public class ContextImpl
extends java.lang.Object
implements javax.naming.Context
Context
. The actual storage
of the persistent data is in the AbstractModel
.
The ContextImpl
is just a Visitor around
the AbstractModel
which also encapsulate
the JNDI environment.
In JNDI, each Context
is a <model, env> pair.
Each client might pass a different environment
to the InitialContext
so each ContextImpl
must be unique for each client. (Granted, this is a bit wasteful of
space which is why JNDI values should be cached.)
Applications which want a different model can still use
ContextImpl
and specify the root
object for AbstractModel
. ContextImpl
will
take care of the JNDI API for the model.
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable<java.lang.String,java.lang.Object> |
_env |
protected AbstractModel |
_model |
protected java.lang.String |
_name |
protected static L10N |
L |
protected static java.util.logging.Logger |
log |
Constructor and Description |
---|
ContextImpl(AbstractModel model,
java.util.Hashtable<java.lang.String,java.lang.Object> env)
Creates a
ContextImpl . |
ContextImpl(java.lang.String name,
AbstractModel model,
java.util.Hashtable<java.lang.String,java.lang.Object> env)
Creates a
ContextImpl . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
addToEnvironment(java.lang.String prop,
java.lang.Object value)
Adds a property to the context environment.
|
void |
bind(javax.naming.Name name,
java.lang.Object obj)
Binds an object to the context.
|
void |
bind(java.lang.String name,
java.lang.Object obj)
Binds an object to the context.
|
void |
close()
Close is intended to free any transient data, like a cached
socket.
|
javax.naming.Name |
composeName(javax.naming.Name suffix,
javax.naming.Name prefix) |
java.lang.String |
composeName(java.lang.String suffix,
java.lang.String prefix) |
protected ContextImpl |
create(AbstractModel model,
java.util.Hashtable<java.lang.String,java.lang.Object> env)
Creates a new
ContextImpl when the name is irrelevant. |
protected ContextImpl |
create(java.lang.String name,
AbstractModel model,
java.util.Hashtable<java.lang.String,java.lang.Object> env)
Creates a new instance of the
ContextImpl . |
protected javax.naming.Context |
createSingleSubcontext(java.lang.String name) |
javax.naming.Context |
createSubcontext(javax.naming.Name name) |
javax.naming.Context |
createSubcontext(java.lang.String name)
Creates a subcontext for the current model.
|
protected void |
destroySingleSubcontext(java.lang.String name) |
void |
destroySubcontext(javax.naming.Name name) |
void |
destroySubcontext(java.lang.String name)
Destroys the named subcontext.
|
java.util.Hashtable |
getEnvironment()
Returns the context environment.
|
protected java.lang.String |
getFullPath(javax.naming.Name name)
Returns the full name for the context.
|
protected java.lang.String |
getFullPath(java.lang.String name)
Returns the full name for the context.
|
AbstractModel |
getModel()
Returns the underlying storage node.
|
java.lang.String |
getName()
Returns the name.
|
java.lang.String |
getNameInNamespace() |
javax.naming.NameParser |
getNameParser(javax.naming.Name name) |
javax.naming.NameParser |
getNameParser(java.lang.String name) |
protected char |
getSeparator() |
protected java.lang.String |
getSeparatorString() |
javax.naming.NamingEnumeration |
list(javax.naming.Name name)
Lists the names for the context.
|
javax.naming.NamingEnumeration |
list(java.lang.String name)
List the names for a context.
|
javax.naming.NamingEnumeration |
listBindings(javax.naming.Name name)
Lists the bindings for the given name.
|
javax.naming.NamingEnumeration |
listBindings(java.lang.String name)
List the bindings for a context.
|
protected java.util.Iterator |
listSingle() |
java.lang.Object |
lookup(javax.naming.Name name)
Looks up an object with the given parsed JNDI name.
|
java.lang.Object |
lookup(java.lang.String name)
Looks up an object using its full string name.
|
protected java.lang.Object |
lookupImpl(java.lang.String name)
Looks up an object using its full string name.
|
java.lang.Object |
lookupLink(javax.naming.Name name)
Looks up an object with the given parsed JNDI name, but don't
dereference the final object.
|
java.lang.Object |
lookupLink(java.lang.String name)
Looks up an object given the name, but doesn't dereference links.
|
protected java.lang.Object |
lookupSingle(java.lang.String name)
Returns the object named by the single name segment.
|
protected java.lang.String |
parseFirst(java.lang.String name) |
protected java.lang.String |
parseRest(java.lang.String name) |
void |
rebind(javax.naming.Name name,
java.lang.Object obj) |
void |
rebind(java.lang.String name,
java.lang.Object obj)
Binds an object to the context, overriding any old value.
|
protected void |
rebindSingle(java.lang.String name,
java.lang.Object obj) |
java.lang.Object |
removeFromEnvironment(java.lang.String prop)
Removes a property from the context environment.
|
void |
rename(javax.naming.Name oldName,
javax.naming.Name newName) |
void |
rename(java.lang.String oldName,
java.lang.String newName) |
java.lang.String |
toString()
Returns a string value.
|
void |
unbind(javax.naming.Name name) |
void |
unbind(java.lang.String name)
Unbinds an object from the context.
|
protected void |
unbindSingle(java.lang.String name) |
protected static final java.util.logging.Logger log
protected static final L10N L
protected java.util.Hashtable<java.lang.String,java.lang.Object> _env
protected AbstractModel _model
protected java.lang.String _name
public ContextImpl(AbstractModel model, java.util.Hashtable<java.lang.String,java.lang.Object> env)
ContextImpl
.model
- The underlying storage node.env
- The client's JNDI environment.public ContextImpl(java.lang.String name, AbstractModel model, java.util.Hashtable<java.lang.String,java.lang.Object> env)
ContextImpl
.name
- JNDI name, used for error messages, etc.model
- The underlying storage node.env
- The client's JNDI environment.protected ContextImpl create(java.lang.String name, AbstractModel model, java.util.Hashtable<java.lang.String,java.lang.Object> env)
ContextImpl
. Subclasses will
override this method to return a new instance of the subclass.name
- the JNDI name for the new contextmodel
- the underlying storage nodeenv
- the client's JNDI environment.protected final ContextImpl create(AbstractModel model, java.util.Hashtable<java.lang.String,java.lang.Object> env)
ContextImpl
when the name is irrelevant.model
- the underlying storage nodeenv
- the client's JNDI environment.public AbstractModel getModel()
public java.lang.String getName()
public java.lang.Object lookup(java.lang.String name) throws javax.naming.NamingException
parseFirst
returns the first segment. Thelookup
in interface javax.naming.Context
name
- the JNDI name to lookup for the child.javax.naming.NamingException
protected java.lang.Object lookupImpl(java.lang.String name) throws javax.naming.NamingException
parseFirst
returns the first segment. Thename
- the JNDI name to lookup for the child.javax.naming.NamingException
public java.lang.Object lookup(javax.naming.Name name) throws javax.naming.NamingException
lookup
in interface javax.naming.Context
javax.naming.NamingException
public java.lang.Object lookupLink(java.lang.String name) throws javax.naming.NamingException
lookupLink
in interface javax.naming.Context
javax.naming.NamingException
public java.lang.Object lookupLink(javax.naming.Name name) throws javax.naming.NamingException
lookupLink
in interface javax.naming.Context
javax.naming.NamingException
public void bind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
bind
in interface javax.naming.Context
javax.naming.NamingException
public void bind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException
bind
in interface javax.naming.Context
javax.naming.NamingException
public void rebind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
rebind
in interface javax.naming.Context
name
- the name to bindobj
- the object to bindjavax.naming.NamingException
public void rebind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException
rebind
in interface javax.naming.Context
javax.naming.NamingException
public void unbind(java.lang.String name) throws javax.naming.NamingException
unbind
in interface javax.naming.Context
name
- the name to unbindjavax.naming.NamingException
public void unbind(javax.naming.Name name) throws javax.naming.NamingException
unbind
in interface javax.naming.Context
javax.naming.NamingException
public void rename(java.lang.String oldName, java.lang.String newName) throws javax.naming.NamingException
rename
in interface javax.naming.Context
javax.naming.NamingException
public void rename(javax.naming.Name oldName, javax.naming.Name newName) throws javax.naming.NamingException
rename
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.NamingEnumeration list(java.lang.String name) throws javax.naming.NamingException
list
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.NamingEnumeration list(javax.naming.Name name) throws javax.naming.NamingException
list
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.NamingEnumeration listBindings(java.lang.String name) throws javax.naming.NamingException
listBindings
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.NamingEnumeration listBindings(javax.naming.Name name) throws javax.naming.NamingException
listBindings
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.Context createSubcontext(java.lang.String name) throws javax.naming.NamingException
createSubcontext
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.Context createSubcontext(javax.naming.Name name) throws javax.naming.NamingException
createSubcontext
in interface javax.naming.Context
javax.naming.NamingException
public void destroySubcontext(java.lang.String name) throws javax.naming.NamingException
destroySubcontext
in interface javax.naming.Context
javax.naming.NamingException
public void destroySubcontext(javax.naming.Name name) throws javax.naming.NamingException
destroySubcontext
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.NameParser getNameParser(java.lang.String name) throws javax.naming.NamingException
getNameParser
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.NameParser getNameParser(javax.naming.Name name) throws javax.naming.NamingException
getNameParser
in interface javax.naming.Context
javax.naming.NamingException
public java.lang.String composeName(java.lang.String suffix, java.lang.String prefix) throws javax.naming.NamingException
composeName
in interface javax.naming.Context
javax.naming.NamingException
public javax.naming.Name composeName(javax.naming.Name suffix, javax.naming.Name prefix) throws javax.naming.NamingException
composeName
in interface javax.naming.Context
javax.naming.NamingException
public java.lang.String getNameInNamespace() throws javax.naming.NamingException
getNameInNamespace
in interface javax.naming.Context
javax.naming.NamingException
protected java.lang.Object lookupSingle(java.lang.String name) throws javax.naming.NamingException
name
- the name segment.javax.naming.NamingException
protected void rebindSingle(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
javax.naming.NamingException
protected void unbindSingle(java.lang.String name) throws javax.naming.NamingException
javax.naming.NamingException
protected javax.naming.Context createSingleSubcontext(java.lang.String name) throws javax.naming.NamingException
javax.naming.NamingException
protected void destroySingleSubcontext(java.lang.String name) throws javax.naming.NamingException
javax.naming.NamingException
protected java.util.Iterator listSingle()
protected java.lang.String parseFirst(java.lang.String name) throws javax.naming.NamingException
javax.naming.NamingException
protected java.lang.String parseRest(java.lang.String name) throws javax.naming.NamingException
javax.naming.NamingException
protected char getSeparator()
protected java.lang.String getSeparatorString()
protected java.lang.String getFullPath(java.lang.String name)
protected java.lang.String getFullPath(javax.naming.Name name)
public java.lang.Object addToEnvironment(java.lang.String prop, java.lang.Object value) throws javax.naming.NamingException
addToEnvironment
in interface javax.naming.Context
javax.naming.NamingException
public java.lang.Object removeFromEnvironment(java.lang.String prop) throws javax.naming.NamingException
removeFromEnvironment
in interface javax.naming.Context
javax.naming.NamingException
public java.util.Hashtable getEnvironment() throws javax.naming.NamingException
getEnvironment
in interface javax.naming.Context
javax.naming.NamingException
public void close() throws javax.naming.NamingException
close
in interface javax.naming.Context
javax.naming.NamingException
public java.lang.String toString()
toString
in class java.lang.Object