📄 jndi-cos.html
字号:
<HTML><HEAD><title>JNDI/COS Naming Service Provider</title></HEAD><BODY BGCOLOR="#FFFFFF" TEXT=#000000 LINK=#0000ff VLINK=#000077ALINK=#ff0000><hr SIZE=3 NOSHADE WIDTH="100%"><center><h1>COS Naming Service Provider for the <br>Java Naming and Directory Interface<font size=4><sup>TM</sup></font> (JNDI)</h1></center><hr SIZE=3 NOSHADE WIDTH="100%"><P><FONT SIZE=-1>Please send feedback to <a href="mailto:jndi@java.sun.com">jndi@java.sun.com</a></FONT><P><P><I>Table of Contents</I><UL><LI><A HREF="#INTRO">Introduction</A></LI><LI> <A HREF="#CONF">Conformance</A></LI> <LI><A HREF="#PROP">Environment Properties</A></LI><LI><A HREF="#ORB">ORB Initialization</A></LI><LI><A HREF="#ROOT">Root Naming Context Initialization</A></LI><LI><A HREF="#URL">Names and URLs</A></LI><LI><A HREF="#API">API Mapping</A></LI><LI><A HREF="#CORBA">Converting CORBA Programs to use JNDI</A></LI><LI><A HREF="#SEC">Security Considerations</A></LI></UL><P><HR><P><A NAME="INTRO"><H2>Introduction</H2><p>The Common Object Services (COS) Name Server is the name server forstoring Common Object Request Broker Architecture (CORBA) objectreferences. It can be accessed from CORBA applications using the COSNaming package (org.omg.CORBA.CosNaming).<p>The JNDI/COS naming service provider implements the<tt>javax.naming.Context</tt> interface on top of the COS Naming packagein order to allow applications to use JNDI to access the COS Name Server.JNDI can also be used to access other naming and directory services,in addition to the COS Name Server, thereby offering the CORBAapplication one interface for accessing different naming and directoryservices.<p>This document describes the features of the COS naming service providerand contains details of how JNDI is mapped to the COS naming package.<hr><p><A NAME="CONF"><H2>Conformance</H2><p>The COS naming service provider for JNDI uses<a href=http://java.sun.com/products/jdk/1.2/docs/guide/idl>Java<font size="-2"><sup>TM</sup></font> IDL</a>, the Java programming language mappingto the industry standard Object Management Group InterfaceDefinition Language (OMG IDL).In particular, it uses the<a href="http://java.sun.com/products/jdk/1.2/docs/guide/idl/jidlNaming.html">COS Naming Service</a>.<p>The complete specification for COS Naming can be obtained from <a href="http://www.omg.org/library/">OMG</a>.<p>The syntax of names conforms to the Interoperable NamingServer (INS) specification, <a href="ftp://ftp.omg.org/pub/docs/orbos/98-10-11.pdf">OMG TC Document orbos/98-10-11</a>.This is described in <a href="#URL">Names and URLs</a>.<hr><p><A NAME="PROP"><H2>Environment Properties</H2><p>The following JNDI environment properties are relevant for theCOS naming service provider. See the <a href=http://java.sun.com//products/jndi/1.2/javadoc/javax/naming/InitialContext.html#ENVIRONMENT>JNDI documentation</a>for a description of how properties are initialized using the environment properties, system properties, applet parameters, and resource files.<p><b><pre>java.naming.factory.initial</pre></b><blockquote> This property is used to select the COS naming service provider; it's not actually used by the provider itself. It specifies the class name of the initial context factory for the provider.<p> For example:<p><blockquote><pre>env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");</pre></blockquote><p> This property must be set if you are using the COS naming service as the initial context. The only exception is if you supply only URLs to the initial context, in which case, you don't need to specify this property. See <a href="#URL">Names and URLs</a> for details.</blockquote><a name=URLPROP><b><pre>java.naming.provider.url</pre></b></a><blockquote> This property is used to configure the root naming context and/or the Object Request Broker (ORB). Its value is the string representation of a URL.<p> If the URL scheme is either "iiop" or "iiopname", the host and port fields of the URL are used to initialize the ORB. An "iiopname" URL must conform to the <a href="ftp://ftp.omg.org/pub/docs/orbos/98-10-11.pdf">INS specification</a>. It has the form:<p><blockquote><pre>iiopname://[<addr_list>][/<cosnaming name>]</pre></blockquote><p> An "iiop" URL is supported for backward compatibility with an older version of the INS specification. It has the form:<p><blockquote><pre>iiop://[<host>[:<port>]][/<cosnaming name>]</pre></blockquote><p> For both "iiop" and "iiopname" URLs, if the host is not specified, it defaults to "localhost" for an application and the applet's host for an applet. If the port is not specified, it defaults to 9999 for "iiopname", and 900 for "iiop". The root naming context is obtained by invoking the following method on the ORB:<blockquote><pre>orb.resolve_initial_references("NameService");</pre></blockquote> <p> If the "cosnaming name" is nonempty, the root naming context is the naming context named by "cosnaming name".<p> If the URL scheme is "IOR", the property must contain the stringified IOR of the root naming context.<p> If the URL scheme is neither "iiop", "iiopname", nor "IOR", the URL must name a location that contains the stringified IOR of the root naming context. For example, if the property contains "file:/nsdir/ior", the file "/nsdir/ior" must contain a stringified IOR. The URL scheme can be any for which there is a corresponding URL protocol handler ( <tt><a href= "http://java.sun.com/products/jdk/1.2/docs/api/java/net/URLStreamHandler.html"> java.net.URLStreamHandler</tt></a>). See the <tt><a href= "http://java.sun.com/products/jdk/1.2/docs/api/java/net/URL.html"> java.net.URL</a></tt> class for details. The stringified IOR is read from the data stream corresponding to the URL assuming a character encoding of ISO Latin-1. The stringified IOR is the first line in the stream that contains the prefix "IOR:". For example, if the URL scheme is "http", the headers in the stream are skipped and the first line containing the prefix "IOR:" is returned as the IOR.<p> When the property specifies a stringified IOR or the location of one, the root naming context is that named by the the stringified IOR. The ORB is initialized using the <a href=#ORBPROP><tt>java.naming.corba.orb</tt></a> property, the <a href=#APPPROP><tt>java.naming.applet</tt></a> property, or <a href=#OTHERPROP>other ORB intiailization properties</a>.<p> If this property is not specified, the ORB is initialized using the <a href=#ORBPROP><tt>java.naming.corba.orb</tt></a> property, the <a href=#APPPROP><tt>java.naming.applet</tt></a> property, or <a href=#OTHERPROP>other ORB intiailization properties</a>. The root naming context is obtained by invoking<p><blockquote><pre>orb.resolve_initial_references("NameService");</pre></blockquote></blockquote><a name=ORBPROP><b><pre>java.naming.corba.orb</pre></b></a><blockquote> This property specifies the ORB that the program is using. When the JNDI COS naming service provider needs to use an ORB, for example, to look up the "NameService" initial reference or to turn a stringified IOR into an object reference, it will use this ORB. <p> In an applcation you can set this property as follows:<blockquote> <pre>ORB orb = ORB.init(args, null);Hashtable env = new Hashtable(5, 0.75f);env.put("java.naming.corba.orb", orb);... </pre></blockquote> In an applet, you can set it as follows:<blockquote> <pre>public class MyApplet extends Applet { public someInitMethod() { ORB orb = ORB.init(this, null); Hashtable env = new Hashtable(5, 0.75f); env.put("java.naming.corba.orb", orb); ... }...} </pre></blockquote> If this property is not set, then the <a href=#URLPROP><tt>java.naming.provider.url</tt></a> property, the <a href=#APPPROP><tt>java.naming.applet</tt></a> property, or <a href=#OTHERPROP>the ORB initialization properties</a> are used to initialize the ORB.</blockquote><a name=APPPROP><b><pre>java.naming.applet</pre></b></a><blockquote> This property specifies the applet that the program is using. It is used to initialize the ORB to be used by the COS naming service provider. Its parameters are used for setting JNDI-related properties; see the<a href=http://java.sun.com//products/jndi/1.2/javadoc/javax/naming/InitialContext.html#ENVIRONMENT>JNDI documentation</a> for details.<blockquote> <pre>public class MyApplet extends Applet { public someInitMethod() { Hashtable env = new Hashtable(5, 0.75f); env.put("java.naming.applet", this); ... }...} </pre></blockquote></blockquote> <b><pre>java.naming.factory.state</pre></b><blockquote> A colon-separated list of the fully qualified class names of state factory classes used to get an object's state for storing given the object itself. You can use this mechanism to transform an object into forms that can be stored into a COS name server. The COS name server supports storing CORBA objects. <p> A state factory that transforms a <tt>java.rmi.Remote</tt> into a CORBA object is supplied by default. This factory is useful for applications using <a href=http://java.sun.com/products/rmi-iiop>RMI-IIOP</a>. You can supply other factories to effect the transformation of other objects into CORBA objects for storing. See <a href="http://java.sun.com/products/jndi/1.2/javadoc/javax/naming/spi/NamingManager.html#getStateToBind(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)"><tt>javax.naming.spi.NamingManager.getStateToBind()</tt></a> for details.</blockquote><b><pre>java.naming.factory.object</pre></b><blockquote> A colon-separated list of the fully qualified class names of object factory classes for transforming a CORBA object. You can use this mechanism to transform an object into forms expected by the application. For example, a specialized object factory could do the appropriate narrowing to return an object of the expected type. See<a href="http://java.sun.com/products/jndi/1.2/javadoc/javax/naming/spi/NamingManager.html#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)"><tt>javax.naming.spi.NamingManager.getObjectInstance()</tt></a> for details.</blockquote> <b><pre>java.naming.batchsize</pre></b><blockquote> Specifies the batch size to use in <tt>CosNaming::BindingIterator.next_n</tt> when getting the results of a <tt>list()</tt>/<tt>listBindings()</tt>. The default is "100."<p> For example, the following sets the batch size to be 24:<blockquote><pre> env.put(Context.BATCHSIZE, "24");</pre></blockquote></blockquote> <a name=OTHERPROP><b>ORB initialization properties</b></a><blockquote> You can specify CORBA related properties such as those with the "<tt>org.omg.CORBA</tt>." prefix as properties. Properties of type <tt>String</tt> are used to initialize the ORB.</blockquote><hr><p><A NAME="ORB"><H2>ORB Initialization</H2><p>The properties that affect which ORB is used and how theORB is initialized are:<ul><li><pre>java.naming.corba.orb</pre><li><pre>java.naming.applet</pre><li><pre>java.naming.provider.url</pre><li><tt>org.omg.CORBA.*</tt> and other ORB-specific properties of type <tt>String</tt></ul>The following algorithm is used to determine which ORB is used:<ol><li> If <tt>java.naming.corba.orb</tt> has been set, its value (an ORB) is used.<p><li> Otherwise, the provider will internally initialize and use an ORB as follows:<p> <dl> <dd>a) Any <tt>org.omg.CORBA.*</tt> properties and properties of type <tt>String</tt> are extracted and used as part of the <tt>Properties</tt> argument to the <tt>ORB.init()</tt> method. You can use this mechanism to specify, for example, the ORB implementation or host to use.</dd> <p> <dd>b) If <tt>java.naming.provider.url</tt> has been set and it contains a URL of scheme "iiop" or "iiopname", the host and port number specified in the URL are used as part of the <tt>Properties</tt> argument to the <tt>ORB.init()</tt> method, overriding any <tt>org.omg.CORBA.ORBInitialHost</tt> and <tt>org.omg.CORBA.ORBInitialPort</tt> properties set up in (a). <p> <dd>c) The <tt>Properties</tt> instance constructed in (a) and (b) are passed to <tt>ORB.init()</tt> along with the <tt>Applet</tt> instance in <tt>java.naming.applet</tt> property, or an empty <tt>String[]</tt> if <tt>java.naming.applet</tt> was not supplied.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -