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.NamingException
protected 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.NamingException
public InitialContext() throws NamingException
NamingException
protected 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.NamingException
protected 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.NamingException
protected Context getURLOrDefaultInitCtx(Name name) throws NamingException
name
- the name, for that it is required to obtain the context.NamingException
protected Context getURLOrDefaultInitCtx(String name) throws NamingException
name
- the name, for that it is required to obtain the context.NamingException
public void bind(Name name, Object obj) throws NamingException
Context
bind
in interface Context
name
- 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
Context
bind
in interface Context
name
- 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
Context
lookup
in interface Context
name
- the name of the object being searched in this contextNamingException
- if the naming fails.public Object lookup(String name) throws NamingException
Context
lookup
in interface Context
name
- the name of the object being searched in this contextNamingException
- if the naming fails.public void rebind(Name name, Object obj) throws NamingException
Context
rebind
in interface Context
name
- 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
Context
rebind
in interface Context
name
- 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
Context
NameNotFoundException
if one of the
intermadiate contexts does not exist.unbind
in interface Context
name
- 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
Context
NameNotFoundException
if one of the
intermadiate contexts does not exist.unbind
in interface Context
name
- 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
Context
rename
in interface Context
oldName
- 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
Context
rename
in interface Context
oldName
- 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
Context
NameClassPair
, 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 Context
name
- the name of the subcontextNamingException
public NamingEnumeration<NameClassPair> list(String name) throws NamingException
Context
NameClassPair
, 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 Context
name
- the name of the subcontextNamingException
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
Context
Binding
, 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 Context
name
- the name of the subcontextNamingException
public NamingEnumeration<Binding> listBindings(String name) throws NamingException
Context
Binding
, 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 Context
name
- the name of the subcontextNamingException
public void destroySubcontext(Name name) throws NamingException
Context
destroySubcontext
in interface Context
name
- the name of the subcontext beig removed.ContextNotEmptyException
- if the named context is not empty.NamingException
public void destroySubcontext(String name) throws NamingException
Context
destroySubcontext
in interface Context
name
- the name of the subcontext beig removed.ContextNotEmptyException
- if the named context is not empty.NamingException
public Context createSubcontext(Name name) throws NamingException
Context
createSubcontext
in interface Context
name
- 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 attributesNamingException
public Context createSubcontext(String name) throws NamingException
Context
createSubcontext
in interface Context
name
- 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 attributesNamingException
public Object lookupLink(Name name) throws NamingException
Context
lookupLink
in interface Context
name
- the name of the object that may be a link, leading to another
object.NamingException
public Object lookupLink(String name) throws NamingException
Context
lookupLink
in interface Context
name
- the name of the object that may be a link, leading to another
object.NamingException
public NameParser getNameParser(Name name) throws NamingException
Context
getNameParser
in interface Context
name
- the name of the subcontext for that the parser must be obtainedNamingException
public NameParser getNameParser(String name) throws NamingException
Context
getNameParser
in interface Context
name
- the name of the subcontext for that the parser must be obtainedNamingException
public Name composeName(Name name, Name prefix) throws NamingException
Context
composeName
in interface Context
name
- a name, defined in the scope of this contextprefix
- a name of this context itself, defined in the scope of some
ancestorNamingException
public String composeName(String name, String prefix) throws NamingException
Context
composeName
in interface Context
name
- a name, defined in the scope of this contextprefix
- a name of this context itself, defined in the scope of some
ancestorNamingException
public Object addToEnvironment(String propName, Object propVal) throws NamingException
Context
addToEnvironment
in interface Context
propName
- the name of the new propertypropVal
- the value of the new propertyNamingException
public Object removeFromEnvironment(String propName) throws NamingException
Context
removeFromEnvironment
in interface Context
propName
- the name of the property being removed.NamingException
public Hashtable<?,?> getEnvironment() throws NamingException
Context
Context.addToEnvironment(java.lang.String, java.lang.Object)
and Context.removeFromEnvironment(java.lang.String)
to modify the environement, if needed.getEnvironment
in interface Context
NamingException
public void close() throws NamingException
Context
close
in interface Context
NamingException
public String getNameInNamespace() throws NamingException
getNameInNamespace
in interface Context
OperationNotSupportedException
- always, unless the method is
overridden in the derived class.NamingException