📄 initialcontext.html
字号:
<!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="init(java.util.Hashtable)"><!-- --></A><H3>init</H3><PRE>protected void <B>init</B>(<A HREF="../../java/util/Hashtable.html">Hashtable</A> environment) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD>Initializes the initial context using the supplied environment. Environment properties are discussed in the class description. <p> This method will modify <tt>environment</tt> and save a reference to it. The caller may no longer modify it.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>environment</CODE> - environment used to create the initial context. Null indicates an empty environment.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - if a naming exception is encountered<DT><B>Since: </B><DD>1.3</DD><DT><B>See Also: </B><DD><A HREF="../../javax/naming/InitialContext.html#InitialContext(boolean)"><CODE>InitialContext(boolean)</CODE></A></DL></DD></DL><HR><A NAME="getDefaultInitCtx()"><!-- --></A><H3>getDefaultInitCtx</H3><PRE>protected <A HREF="../../javax/naming/Context.html">Context</A> <B>getDefaultInitCtx</B>() throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD>Retrieves the initial context by calling <code>NamingManager.getInitialContext()</code> and cache it in defaultInitCtx. Set <code>gotDefault</code> so that we know we've tried this before.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The non-null cached initial context.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NoInitialContextException.html">NoInitialContextException</A></CODE> - If cannot find an initial context.<DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - If a naming exception was encountered.</DL></DD></DL><HR><A NAME="getURLOrDefaultInitCtx(java.lang.String)"><!-- --></A><H3>getURLOrDefaultInitCtx</H3><PRE>protected <A HREF="../../javax/naming/Context.html">Context</A> <B>getURLOrDefaultInitCtx</B>(<A HREF="../../java/lang/String.html">String</A> name) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD>Retrieves a context for resolving the string name <code>name</code>. If <code>name</code> name is a URL string, then attempt to find a URL context for it. If none is found, or if <code>name</code> is not a URL string, then return <code>getDefaultInitCtx()</code>.<p> See getURLOrDefaultInitCtx(Name) for description of how a subclass should use this method.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - The non-null name for which to get the context.<DT><B>Returns:</B><DD>A URL context for <code>name</code> or the cached initial context. The result cannot be null.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NoInitialContextException.html">NoInitialContextException</A></CODE> - If cannot find an initial context.<DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - In a naming exception is encountered.<DT><B>See Also: </B><DD><A HREF="../../javax/naming/spi/NamingManager.html#getURLContext(java.lang.String, java.util.Hashtable)"><CODE>NamingManager.getURLContext(java.lang.String, java.util.Hashtable)</CODE></A></DL></DD></DL><HR><A NAME="getURLOrDefaultInitCtx(javax.naming.Name)"><!-- --></A><H3>getURLOrDefaultInitCtx</H3><PRE>protected <A HREF="../../javax/naming/Context.html">Context</A> <B>getURLOrDefaultInitCtx</B>(<A HREF="../../javax/naming/Name.html">Name</A> name) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD>Retrieves a context for resolving <code>name</code>. If the first component of <code>name</code> name is a URL string, then attempt to find a URL context for it. If none is found, or if the first component of <code>name</code> is not a URL string, then return <code>getDefaultInitCtx()</code>.<p> When creating a subclass of InitialContext, use this method as follows. Define a new method that uses this method to get an initial context of the desired subclass. <p><blockquote><pre> protected XXXContext getURLOrDefaultInitXXXCtx(Name name) throws NamingException { Context answer = getURLOrDefaultInitCtx(name); if (!(answer instanceof XXXContext)) { if (answer == null) { throw new NoInitialContextException(); } else { throw new NotContextException("Not an XXXContext"); } } return (XXXContext)answer; } </pre></blockquote> When providing implementations for the new methods in the subclass, use this newly defined method to get the initial context. <p><blockquote><pre> public Object XXXMethod1(Name name, ...) { throws NamingException { return getURLOrDefaultInitXXXCtx(name).XXXMethod1(name, ...); } </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - The non-null name for which to get the context.<DT><B>Returns:</B><DD>A URL context for <code>name</code> or the cached initial context. The result cannot be null.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NoInitialContextException.html">NoInitialContextException</A></CODE> - If cannot find an initial context.<DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - In a naming exception is encountered.<DT><B>See Also: </B><DD><A HREF="../../javax/naming/spi/NamingManager.html#getURLContext(java.lang.String, java.util.Hashtable)"><CODE>NamingManager.getURLContext(java.lang.String, java.util.Hashtable)</CODE></A></DL></DD></DL><HR><A NAME="lookup(java.lang.String)"><!-- --></A><H3>lookup</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>lookup</B>(<A HREF="../../java/lang/String.html">String</A> name) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></B></DD><DD>Retrieves the named object. See <A HREF="../../javax/naming/Context.html#lookup(javax.naming.Name)"><CODE>Context.lookup(Name)</CODE></A> for details.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../javax/naming/Context.html#lookup(java.lang.String)">lookup</A></CODE> in interface <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></DL></DD><DD>Following copied from interface: <CODE>javax.naming.Context</CODE></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the object to look up<DT><B>Returns:</B><DD>the object bound to <tt>name</tt><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - if a naming exception is encountered</DL></DD></DL><HR><A NAME="lookup(javax.naming.Name)"><!-- --></A><H3>lookup</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>lookup</B>(<A HREF="../../javax/naming/Name.html">Name</A> name) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></B></DD><DD>Retrieves the named object. If <tt>name</tt> is empty, returns a new instance of this context (which represents the same naming context as this context, but its environment may be modified independently and it may be accessed concurrently).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../javax/naming/Context.html#lookup(javax.naming.Name)">lookup</A></CODE> in interface <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></DL></DD><DD>Following copied from interface: <CODE>javax.naming.Context</CODE></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the object to look up<DT><B>Returns:</B><DD>the object bound to <tt>name</tt><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - if a naming exception is encountered<DT><B>See Also: </B><DD><A HREF="../../javax/naming/Context.html#lookup(java.lang.String)"><CODE>Context.lookup(String)</CODE></A>, <A HREF="../../javax/naming/Context.html#lookupLink(javax.naming.Name)"><CODE>Context.lookupLink(Name)</CODE></A></DL></DD></DL><HR><A NAME="bind(java.lang.String, java.lang.Object)"><!-- --></A><H3>bind</H3><PRE>public void <B>bind</B>(<A HREF="../../java/lang/String.html">String</A> name, <A HREF="../../java/lang/Object.html">Object</A> obj) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></B></DD><DD>Binds a name to an object. See <A HREF="../../javax/naming/Context.html#bind(javax.naming.Name, java.lang.Object)"><CODE>Context.bind(Name, Object)</CODE></A> for details.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../javax/naming/Context.html#bind(java.lang.String, java.lang.Object)">bind</A></CODE> in interface <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></DL></DD><DD>Following copied from interface: <CODE>javax.naming.Context</CODE></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name to bind; may not be empty<DD><CODE>obj</CODE> - the object to bind; possibly null<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NameAlreadyBoundException.html">NameAlreadyBoundException</A></CODE> - if name is already bound<DD><CODE><A HREF="../../javax/naming/directory/InvalidAttributesException.html">InvalidAttributesException</A></CODE> - if object did not supply all mandatory attributes<DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - if a naming exception is encountered</DL></DD></DL><HR><A NAME="bind(javax.naming.Name, java.lang.Object)"><!-- --></A><H3>bind</H3><PRE>public void <B>bind</B>(<A HREF="../../javax/naming/Name.html">Name</A> name, <A HREF="../../java/lang/Object.html">Object</A> obj) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></B></DD><DD>Binds a name to an object. All intermediate contexts and the target context (that named by all but terminal atomic component of the name) must already exist.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../javax/naming/Context.html#bind(javax.naming.Name, java.lang.Object)">bind</A></CODE> in interface <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></DL></DD><DD>Following copied from interface: <CODE>javax.naming.Context</CODE></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name to bind; may not be empty<DD><CODE>obj</CODE> - the object to bind; possibly null<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/NameAlreadyBoundException.html">NameAlreadyBoundException</A></CODE> - if name is already bound<DD><CODE><A HREF="../../javax/naming/directory/InvalidAttributesException.html">InvalidAttributesException</A></CODE> - if object did not supply all mandatory attributes<DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - if a naming exception is encountered<DT><B>See Also: </B><DD><A HREF="../../javax/naming/Context.html#bind(java.lang.String, java.lang.Object)"><CODE>Context.bind(String, Object)</CODE></A>, <A HREF="../../javax/naming/Context.html#rebind(javax.naming.Name, java.lang.Object)"><CODE>Context.rebind(Name, Object)</CODE></A>, <A HREF="../../javax/naming/directory/DirContext.html#bind(javax.naming.Name, java.lang.Object, javax.naming.directory.Attributes)"><CODE>DirContext.bind(Name, Object, javax.naming.directory.Attributes)</CODE></A></DL></DD></DL><HR><A NAME="rebind(java.lang.String, java.lang.Object)"><!-- --></A><H3>rebind</H3><PRE>public void <B>rebind</B>(<A HREF="../../java/lang/String.html">String</A> name, <A HREF="../../java/lang/Object.html">Object</A> obj) throws <A HREF="../../javax/naming/NamingException.html">NamingException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></B></DD><DD>Binds a name to an object, overwriting any existing binding. See <A HREF="../../javax/naming/Context.html#rebind(javax.naming.Name, java.lang.Object)"><CODE>Context.rebind(Name, Object)</CODE></A> for details.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../javax/naming/Context.html#rebind(java.lang.String, java.lang.Object)">rebind</A></CODE> in interface <CODE><A HREF="../../javax/naming/Context.html">Context</A></CODE></DL></DD><DD>Following copied from interface: <CODE>javax.naming.Context</CODE></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name to bind; may not be empty<DD><CODE>obj</CODE> - the object to bind; possibly null<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/naming/directory/InvalidAttributesException.html">InvalidAttributesException</A></CODE> - if object did not supply all mandatory attributes<DD><CODE><A HREF="../../javax/naming/NamingException.html">NamingException</A></CODE> - if a naming exception is encountered</DL></DD></DL><HR><A NAME="rebind(javax.naming.Name, java.lang.Object)"><!-- --></A><H3>rebind</H3><PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -