In order to retrieve (look up) administered objects from a foreign naming/directory service, an initial context must be established for that service. The following example illustrates how to create an initial context using the Sun LDAP JNDI provider for an LDAP server running on the local machine, listening on port 20329, where the root naming context is myJMSObjects
:
Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:20329/o=myJMSObjects"); Context context = new InitialContext(env);
Once the context is established, retrieving (looking up) administered objects from a foreign naming/directory service is accomplished no differently than with the TIBCO Enterprise Message Service server. However, there is one exception two properties must be added to the context object that inform the JNDI provider where to find the object factories for the TIBCO Enterprise Message Service administered objects. The JNDI provider invokes these factories when any of the objects are retrieved. The properties are responsible for locating the factories that create the appropriate instances of the desired objects for the user.
The following example illustrates setting these properties. If the variable "context" contains the initial context for the foreign naming/directory service, then these properties would be set with the following two lines:
context.addToEnvironment(Context.OBJECT_FACTORIES, "com.tibco.tibjms.naming.TibjmsObjectFactory"); context.addToEnvironment(Context.URL_PKG_PREFIXES, "com.tibco.tibjms.naming");
Once these properties are set, then the "lookup" method of the context can be used to retrieve any object stored in that context.
For an example of retrieving administered objects from a foreign naming/directory service, see the tibjmsJNDIRead.java
example included with TIBCO Enterprise Message Service.
TIBCO Enterprise Message Service™ Application Integration Guide Software Release 4.3, February 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |