Package org.eclipse.jetty.jndi
Class NamingContext
- java.lang.Object
-
- org.eclipse.jetty.jndi.NamingContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NamingContext.Listener
Naming Context Listener.-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ConcurrentMap<java.lang.String,javax.naming.Binding>
_bindings
protected java.util.Hashtable<java.lang.String,java.lang.Object>
_env
protected java.lang.String
_name
protected NamingContext
_parent
protected javax.naming.NameParser
_parser
static java.lang.String
DEEP_BINDING
static java.lang.String
LOCK_PROPERTY
static java.lang.String
UNLOCK_PROPERTY
-
Constructor Summary
Constructors Modifier Constructor Description NamingContext(java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String name, NamingContext parent, javax.naming.NameParser parser)
Constructorprotected
NamingContext(java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String name, NamingContext parent, javax.naming.NameParser parser, java.util.concurrent.ConcurrentMap<java.lang.String,javax.naming.Binding> bindings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBinding(javax.naming.Name name, java.lang.Object obj)
Add a name to object binding to this Context.void
addListener(NamingContext.Listener listener)
java.lang.Object
addToEnvironment(java.lang.String propName, java.lang.Object propVal)
Add an environment setting to this Contextvoid
bind(java.lang.String name, java.lang.Object obj)
Bind a name (as a String) to an objectvoid
bind(javax.naming.Name name, java.lang.Object obj)
Bind a name to an objectvoid
close()
Do nothingjava.lang.String
composeName(java.lang.String name, java.lang.String prefix)
Join two names together.javax.naming.Name
composeName(javax.naming.Name name, javax.naming.Name prefix)
Join two names together.javax.naming.Context
createSubcontext(java.lang.String name)
Create a Context as a child of this onejavax.naming.Context
createSubcontext(javax.naming.Name name)
Create a context as a child of this onevoid
destroySubcontext(java.lang.String name)
void
destroySubcontext(javax.naming.Name name)
java.lang.String
dump()
void
dump(java.lang.Appendable out, java.lang.String indent)
Dump this object (and children) into an Appendable using the provided indent after any new lines.javax.naming.Binding
getBinding(java.lang.String name)
Get a name to object binding from this Contextjavax.naming.Binding
getBinding(javax.naming.Name name)
Get a name to object binding from this Contextjava.util.Hashtable
getEnvironment()
Get the environment of this Context.java.lang.String
getName()
Getter for _namejava.lang.String
getNameInNamespace()
Get the full name of this Context node by visiting it's ancestors back to root.javax.naming.NameParser
getNameParser(java.lang.String name)
Return a NameParser for this Context.javax.naming.NameParser
getNameParser(javax.naming.Name name)
Return a NameParser for this Context.javax.naming.Context
getParent()
Getter for _parentboolean
isDeepBindingSupported()
boolean
isLocked()
javax.naming.NamingEnumeration
list(java.lang.String name)
List all names bound at Context named by Namejavax.naming.NamingEnumeration
list(javax.naming.Name name)
List all names bound at Context named by Namejavax.naming.NamingEnumeration
listBindings(java.lang.String name)
List all Bindings at Namejavax.naming.NamingEnumeration
listBindings(javax.naming.Name name)
List all Bindings present at Context named by Namejava.lang.Object
lookup(java.lang.String name)
Lookup binding of an object by namejava.lang.Object
lookup(javax.naming.Name name)
Lookup a binding by namejava.lang.Object
lookupLink(java.lang.String name)
Lookup link bound to namejava.lang.Object
lookupLink(javax.naming.Name name)
Lookup link bound to namevoid
rebind(java.lang.String name, java.lang.Object obj)
Overwrite or create a binding from Name to Objectvoid
rebind(javax.naming.Name name, java.lang.Object obj)
Overwrite or create a bindingvoid
removeBinding(javax.naming.Name name)
java.lang.Object
removeFromEnvironment(java.lang.String propName)
Remove a property from this Context's environment.boolean
removeListener(NamingContext.Listener listener)
void
rename(java.lang.String oldName, java.lang.String newName)
Not supportedvoid
rename(javax.naming.Name oldName, javax.naming.Name newName)
Not supportedvoid
setEnv(java.util.Hashtable<java.lang.String,java.lang.Object> env)
void
setNameParser(javax.naming.NameParser parser)
javax.naming.Context
shallowCopy(java.util.Hashtable<java.lang.String,java.lang.Object> env)
javax.naming.Name
toCanonicalName(javax.naming.Name name)
Remove leading or trailing empty components from name.java.lang.String
toString()
void
unbind(java.lang.String name)
Not supported.void
unbind(javax.naming.Name name)
Not supported.
-
-
-
Field Detail
-
DEEP_BINDING
public static final java.lang.String DEEP_BINDING
- See Also:
- Constant Field Values
-
LOCK_PROPERTY
public static final java.lang.String LOCK_PROPERTY
- See Also:
- Constant Field Values
-
UNLOCK_PROPERTY
public static final java.lang.String UNLOCK_PROPERTY
- See Also:
- Constant Field Values
-
_env
protected final java.util.Hashtable<java.lang.String,java.lang.Object> _env
-
_bindings
protected final java.util.concurrent.ConcurrentMap<java.lang.String,javax.naming.Binding> _bindings
-
_parent
protected NamingContext _parent
-
_name
protected java.lang.String _name
-
_parser
protected javax.naming.NameParser _parser
-
-
Constructor Detail
-
NamingContext
public NamingContext(java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String name, NamingContext parent, javax.naming.NameParser parser)
Constructor- Parameters:
env
- environment properties which are copied into this Context's environmentname
- relative name of this contextparent
- immediate ancestor Context (can be null)parser
- NameParser for this Context
-
NamingContext
protected NamingContext(java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String name, NamingContext parent, javax.naming.NameParser parser, java.util.concurrent.ConcurrentMap<java.lang.String,javax.naming.Binding> bindings)
-
-
Method Detail
-
shallowCopy
public javax.naming.Context shallowCopy(java.util.Hashtable<java.lang.String,java.lang.Object> env)
- Returns:
- A shallow copy of the Context with the same bindings, but with the passed environment
-
isDeepBindingSupported
public boolean isDeepBindingSupported()
-
getName
public java.lang.String getName()
Getter for _name- Returns:
- name of this Context (relative, not absolute)
-
getParent
public javax.naming.Context getParent()
Getter for _parent- Returns:
- parent Context
-
setNameParser
public void setNameParser(javax.naming.NameParser parser)
-
setEnv
public final void setEnv(java.util.Hashtable<java.lang.String,java.lang.Object> env)
-
bind
public void bind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException
Bind a name to an object- Specified by:
bind
in interfacejavax.naming.Context
- Parameters:
name
- Name of the objectobj
- object to bind- Throws:
javax.naming.NamingException
- if an error occurs
-
bind
public void bind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
Bind a name (as a String) to an object- Specified by:
bind
in interfacejavax.naming.Context
- Parameters:
name
- aString
valueobj
- anObject
value- Throws:
javax.naming.NamingException
- if an error occurs
-
createSubcontext
public javax.naming.Context createSubcontext(javax.naming.Name name) throws javax.naming.NamingException
Create a context as a child of this one- Specified by:
createSubcontext
in interfacejavax.naming.Context
- Parameters:
name
- aName
value- Returns:
- a
Context
value - Throws:
javax.naming.NamingException
- if an error occurs
-
createSubcontext
public javax.naming.Context createSubcontext(java.lang.String name) throws javax.naming.NamingException
Create a Context as a child of this one- Specified by:
createSubcontext
in interfacejavax.naming.Context
- Parameters:
name
- aString
value- Returns:
- a
Context
value - Throws:
javax.naming.NamingException
- if an error occurs
-
destroySubcontext
public void destroySubcontext(java.lang.String name) throws javax.naming.NamingException
- Specified by:
destroySubcontext
in interfacejavax.naming.Context
- Parameters:
name
- name of subcontext to remove- Throws:
javax.naming.NamingException
- if an error occurs
-
destroySubcontext
public void destroySubcontext(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
destroySubcontext
in interfacejavax.naming.Context
- Parameters:
name
- name of subcontext to remove- Throws:
javax.naming.NamingException
- if an error occurs
-
lookup
public java.lang.Object lookup(javax.naming.Name name) throws javax.naming.NamingException
Lookup a binding by name- Specified by:
lookup
in interfacejavax.naming.Context
- Parameters:
name
- name of bound object- Throws:
javax.naming.NamingException
- if an error occurs
-
lookup
public java.lang.Object lookup(java.lang.String name) throws javax.naming.NamingException
Lookup binding of an object by name- Specified by:
lookup
in interfacejavax.naming.Context
- Parameters:
name
- name of bound object- Returns:
- object bound to name
- Throws:
javax.naming.NamingException
- if an error occurs
-
lookupLink
public java.lang.Object lookupLink(javax.naming.Name name) throws javax.naming.NamingException
Lookup link bound to name- Specified by:
lookupLink
in interfacejavax.naming.Context
- Parameters:
name
- name of link binding- Returns:
- LinkRef or plain object bound at name
- Throws:
javax.naming.NamingException
- if an error occurs
-
lookupLink
public java.lang.Object lookupLink(java.lang.String name) throws javax.naming.NamingException
Lookup link bound to name- Specified by:
lookupLink
in interfacejavax.naming.Context
- Parameters:
name
- name of link binding- Returns:
- LinkRef or plain object bound at name
- Throws:
javax.naming.NamingException
- if an error occurs
-
list
public javax.naming.NamingEnumeration list(javax.naming.Name name) throws javax.naming.NamingException
List all names bound at Context named by Name- Specified by:
list
in interfacejavax.naming.Context
- Parameters:
name
- aName
value- Returns:
- a
NamingEnumeration
value - Throws:
javax.naming.NamingException
- if an error occurs
-
list
public javax.naming.NamingEnumeration list(java.lang.String name) throws javax.naming.NamingException
List all names bound at Context named by Name- Specified by:
list
in interfacejavax.naming.Context
- Parameters:
name
- aName
value- Returns:
- a
NamingEnumeration
value - Throws:
javax.naming.NamingException
- if an error occurs
-
listBindings
public javax.naming.NamingEnumeration listBindings(javax.naming.Name name) throws javax.naming.NamingException
List all Bindings present at Context named by Name- Specified by:
listBindings
in interfacejavax.naming.Context
- Parameters:
name
- aName
value- Returns:
- a
NamingEnumeration
value - Throws:
javax.naming.NamingException
- if an error occurs
-
listBindings
public javax.naming.NamingEnumeration listBindings(java.lang.String name) throws javax.naming.NamingException
List all Bindings at Name- Specified by:
listBindings
in interfacejavax.naming.Context
- Parameters:
name
- aString
value- Returns:
- a
NamingEnumeration
value - Throws:
javax.naming.NamingException
- if an error occurs
-
rebind
public void rebind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException
Overwrite or create a binding- Specified by:
rebind
in interfacejavax.naming.Context
- Parameters:
name
- aName
valueobj
- anObject
value- Throws:
javax.naming.NamingException
- if an error occurs
-
rebind
public void rebind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
Overwrite or create a binding from Name to Object- Specified by:
rebind
in interfacejavax.naming.Context
- Parameters:
name
- aString
valueobj
- anObject
value- Throws:
javax.naming.NamingException
- if an error occurs
-
unbind
public void unbind(java.lang.String name) throws javax.naming.NamingException
Not supported.- Specified by:
unbind
in interfacejavax.naming.Context
- Parameters:
name
- aString
value- Throws:
javax.naming.NamingException
- if an error occurs
-
unbind
public void unbind(javax.naming.Name name) throws javax.naming.NamingException
Not supported.- Specified by:
unbind
in interfacejavax.naming.Context
- Parameters:
name
- aString
value- Throws:
javax.naming.NamingException
- if an error occurs
-
rename
public void rename(javax.naming.Name oldName, javax.naming.Name newName) throws javax.naming.NamingException
Not supported- Specified by:
rename
in interfacejavax.naming.Context
- Parameters:
oldName
- aName
valuenewName
- aName
value- Throws:
javax.naming.NamingException
- if an error occurs
-
rename
public void rename(java.lang.String oldName, java.lang.String newName) throws javax.naming.NamingException
Not supported- Specified by:
rename
in interfacejavax.naming.Context
- Parameters:
oldName
- aName
valuenewName
- aName
value- Throws:
javax.naming.NamingException
- if an error occurs
-
composeName
public javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix) throws javax.naming.NamingException
Join two names together. These are treated as CompoundNames.- Specified by:
composeName
in interfacejavax.naming.Context
- Parameters:
name
- aName
valueprefix
- aName
value- Returns:
- a
Name
value - Throws:
javax.naming.NamingException
- if an error occurs
-
composeName
public java.lang.String composeName(java.lang.String name, java.lang.String prefix) throws javax.naming.NamingException
Join two names together. These are treated as CompoundNames.- Specified by:
composeName
in interfacejavax.naming.Context
- Parameters:
name
- aName
valueprefix
- aName
value- Returns:
- a
Name
value - Throws:
javax.naming.NamingException
- if an error occurs
-
close
public void close() throws javax.naming.NamingException
Do nothing- Specified by:
close
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
- if an error occurs
-
getNameParser
public javax.naming.NameParser getNameParser(javax.naming.Name name)
Return a NameParser for this Context.- Specified by:
getNameParser
in interfacejavax.naming.Context
- Parameters:
name
- aName
value- Returns:
- a
NameParser
value
-
getNameParser
public javax.naming.NameParser getNameParser(java.lang.String name)
Return a NameParser for this Context.- Specified by:
getNameParser
in interfacejavax.naming.Context
- Parameters:
name
- aName
value- Returns:
- a
NameParser
value
-
getNameInNamespace
public java.lang.String getNameInNamespace() throws javax.naming.NamingException
Get the full name of this Context node by visiting it's ancestors back to root. NOTE: if this Context has a URL namespace then the URL prefix will be missing- Specified by:
getNameInNamespace
in interfacejavax.naming.Context
- Returns:
- the full name of this Context
- Throws:
javax.naming.NamingException
- if an error occurs
-
addToEnvironment
public java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal) throws javax.naming.NamingException
Add an environment setting to this Context- Specified by:
addToEnvironment
in interfacejavax.naming.Context
- Parameters:
propName
- name of the property to addpropVal
- value of the property to add- Returns:
- propVal or previous value of the property
- Throws:
javax.naming.NamingException
- if an error occurs
-
removeFromEnvironment
public java.lang.Object removeFromEnvironment(java.lang.String propName) throws javax.naming.NamingException
Remove a property from this Context's environment.- Specified by:
removeFromEnvironment
in interfacejavax.naming.Context
- Parameters:
propName
- name of property to remove- Returns:
- value of property or null if it didn't exist
- Throws:
javax.naming.NamingException
- if an error occurs
-
getEnvironment
public java.util.Hashtable getEnvironment()
Get the environment of this Context.- Specified by:
getEnvironment
in interfacejavax.naming.Context
- Returns:
- a copy of the environment of this Context.
-
addBinding
public void addBinding(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NameAlreadyBoundException
Add a name to object binding to this Context.- Parameters:
name
- aName
valueobj
- anObject
value- Throws:
javax.naming.NameAlreadyBoundException
- if name already bound
-
getBinding
public javax.naming.Binding getBinding(javax.naming.Name name)
Get a name to object binding from this Context- Parameters:
name
- aName
value- Returns:
- a
Binding
value
-
getBinding
public javax.naming.Binding getBinding(java.lang.String name)
Get a name to object binding from this Context- Parameters:
name
- as a String- Returns:
- null or the Binding
-
removeBinding
public void removeBinding(javax.naming.Name name)
-
toCanonicalName
public javax.naming.Name toCanonicalName(javax.naming.Name name)
Remove leading or trailing empty components from name. Eg "/comp/env/" -> "comp/env"- Parameters:
name
- the name to normalize- Returns:
- normalized name
-
isLocked
public boolean isLocked()
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
-
addListener
public void addListener(NamingContext.Listener listener)
-
removeListener
public boolean removeListener(NamingContext.Listener listener)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-