public class InitialContext extends Object implements Context
| Modifier and Type | Field and Description |
|---|---|
protected Context |
defaultInitCtx
Contains the default initial context.
|
protected boolean |
gotDefault
Indicates if the initial context was obtained by calling
NamingManager.getInitialContext(java.util.Hashtable<?, ?>). |
protected Hashtable<Object,Object> |
myProps
The environment, associated with this initial 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| Modifier | Constructor and Description |
|---|---|
|
InitialContext()
Creates teh new initial context with no properties.
|
protected |
InitialContext(boolean lazy)
Creates the initial context with the possibility to delay its
initialisation.
|
|
InitialContext(Hashtable<?,?> environment)
Creates the new initial context with the given properties.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
addToEnvironment(String propName,
Object propVal)
Add new environment property to the environment of this context.
|
void |
bind(Name name,
Object obj)
Give the specified name for the specified object.
|
void |
bind(String name,
Object obj)
Give the specified name for the specified object.
|
void |
close()
Releases all resources, associated with this context.
|
Name |
composeName(Name name,
Name prefix)
Composes the name of this context together with another name, related to
this context.
|
String |
composeName(String name,
String prefix)
Composes the name of this context together with another name, related to
this context.
|
Context |
createSubcontext(Name name)
Creates the new naming subcontext and binds it to the current (this)
context.
|
Context |
createSubcontext(String name)
Creates the new naming subcontext and binds it to the current (this)
context.
|
void |
destroySubcontext(Name name)
Removes the naming subcontext from this naming context.
|
void |
destroySubcontext(String name)
Removes the naming subcontext from this naming context.
|
protected Context |
getDefaultInitCtx()
Get the default initial context.
|
Hashtable<?,?> |
getEnvironment()
Returns the environment, associated with this naming context.
|
String |
getNameInNamespace()
This operation is not supported for the initial naming context.
|
NameParser |
getNameParser(Name name)
Obtains the name parser for parsing the names of the given naming
subcontext.
|
NameParser |
getNameParser(String name)
Obtains the name parser for parsing the names of the given naming
subcontext.
|
protected Context |
getURLOrDefaultInitCtx(Name name)
Obtains the context for resolving the given name.
|
protected Context |
getURLOrDefaultInitCtx(String name)
Obtains the context for resolving the given name.
|
protected void |
init(Hashtable<?,?> environment)
Initialises the context, using the properties, specified in the passed
table.
|
NamingEnumeration<NameClassPair> |
list(Name name)
Creates and returns the enumeration over the name bindings that are present
the given subcontext.
|
NamingEnumeration<NameClassPair> |
list(String name)
Creates and returns the enumeration over the name bindings that are present
the given subcontext.
|
NamingEnumeration<Binding> |
listBindings(Name name)
Creates and returns the enumeration over the name - object bindings that
are present the given subcontext.
|
NamingEnumeration<Binding> |
listBindings(String name)
Creates and returns the enumeration over the name - object bindings that
are present the given subcontext.
|
Object |
lookup(Name name)
Gets the previously named object by name.
|
Object |
lookup(String name)
Gets the previously named object by name.
|
Object |
lookupLink(Name name)
Retrieves the named object, not following the link of the terminal atomic
component of the name.
|
Object |
lookupLink(String name)
Retrieves the named object, not following the link of the terminal atomic
component of the name.
|
void |
rebind(Name name,
Object obj)
Give the specified name for the specified object.
|
void |
rebind(String name,
Object obj)
Give the specified name for the specified object.
|
Object |
removeFromEnvironment(String propName)
Removes the property with the given name from the environment.
|
void |
rename(Name oldName,
Name newName)
Renames the existing binding, removing the existing and giving the new name
for the same object.
|
void |
rename(String oldName,
String newName)
Renames the existing binding, removing the existing and giving the new name
for the same object.
|
void |
unbind(Name name)
Removes the name - object mapping from the current context.
|
void |
unbind(String name)
Removes the name - object mapping from the current context.
|
protected Context defaultInitCtx
NamingManager.getInitialContext(java.util.Hashtable<?, ?>). It is set by this method
when calling it first time. The subsequent calls return the value of
this field.protected boolean gotDefault
NamingManager.getInitialContext(java.util.Hashtable<?, ?>).public InitialContext(Hashtable<?,?> environment) throws NamingException
environment - the properties, used by the initial context being
created.NamingExceptionprotected InitialContext(boolean lazy) throws NamingException
lazy - specified if the initialization should not be performed by this
constructor (true). If the valueis false, it works the same way as
the parameterless constructor.NamingExceptionpublic InitialContext() throws NamingException
NamingExceptionprotected void init(Hashtable<?,?> environment) throws NamingException
Initialises the context, using the properties, specified in the passed table.
The missing properties are additionally obtained (in order) from the following locations:Applet. Then the properties are
requested via Applet.getParameter(String).environment - the table of the properties, may be null. The method
modifies the table and stores the reference to it. The caller must
not later reuse this structure for other purposes.NamingExceptionprotected Context getDefaultInitCtx() throws NamingException
gotDefault == false, this
method obtains the initial context from the naming manager and sets
gotDefault to true. Otherwise the cached value (defaultInitCtx is
returned.NamingExceptionprotected Context getURLOrDefaultInitCtx(Name name) throws NamingException
name - the name, for that it is required to obtain the context.NamingExceptionprotected Context getURLOrDefaultInitCtx(String name) throws NamingException
name - the name, for that it is required to obtain the context.NamingExceptionpublic void bind(Name name, Object obj) throws NamingException
Contextbind in interface Contextname - the name that will be given to the object (in the scope of this
context).obj - the object being named.NameAlreadyBoundException - if this name is already used to name some
object.InvalidAttributesException - if the object does not supply all
required attributes.NamingException - if the naming operation has failed due other
reasons.public void bind(String name, Object obj) throws NamingException
Contextbind in interface Contextname - the name that will be given to the object (in the scope of this
context).obj - the object being named.NameAlreadyBoundException - if this name is already used to name some
object.InvalidAttributesException - if the object does not supply all
required attributes.NamingException - if the naming operation has failed due other
reasons.public Object lookup(Name name) throws NamingException
Contextlookup in interface Contextname - the name of the object being searched in this contextNamingException - if the naming fails.public Object lookup(String name) throws NamingException
Contextlookup in interface Contextname - the name of the object being searched in this contextNamingException - if the naming fails.public void rebind(Name name, Object obj) throws NamingException
Contextrebind in interface Contextname - the name that will be given to the object (in the scope of this
context).obj - the object being named.InvalidAttributesException - if the object does not supply all
required attributes.NamingException - if the naming operation has failed due other
reasons.public void rebind(String name, Object obj) throws NamingException
Contextrebind in interface Contextname - the name that will be given to the object (in the scope of this
context).obj - the object being named.InvalidAttributesException - if the object does not supply all
required attributes.NamingException - if the naming operation has failed due other
reasons.public void unbind(Name name) throws NamingException
ContextNameNotFoundException if one of the
intermadiate contexts does not exist.unbind in interface Contextname - the name to be removedNameNotFoundException - if one of the intermediate naming contexts
does not exist. Will not be thrown if just the terminal binding
is missing.NamingException - if the naming operation has failed due other
reasons.public void unbind(String name) throws NamingException
ContextNameNotFoundException if one of the
intermadiate contexts does not exist.unbind in interface Contextname - the name to be removedNameNotFoundException - if one of the intermediate naming contexts
does not exist. Will not be thrown if just the terminal binding
is missing.NamingException - if the naming operation has failed due other
reasons.public void rename(Name oldName, Name newName) throws NamingException
Contextrename in interface ContextoldName - the existing name of the known objectnewName - the new name of the same objectNameNotFoundException - if the oldName is unknown for this contextNamingException - if the naming operation has failed due other
reasons.public void rename(String oldName, String newName) throws NamingException
Contextrename in interface ContextoldName - the existing name of the known objectnewName - the new name of the same objectNameNotFoundException - if the oldName is unknown for this contextNamingException - if the naming operation has failed due other
reasons.public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
ContextNameClassPair, providing also information about the class of the
bound object. The behaviour in the case if the bindings are added or
removed later is not defined. The contents of the subcontexts are not
included.list in interface Contextname - the name of the subcontextNamingExceptionpublic NamingEnumeration<NameClassPair> list(String name) throws NamingException
ContextNameClassPair, providing also information about the class of the
bound object. The behaviour in the case if the bindings are added or
removed later is not defined. The contents of the subcontexts are not
included.list in interface Contextname - the name of the subcontextNamingExceptionpublic NamingEnumeration<Binding> listBindings(Name name) throws NamingException
ContextBinding, providing also information about the class of the bound
object. The behaviour in the case if the bindings are added or removed
later is not defined. The contents of the subcontexts are not included.listBindings in interface Contextname - the name of the subcontextNamingExceptionpublic NamingEnumeration<Binding> listBindings(String name) throws NamingException
ContextBinding, providing also information about the class of the bound
object. The behaviour in the case if the bindings are added or removed
later is not defined. The contents of the subcontexts are not included.listBindings in interface Contextname - the name of the subcontextNamingExceptionpublic void destroySubcontext(Name name) throws NamingException
ContextdestroySubcontext in interface Contextname - the name of the subcontext beig removed.ContextNotEmptyException - if the named context is not empty.NamingExceptionpublic void destroySubcontext(String name) throws NamingException
ContextdestroySubcontext in interface Contextname - the name of the subcontext beig removed.ContextNotEmptyException - if the named context is not empty.NamingExceptionpublic Context createSubcontext(Name name) throws NamingException
ContextcreateSubcontext in interface Contextname - the name of the new context being createdNameAlreadyBoundException - if this name is already boundInvalidAttributesException - if the creation of the new context
requires the missing mandatory attributesNamingExceptionpublic Context createSubcontext(String name) throws NamingException
ContextcreateSubcontext in interface Contextname - the name of the new context being createdNameAlreadyBoundException - if this name is already boundInvalidAttributesException - if the creation of the new context
requires the missing mandatory attributesNamingExceptionpublic Object lookupLink(Name name) throws NamingException
ContextlookupLink in interface Contextname - the name of the object that may be a link, leading to another
object.NamingExceptionpublic Object lookupLink(String name) throws NamingException
ContextlookupLink in interface Contextname - the name of the object that may be a link, leading to another
object.NamingExceptionpublic NameParser getNameParser(Name name) throws NamingException
ContextgetNameParser in interface Contextname - the name of the subcontext for that the parser must be obtainedNamingExceptionpublic NameParser getNameParser(String name) throws NamingException
ContextgetNameParser in interface Contextname - the name of the subcontext for that the parser must be obtainedNamingExceptionpublic Name composeName(Name name, Name prefix) throws NamingException
ContextcomposeName in interface Contextname - a name, defined in the scope of this contextprefix - a name of this context itself, defined in the scope of some
ancestorNamingExceptionpublic String composeName(String name, String prefix) throws NamingException
ContextcomposeName in interface Contextname - a name, defined in the scope of this contextprefix - a name of this context itself, defined in the scope of some
ancestorNamingExceptionpublic Object addToEnvironment(String propName, Object propVal) throws NamingException
ContextaddToEnvironment in interface ContextpropName - the name of the new propertypropVal - the value of the new propertyNamingExceptionpublic Object removeFromEnvironment(String propName) throws NamingException
ContextremoveFromEnvironment in interface ContextpropName - the name of the property being removed.NamingExceptionpublic Hashtable<?,?> getEnvironment() throws NamingException
ContextContext.addToEnvironment(java.lang.String, java.lang.Object)
and Context.removeFromEnvironment(java.lang.String) to modify the environement, if needed.getEnvironment in interface ContextNamingExceptionpublic void close() throws NamingException
Contextclose in interface ContextNamingExceptionpublic String getNameInNamespace() throws NamingException
getNameInNamespace in interface ContextOperationNotSupportedException - always, unless the method is
overridden in the derived class.NamingException