Package org.glassfish.jndi.cosnaming
Class CNCtx
java.lang.Object
org.glassfish.jndi.cosnaming.CNCtx
- All Implemented Interfaces:
Context
Provides a bridge to the CosNaming server provided by
JavaIDL. This class provides the InitialContext from CosNaming.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ORB
private NameComponent[]
(package private) ORB
private static final boolean
(package private) int
private static final String
(package private) boolean
(package private) boolean
(package private) OrbReuseTracker
(package private) static final CNNameParser
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
CNCtx()
(package private)
Create a CNCtx object.(package private)
CNCtx
(ORB orb, OrbReuseTracker tracker, NamingContext nctx, Hashtable<String, Object> env, NameComponent[] name) Creates a CNCtx object which supports the javax.naming apis given a COS Naming Context object. -
Method Summary
Modifier and TypeMethodDescriptionaddToEnvironment
(String propName, Object propValue) Adds to the environment for the current context.void
Converts the "String" name into a CompositeName object and performs the bind operation.void
Converts the "Name" name into a NameComponent[] object and performs the bind operation.private Context
callBindNewContext
(NameComponent[] path) Calls the bind_new_context COS naming api to create a new subcontext.private void
callBindOrRebind
(NameComponent[] pth, Name name, Object obj, boolean rebind) Performs bind or rebind in the context depending on whether the flag rebind is set.private void
Calls the destroy on the COS Naming Server(package private) Object
callResolve
(NameComponent[] path) Does the job of calling the COS Naming API, resolve, and performs the exception mapping.private void
callUnbind
(NameComponent[] path) Calls the unbind api of COS Naming and uses the exception mapper class to map the exceptionsvoid
close()
composeName
(String name, String prefix) composeName
(Name name, Name prefix) createSubcontext
(String name) Uses the callBindNewContext convenience function to create a new context.createSubcontext
(Name name) Uses the callBindNewContext convenience function to create a new context.static ResolveResult
createUsingURL
(String url, Hashtable<?, ?> env) This method is used by the iiop and iiopname URL Context factories.void
void
destroySubcontext
(String name) Uses the callDestroy function to destroy the context.void
destroySubcontext
(Name name) Uses the callDestroy function to destroy the context.protected void
finalize()
private static Context
private static ORB
Returns the current environment.getNameParser
(String name) Allow access to the name parser object.getNameParser
(Name name) Allow access to the name parser object.private String
getStringifiedIor
(String url) void
private void
initOrbAndRootContext
(Hashtable<?, ?> env) Initializes the COS Naming Service.private String
initUsingCorbanameUrl
(ORB orb, String url, Hashtable<?, ?> env) Initializes using "corbaname" URL (INS 99-12-03)private String
initUsingIiopUrl
(ORB defOrb, String url, Hashtable<?, ?> env) Handles "iiop" and "iiopname" URLs (INS 98-10-11)private String
initUsingUrl
(ORB orb, String url, Hashtable<?, ?> env) private static boolean
isCorbaUrl
(String url) These are the URL schemes that need to be processed.private boolean
leafNotFound
(NotFound e, NameComponent leaf) Returns a NameClassEnumeration object which has a list of name class pairs.Returns a NameClassEnumeration object which has a list of name class pairs.listBindings
(String name) Returns a BindingEnumeration object which has a list of name object pairs.listBindings
(Name name) Returns a BindingEnumeration object which has a list of name class pairs.Converts the "String" name into a CompositeName returns the object resolved by the COS Naming api, resolve.Converts the "Name" name into a NameComponent[] object and returns the object resolved by the COS Naming api, resolve.lookupLink
(String name) Is mapped to resolve in the COS Naming api.lookupLink
(Name name) Is mapped to resolve in the COS Naming api.(package private) NameComponent[]
makeFullName
(NameComponent[] child) void
Converts the "String" name into a CompositeName object and performs the rebind operation.void
Converts the "Name" name into a NameComponent[] object and performs the rebind operation.removeFromEnvironment
(String propName) void
Renames an object.void
Renames an object.private void
setOrbAndRootContext
(ORB orb, String ncIor) private void
setOrbAndRootContext
(ORB orb, Object ncRef) void
Converts the "String" name into a CompositeName object and performs the unbind operation.void
Converts the "Name" name into a NameComponent[] object and performs the unbind operation.
-
Field Details
-
debug
private static final boolean debug- See Also:
-
_defaultOrb
-
_orb
ORB _orb -
_nc
-
_name
-
_env
-
parser
-
FED_PROP
- See Also:
-
federation
boolean federation -
orbTracker
OrbReuseTracker orbTracker -
enumCount
int enumCount -
isCloseCalled
boolean isCloseCalled
-
-
Constructor Details
-
CNCtx
CNCtx(Hashtable<?, ?> env) throws NamingExceptionCreate a CNCtx object. Gets the initial naming reference for the COS Naming Service from the ORB. The ORB can be passed in via the java.naming.corba.orb property or be created using properties in the environment properties.- Parameters:
env
- Environment properties for initializing name service.- Throws:
NamingException
- Cannot initialize ORB or naming context.
-
CNCtx
private CNCtx() -
CNCtx
CNCtx(ORB orb, OrbReuseTracker tracker, NamingContext nctx, Hashtable<String, Object> env, NameComponent[] name) throws NamingExceptionCreates a CNCtx object which supports the javax.naming apis given a COS Naming Context object.- Parameters:
orb
- The ORB used by this contexttracker
- The ORB reuse tracker for tracking references to the orb objectnctx
- The COS NamingContext object associated with this contextname
- The name of this context relative to the root- Throws:
NamingException
-
-
Method Details
-
getDefaultOrb
-
createUsingURL
This method is used by the iiop and iiopname URL Context factories.- Throws:
NamingException
-
makeFullName
-
getNameInNamespace
- Specified by:
getNameInNamespace
in interfaceContext
- Throws:
NamingException
-
isCorbaUrl
These are the URL schemes that need to be processed. IOR and corbaloc URLs can be passed directly to ORB.string_to_object() -
initOrbAndRootContext
Initializes the COS Naming Service. This method initializes the three instance fields: _nc : The root naming context. _orb: The ORB to use for connecting RMI/IIOP stubs and for getting the naming context (_nc) if one was not specified explicitly via PROVIDER_URL. _name: The name of the root naming context._orb is obtained from java.naming.corba.orb if it has been set. Otherwise, _orb is created using the host/port from PROVIDER_URL (if it contains an "iiop" or "iiopname" URL), or from initialization properties specified in env.
_nc is obtained from the IOR stored in PROVIDER_URL if it has been set and does not contain an "iiop" or "iiopname" URL. It can be a stringified IOR, "corbaloc" URL, "corbaname" URL, or a URL (such as file/http/ftp) to a location containing a stringified IOR. If PROVIDER_URL has not been set in this way, it is obtained from the result of ORB.resolve_initial_reference("NameService");
_name is obtained from the "iiop", "iiopname", or "corbaname" URL. It is the empty name by default.
- Parameters:
env
- Environment The possibly null environment.- Throws:
NamingException
- When an error occurs while initializing the ORB or the naming context.
-
initUsingUrl
- Throws:
NamingException
-
initUsingIiopUrl
Handles "iiop" and "iiopname" URLs (INS 98-10-11)- Throws:
NamingException
-
initUsingCorbanameUrl
private String initUsingCorbanameUrl(ORB orb, String url, Hashtable<?, ?> env) throws NamingExceptionInitializes using "corbaname" URL (INS 99-12-03)- Throws:
NamingException
-
setOrbAndRootContext
- Throws:
NamingException
-
setOrbAndRootContext
- Throws:
NamingException
-
getStringifiedIor
- Throws:
NamingException
-
callResolve
Does the job of calling the COS Naming API, resolve, and performs the exception mapping. If the resolved object is a COS Naming Context (sub-context), then this function returns a new JNDI naming context object.- Parameters:
path
- the NameComponent[] object.- Returns:
- Resolved object returned by the COS Name Server.
- Throws:
NotFound
- No objects under the name.CannotProceed
- Unable to obtain a continuation contextInvalidName
- Name not understood.NamingException
-
lookup
Converts the "String" name into a CompositeName returns the object resolved by the COS Naming api, resolve. Returns the current context if the name is empty. Returns either an org.omg.CORBA.Object or javax.naming.Context object.- Specified by:
lookup
in interfaceContext
- Parameters:
name
- string used to resolve the object.- Returns:
- the resolved object
- Throws:
NamingException
- See callResolve.
-
lookup
Converts the "Name" name into a NameComponent[] object and returns the object resolved by the COS Naming api, resolve. Returns the current context if the name is empty. Returns either an org.omg.CORBA.Object or javax.naming.Context object.- Specified by:
lookup
in interfaceContext
- Parameters:
name
- JNDI Name used to resolve the object.- Returns:
- the resolved object
- Throws:
NamingException
- See callResolve.
-
callBindOrRebind
private void callBindOrRebind(NameComponent[] pth, Name name, Object obj, boolean rebind) throws NamingException Performs bind or rebind in the context depending on whether the flag rebind is set. The only objects allowed to be bound are of types org.omg.CORBA.Object, org.omg.CosNaming.NamingContext. You can use a state factory to turn other objects (such as Remote) into these acceptable forms. Uses the COS Naming apis bind/rebind or bind_context/rebind_context.- Parameters:
pth
- NameComponent[] objectobj
- Object to be bound.rebind
- perform rebind ? if true performs a rebind.- Throws:
NotFound
- No objects under the name.CannotProceed
- Unable to obtain a continuation contextAlreadyBound
- An object is already bound to this name.NamingException
-
bind
Converts the "Name" name into a NameComponent[] object and performs the bind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is empty. We need a name to bind the object even when we work within the current context.- Specified by:
bind
in interfaceContext
- Parameters:
name
- JNDI Name objectobj
- Object to be bound.- Throws:
NamingException
- See callBindOrRebind
-
getContinuationContext
- Throws:
NamingException
-
bind
Converts the "String" name into a CompositeName object and performs the bind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is empty.- Specified by:
bind
in interfaceContext
- Parameters:
name
- stringobj
- Object to be bound.- Throws:
NamingException
- See callBindOrRebind
-
rebind
Converts the "Name" name into a NameComponent[] object and performs the rebind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is empty. We must have a name to rebind the object to even if we are working within the current context.- Specified by:
rebind
in interfaceContext
- Parameters:
name
- stringobj
- Object to be bound.- Throws:
NamingException
- See callBindOrRebind
-
rebind
Converts the "String" name into a CompositeName object and performs the rebind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is an empty string.- Specified by:
rebind
in interfaceContext
- Parameters:
name
- stringobj
- Object to be bound.- Throws:
NamingException
- See callBindOrRebind
-
callUnbind
Calls the unbind api of COS Naming and uses the exception mapper class to map the exceptions- Parameters:
path
- NameComponent[] object- Throws:
NotFound
- No objects under the name. If leaf is not found, that's OK according to the JNDI specCannotProceed
- Unable to obtain a continuation contextInvalidName
- Name not understood.NamingException
-
leafNotFound
-
unbind
Converts the "String" name into a CompositeName object and performs the unbind operation. Uses callUnbind. If the name is empty, throws an invalid name exception. Do we unbind the current context (JNDI spec says work with the current context if the name is empty) ?- Specified by:
unbind
in interfaceContext
- Parameters:
name
- string- Throws:
NamingException
- See callUnbind
-
unbind
Converts the "Name" name into a NameComponent[] object and performs the unbind operation. Uses callUnbind. Throws an invalid name exception if the name is empty.- Specified by:
unbind
in interfaceContext
- Parameters:
name
- string- Throws:
NamingException
- See callUnbind
-
rename
Renames an object. Since COS Naming does not support a rename api, this method unbinds the object with the "oldName" and creates a new binding.- Specified by:
rename
in interfaceContext
- Parameters:
oldName
- string, existing name for the binding.newName
- string, name used to replace.- Throws:
NamingException
- See bind
-
rename
Renames an object. Since COS Naming does not support a rename api, this method unbinds the object with the "oldName" and creates a new binding.- Specified by:
rename
in interfaceContext
- Parameters:
oldName
- JNDI Name, existing name for the binding.newName
- JNDI Name, name used to replace.- Throws:
NamingException
- See bind
-
list
Returns a NameClassEnumeration object which has a list of name class pairs. Lists the current context if the name is empty.- Specified by:
list
in interfaceContext
- Parameters:
name
- string- Returns:
- a list of name-class objects as a NameClassEnumeration.
- Throws:
NamingException
- All exceptions thrown by lookup with a non-null argument
-
list
Returns a NameClassEnumeration object which has a list of name class pairs. Lists the current context if the name is empty.- Specified by:
list
in interfaceContext
- Parameters:
name
- JNDI Name- Returns:
- a list of name-class objects as a NameClassEnumeration.
- Throws:
NamingException
- All exceptions thrown by lookup
-
listBindings
Returns a BindingEnumeration object which has a list of name object pairs. Lists the current context if the name is empty.- Specified by:
listBindings
in interfaceContext
- Parameters:
name
- string- Returns:
- a list of bindings as a BindingEnumeration.
- Throws:
NamingException
- all exceptions returned by lookup
-
listBindings
Returns a BindingEnumeration object which has a list of name class pairs. Lists the current context if the name is empty.- Specified by:
listBindings
in interfaceContext
- Parameters:
name
- JNDI Name- Returns:
- a list of bindings as a BindingEnumeration.
- Throws:
NamingException
- all exceptions returned by lookup.
-
callDestroy
Calls the destroy on the COS Naming Server- Parameters:
nc
- The NamingContext object to use.- Throws:
NotEmpty
- when the context is not empty and cannot be destroyed.NamingException
-
destroySubcontext
Uses the callDestroy function to destroy the context. If name is empty destroys the current context.- Specified by:
destroySubcontext
in interfaceContext
- Parameters:
name
- string- Throws:
OperationNotSupportedException
- when list is invoked with a non-null argumentNamingException
-
destroySubcontext
Uses the callDestroy function to destroy the context. Destroys the current context if name is empty.- Specified by:
destroySubcontext
in interfaceContext
- Parameters:
name
- JNDI Name- Throws:
OperationNotSupportedException
- when list is invoked with a non-null argumentNamingException
-
callBindNewContext
Calls the bind_new_context COS naming api to create a new subcontext.- Parameters:
path
- NameComponent[] object- Returns:
- the new context object.
- Throws:
NotFound
- No objects under the name.CannotProceed
- Unable to obtain a continuation contextInvalidName
- Name not understood.AlreadyBound
- An object is already bound to this name.NamingException
-
createSubcontext
Uses the callBindNewContext convenience function to create a new context. Throws an invalid name exception if the name is empty.- Specified by:
createSubcontext
in interfaceContext
- Parameters:
name
- string- Returns:
- the new context object.
- Throws:
NamingException
- See callBindNewContext
-
createSubcontext
Uses the callBindNewContext convenience function to create a new context. Throws an invalid name exception if the name is empty.- Specified by:
createSubcontext
in interfaceContext
- Parameters:
name
- string- Returns:
- the new context object.
- Throws:
NamingException
- See callBindNewContext
-
lookupLink
Is mapped to resolve in the COS Naming api.- Specified by:
lookupLink
in interfaceContext
- Parameters:
name
- string- Returns:
- the resolved object.
- Throws:
NamingException
- See lookup.
-
lookupLink
Is mapped to resolve in the COS Naming api.- Specified by:
lookupLink
in interfaceContext
- Parameters:
name
- string- Returns:
- the resolved object.
- Throws:
NamingException
- See lookup.
-
getNameParser
Allow access to the name parser object.- Specified by:
getNameParser
in interfaceContext
- Parameters:
name
- JNDI name, is ignored since there is only one Name Parser object.- Returns:
- NameParser object
- Throws:
NamingException
- --
-
getNameParser
Allow access to the name parser object.- Specified by:
getNameParser
in interfaceContext
- Parameters:
name
- JNDI name, is ignored since there is only one Name Parser object.- Returns:
- NameParser object
- Throws:
NamingException
- --
-
getEnvironment
Returns the current environment.- Specified by:
getEnvironment
in interfaceContext
- Returns:
- Environment.
- Throws:
NamingException
-
composeName
- Specified by:
composeName
in interfaceContext
- Throws:
NamingException
-
composeName
- Specified by:
composeName
in interfaceContext
- Throws:
NamingException
-
addToEnvironment
Adds to the environment for the current context. Record change but do not reinitialize ORB.- Specified by:
addToEnvironment
in interfaceContext
- Parameters:
propName
- The property name.propValue
- The ORB.- Returns:
- the previous value of this property if any.
- Throws:
NamingException
-
removeFromEnvironment
- Specified by:
removeFromEnvironment
in interfaceContext
- Throws:
NamingException
-
incEnumCount
public void incEnumCount() -
decEnumCount
- Throws:
NamingException
-
close
- Specified by:
close
in interfaceContext
- Throws:
NamingException
-
finalize
protected void finalize()
-