5171N/A * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A// Needed for creating default ORB 0N/A * Provides a bridge to the CosNaming server provided by 0N/A * JavaIDL. This class provides the InitialContext from CosNaming. 0N/A * @author Raj Krishnamurthy 0N/A * @author Rosanna Lee 0N/A private final static boolean debug =
false;
5171N/A * Implement one shared ORB among all CNCtx. However, there is a public constructor 5171N/A * accepting an ORB, so we need the option of using a given ORB. 0N/A // Reference counter for tracking _orb references 0N/A * Create a CNCtx object. Gets the initial naming 0N/A * reference for the COS Naming Service from the ORB. 0N/A * The ORB can be passed in via the java.naming.corba.orb property 0N/A * or be created using properties in the environment properties. 0N/A * @param env Environment properties for initializing name service. 0N/A * @exception NamingException Cannot initialize ORB or naming context. 0N/A * This method is used by the iiop and iiopname URL Context factories. 0N/A // rest is the INS name 0N/A // Return the parsed form to prevent subsequent lookup 0N/A // from parsing the string as a composite name 5171N/A // The caller should be aware that a toString() of the name, 5171N/A // which came from the environment will yield its INS syntax, 5171N/A // rather than a composite syntax 0N/A * Creates a CNCtx object which supports the javax.naming 0N/A * apis given a COS Naming Context object. 0N/A * @param orb The ORB used by this context 0N/A * @param tracker The ORB reuse tracker for tracking references to the 0N/A * @param nctx The COS NamingContext object associated with this context 0N/A * @param name The name of this context relative to the root 0N/A "Must supply ORB or NamingContext");
0N/A * These are the URL schemes that need to be processed. 0N/A * IOR and corbaloc URLs can be passed directly to ORB.string_to_object() 0N/A * Initializes the COS Naming Service. 0N/A * This method initializes the three instance fields: 0N/A * _nc : The root naming context. 0N/A * _orb: The ORB to use for connecting RMI/IIOP stubs and for 0N/A * getting the naming context (_nc) if one was not specified 0N/A * explicitly via PROVIDER_URL. 0N/A * _name: The name of the root naming context. 0N/A * _orb is obtained from java.naming.corba.orb if it has been set. 0N/A * Otherwise, _orb is created using the host/port from PROVIDER_URL 0N/A * (if it contains an "iiop" or "iiopname" URL), or from initialization 0N/A * properties specified in env. 0N/A * _nc is obtained from the IOR stored in PROVIDER_URL if it has been 0N/A * set and does not contain an "iiop" or "iiopname" URL. It can be 0N/A * a stringified IOR, "corbaloc" URL, "corbaname" URL, 0N/A * containing a stringified IOR. If PROVIDER_URL has not been 0N/A * set in this way, it is obtained from the result of 0N/A * ORB.resolve_initial_reference("NameService"); 0N/A * _name is obtained from the "iiop", "iiopname", or "corbaname" URL. 0N/A * It is the empty name by default. 0N/A * @param env Environment The possibly null environment. 0N/A * @exception NamingException When an error occurs while initializing the 0N/A * ORB or the naming context. 0N/A // Extract PROVIDER_URL from environment 0N/A // Initialize the root naming context by using the IOR supplied 0N/A // in the PROVIDER_URL 0N/A // Initialize the root naming context by using the URL supplied 0N/A // in the PROVIDER_URL 0N/A // If name supplied in URL, resolve it to a NamingContext 0N/A " does not name a NamingContext");
0N/A " does not name a NamingContext");
0N/A // No PROVIDER_URL supplied; initialize using defaults 0N/A * Handles "iiop" and "iiopname" URLs (INS 98-10-11) 0N/A * Initializes using "corbaname" URL (INS 99-12-03) 0N/A "Cannot convert IOR to a NamingContext: " +
ncIor);
0N/A"ORB.resolve_initial_references(\"NameService\") does not return a NamingContext");
0N/A"COS Name Service not registered with ORB under the name 'NameService'");
0N/A "Cannot convert object reference to NamingContext: " +
ncRef);
0N/A * Does the job of calling the COS Naming API, 0N/A * resolve, and performs the exception mapping. If the resolved 0N/A * object is a COS Naming Context (sub-context), then this function 0N/A * returns a new JNDI naming context object. 0N/A * @param path the NameComponent[] object. 0N/A * @exception NotFound No objects under the name. 0N/A * @exception CannotProceed Unable to obtain a continuation context 0N/A * @exception InvalidName Name not understood. 0N/A * @return Resolved object returned by the COS Name Server. 0N/A * Converts the "String" name into a CompositeName 0N/A * returns the object resolved by the COS Naming api, 0N/A * resolve. Returns the current context if the name is empty. 0N/A * Returns either an org.omg.CORBA.Object or javax.naming.Context object. 0N/A * @param name string used to resolve the object. 0N/A * @exception NamingException See callResolve. 0N/A * @return the resolved object 0N/A * Converts the "Name" name into a NameComponent[] object and 0N/A * returns the object resolved by the COS Naming api, 0N/A * resolve. Returns the current context if the name is empty. 0N/A * Returns either an org.omg.CORBA.Object or javax.naming.Context object. 0N/A * @param name JNDI Name used to resolve the object. 0N/A * @exception NamingException See callResolve. 0N/A * @return the resolved object 0N/A "Context does not have a corresponding NamingContext");
0N/A return this;
// %%% should clone() so that env can be changed 0N/A "problem generating object using object factory");
0N/A * Performs bind or rebind in the context depending on whether the 0N/A * flag rebind is set. The only objects allowed to be bound are of 0N/A * types org.omg.CORBA.Object, org.omg.CosNaming.NamingContext. 0N/A * You can use a state factory to turn other objects (such as 0N/A * Remote) into these acceptable forms. 0N/A * @param pth NameComponent[] object 0N/A * @param obj Object to be bound. 0N/A * @param rebind perform rebind ? if true performs a rebind. 0N/A * @exception NotFound No objects under the name. 0N/A * @exception CannotProceed Unable to obtain a continuation context 0N/A * @exception AlreadyBound An object is already bound to this name. 0N/A "Context does not have a corresponding NamingContext");
0N/A // Call state factories to convert 0N/A // Use naming context object reference 0N/A "Only instances of org.omg.CORBA.Object can be bound");
0N/A // probably narrow() failed? 0N/A * Converts the "Name" name into a NameComponent[] object and 0N/A * performs the bind operation. Uses callBindOrRebind. Throws an 0N/A * invalid name exception if the name is empty. We need a name to 0N/A * bind the object even when we work within the current context. 0N/A * @param name JNDI Name object 0N/A * @param obj Object to be bound. 0N/A * @exception NamingException See callBindOrRebind 0N/A "No object reference bound for specified name");
0N/A * Converts the "String" name into a CompositeName object and 0N/A * performs the bind operation. Uses callBindOrRebind. Throws an 0N/A * invalid name exception if the name is empty. 0N/A * @param name string 0N/A * @param obj Object to be bound. 0N/A * @exception NamingException See callBindOrRebind 0N/A * Converts the "Name" name into a NameComponent[] object and 0N/A * performs the rebind operation. Uses callBindOrRebind. Throws an 0N/A * invalid name exception if the name is empty. We must have a name 0N/A * to rebind the object to even if we are working within the current 0N/A * @param name string 0N/A * @param obj Object to be bound. 0N/A * @exception NamingException See callBindOrRebind 0N/A * Converts the "String" name into a CompositeName object and 0N/A * performs the rebind operation. Uses callBindOrRebind. Throws an 0N/A * invalid name exception if the name is an empty string. 0N/A * @param name string 0N/A * @param obj Object to be bound. 0N/A * @exception NamingException See callBindOrRebind 0N/A * Calls the unbind api of COS Naming and uses the exception mapper 0N/A * class to map the exceptions 0N/A * @param path NameComponent[] object 0N/A * @exception NotFound No objects under the name. If leaf 0N/A * is not found, that's OK according to the JNDI spec 0N/A * @exception CannotProceed Unable to obtain a continuation context 0N/A * @exception InvalidName Name not understood. 0N/A "Context does not have a corresponding NamingContext");
0N/A // If leaf is the one missing, return success 0N/A // This test is not foolproof because some name servers 0N/A // always just return one component in rest_of_name 0N/A // so you might not be able to tell whether that is 0N/A // the leaf (e.g. aa/aa/aa, which one is missing?) 0N/A * Converts the "String" name into a CompositeName object and 0N/A * performs the unbind operation. Uses callUnbind. If the name is 0N/A * empty, throws an invalid name exception. Do we unbind the 0N/A * current context (JNDI spec says work with the current context if 0N/A * the name is empty) ? 0N/A * @param name string 0N/A * @exception NamingException See callUnbind 0N/A * Converts the "Name" name into a NameComponent[] object and 0N/A * performs the unbind operation. Uses callUnbind. Throws an 0N/A * invalid name exception if the name is empty. 0N/A * @param name string 0N/A * @exception NamingException See callUnbind 0N/A * Renames an object. Since COS Naming does not support a rename 0N/A * api, this method unbinds the object with the "oldName" and 0N/A * creates a new binding. 0N/A * @param oldName string, existing name for the binding. 0N/A * @param newName string, name used to replace. 0N/A * @exception NamingException See bind 0N/A * Renames an object. Since COS Naming does not support a rename 0N/A * api, this method unbinds the object with the "oldName" and 0N/A * creates a new binding. 0N/A * @param oldName JNDI Name, existing name for the binding. 0N/A * @param newName JNDI Name, name used to replace. 0N/A * @exception NamingException See bind 0N/A "Context does not have a corresponding NamingContext");
0N/A * Returns a NameClassEnumeration object which has a list of name 0N/A * class pairs. Lists the current context if the name is empty. 0N/A * @param name string 0N/A * @exception NamingException All exceptions thrown by lookup 0N/A * with a non-null argument 0N/A * @return a list of name-class objects as a NameClassEnumeration. 0N/A * Returns a NameClassEnumeration object which has a list of name 0N/A * class pairs. Lists the current context if the name is empty. 0N/A * @param name JNDI Name 0N/A * @exception NamingException All exceptions thrown by lookup 0N/A * @return a list of name-class objects as a NameClassEnumeration. 0N/A * Returns a BindingEnumeration object which has a list of name 0N/A * object pairs. Lists the current context if the name is empty. 0N/A * @param name string 0N/A * @exception NamingException all exceptions returned by lookup 0N/A * @return a list of bindings as a BindingEnumeration. 0N/A * Returns a BindingEnumeration object which has a list of name 0N/A * class pairs. Lists the current context if the name is empty. 0N/A * @param name JNDI Name 0N/A * @exception NamingException all exceptions returned by lookup. 0N/A * @return a list of bindings as a BindingEnumeration. 0N/A "Context does not have a corresponding NamingContext");
0N/A * Calls the destroy on the COS Naming Server 0N/A * @param nc The NamingContext object to use. 0N/A * @exception NotEmpty when the context is not empty and cannot be destroyed. 0N/A "Context does not have a corresponding NamingContext");
0N/A * Uses the callDestroy function to destroy the context. If name is 0N/A * empty destroys the current context. 0N/A * @param name string 0N/A * @exception OperationNotSupportedException when list is invoked 0N/A * with a non-null argument 0N/A * Uses the callDestroy function to destroy the context. Destroys 0N/A * the current context if name is empty. 0N/A * @param name JNDI Name 0N/A * @exception OperationNotSupportedException when list is invoked 0N/A * with a non-null argument 0N/A "Context does not have a corresponding NamingContext");
0N/A // If leaf is the one missing, return success 0N/A return;
// leaf missing OK 0N/A * Calls the bind_new_context COS naming api to create a new subcontext. 0N/A * @param path NameComponent[] object 0N/A * @exception NotFound No objects under the name. 0N/A * @exception CannotProceed Unable to obtain a continuation context 0N/A * @exception InvalidName Name not understood. 0N/A * @exception AlreadyBound An object is already bound to this name. 0N/A * @return the new context object. 0N/A "Context does not have a corresponding NamingContext");
0N/A * Uses the callBindNewContext convenience function to create a new 0N/A * context. Throws an invalid name exception if the name is empty. 0N/A * @param name string 0N/A * @exception NamingException See callBindNewContext 0N/A * @return the new context object. 0N/A * Uses the callBindNewContext convenience function to create a new 0N/A * context. Throws an invalid name exception if the name is empty. 0N/A * @param name string 0N/A * @exception NamingException See callBindNewContext 0N/A * @return the new context object. 0N/A * Is mapped to resolve in the COS Naming api. 0N/A * @param name string 0N/A * @exception NamingException See lookup. 0N/A * @return the resolved object. 0N/A * Is mapped to resolve in the COS Naming api. 0N/A * @param name string 0N/A * @exception NamingException See lookup. 0N/A * @return the resolved object. 0N/A * Allow access to the name parser object. 0N/A * @param String JNDI name, is ignored since there is only one Name 0N/A * @exception NamingException -- 0N/A * @return NameParser object 0N/A * Allow access to the name parser object. 0N/A * @param Name JNDI name, is ignored since there is only one Name 0N/A * @exception NamingException -- 0N/A * @return NameParser object 0N/A * Returns the current environment. 0N/A * @return Environment. 0N/A * Adds to the environment for the current context. 0N/A * Record change but do not reinitialize ORB. 0N/A * @param propName The property name. 0N/A * @param propVal The ORB. 0N/A * @return the previous value of this property if any. 0N/A // Record change but do not reinitialize ORB 5171N/A // Never destroy an orb in CNCtx. 5171N/A // from elsewhere, so that orb is somebody else's reponsibility.