Setting the syntax used to parse name strings

 

JNDI clients which must interoperate with CORBA applications may need to use INS name syntax to represent names in string format. The name syntax property may be passed to the InitialContext constructor through its parameter, in the System properties, or in a jndi.properties file. The initial context and any contexts looked up from that initial context will parse name strings based on the specified syntax.

The following example shows how to set the name syntax to make the initial context parse name strings according to INS syntax.

 

Usage scenario

   
   ...
   import java.util.Hashtable;
   import javax.naming.Context;
   import javax.naming.InitialContext;
   import com.ibm.websphere.naming.PROPS;  // WebSphere naming constants
   ...
   Hashtable env = new Hashtable();
   env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
   env.put(Context.PROVIDER_URL, ...);
   env.put(PROPS.NAME_SYNTAX, PROPS.NAME_SYNTAX_INS);
   Context initialContext = new InitialContext(env);
   // The following name maps to a CORBA name component as follows:
   //    id = "a.name", kind = "in.INS.format"
   // The unescaped dot is used as the delimiter.  Escaped dots are interpreted literally.
   java.lang.Object o = initialContext.lookup("a\.name.in\.INS\.format");
   ...


Developing applications that use JNDI

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.