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.
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Binding>
_bindings
protected Hashtable<String,Object>
_env
protected String
_name
protected NamingContext
_parent
protected NameParser
_parser
static String
DEEP_BINDING
static String
LOCK_PROPERTY
static String
UNLOCK_PROPERTY
-
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
Constructors Constructor Description NamingContext(Hashtable<String,Object> env, String name, NamingContext parent, NameParser parser)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBinding(Name name, Object obj)
Add a name to object binding to this Context.void
addListener(NamingContext.Listener listener)
Object
addToEnvironment(String propName, Object propVal)
Add an environment setting to this Contextvoid
bind(String name, Object obj)
Bind a name (as a String) to an objectvoid
bind(Name name, Object obj)
Bind a name to an objectObject
clone()
Clone this NamingContextvoid
close()
Do nothingString
composeName(String name, String prefix)
Join two names together.Name
composeName(Name name, Name prefix)
Join two names together.Context
createSubcontext(String name)
Create a Context as a child of this oneContext
createSubcontext(Name name)
Create a context as a child of this onevoid
destroySubcontext(String name)
void
destroySubcontext(Name name)
String
dump()
void
dump(Appendable out, String indent)
Binding
getBinding(String name)
Get a name to object binding from this ContextBinding
getBinding(Name name)
Get a name to object binding from this ContextMap<String,Binding>
getBindings()
Hashtable
getEnvironment()
Get the environment of this Context.String
getName()
Getter for _nameString
getNameInNamespace()
Get the full name of this Context node by visiting it's ancestors back to root.NameParser
getNameParser(String name)
Return a NameParser for this Context.NameParser
getNameParser(Name name)
Return a NameParser for this Context.Context
getParent()
Getter for _parentboolean
isLocked()
NamingEnumeration
list(String name)
List all names bound at Context named by NameNamingEnumeration
list(Name name)
List all names bound at Context named by NameNamingEnumeration
listBindings(String name)
List all Bindings at NameNamingEnumeration
listBindings(Name name)
List all Bindings present at Context named by NameObject
lookup(String name)
Lookup binding of an object by nameObject
lookup(Name name)
Lookup a binding by nameObject
lookupLink(String name)
Lookup link bound to nameObject
lookupLink(Name name)
Lookup link bound to namevoid
rebind(String name, Object obj)
Overwrite or create a binding from Name to Objectvoid
rebind(Name name, Object obj)
Overwrite or create a bindingvoid
removeBinding(Name name)
Object
removeFromEnvironment(String propName)
Remove a property from this Context's environment.boolean
removeListener(NamingContext.Listener listener)
void
rename(String oldName, String newName)
Not supportedvoid
rename(Name oldName, Name newName)
Not supportedvoid
setBindings(Map<String,Binding> bindings)
void
setEnv(Hashtable<String,Object> env)
void
setNameParser(NameParser parser)
Name
toCanonicalName(Name name)
Remove leading or trailing empty components from name.String
toString()
void
unbind(String name)
Not supported.void
unbind(Name name)
Not supported.
-
-
-
Field Detail
-
DEEP_BINDING
public static final String DEEP_BINDING
- See Also:
- Constant Field Values
-
LOCK_PROPERTY
public static final String LOCK_PROPERTY
- See Also:
- Constant Field Values
-
UNLOCK_PROPERTY
public static final String UNLOCK_PROPERTY
- See Also:
- Constant Field Values
-
_parent
protected NamingContext _parent
-
_name
protected String _name
-
_parser
protected NameParser _parser
-
-
Constructor Detail
-
NamingContext
public NamingContext(Hashtable<String,Object> env, String name, NamingContext parent, NameParser parser)
Constructor- Parameters:
env
- environment propertiesname
- relative name of this contextparent
- immediate ancestor Context (can be null)parser
- NameParser for this Context
-
-
Method Detail
-
clone
public Object clone() throws CloneNotSupportedException
Clone this NamingContext- Overrides:
clone
in classObject
- Returns:
- copy of this NamingContext
- Throws:
CloneNotSupportedException
- if an error occurs
-
getName
public String getName()
Getter for _name- Returns:
- name of this Context (relative, not absolute)
-
getParent
public Context getParent()
Getter for _parent- Returns:
- parent Context
-
setNameParser
public void setNameParser(NameParser parser)
-
bind
public void bind(Name name, Object obj) throws NamingException
Bind a name to an object- Specified by:
bind
in interfaceContext
- Parameters:
name
- Name of the objectobj
- object to bind- Throws:
NamingException
- if an error occurs
-
bind
public void bind(String name, Object obj) throws NamingException
Bind a name (as a String) to an object- Specified by:
bind
in interfaceContext
- Parameters:
name
- aString
valueobj
- anObject
value- Throws:
NamingException
- if an error occurs
-
createSubcontext
public Context createSubcontext(Name name) throws NamingException
Create a context as a child of this one- Specified by:
createSubcontext
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
Context
value - Throws:
NamingException
- if an error occurs
-
createSubcontext
public Context createSubcontext(String name) throws NamingException
Create a Context as a child of this one- Specified by:
createSubcontext
in interfaceContext
- Parameters:
name
- aString
value- Returns:
- a
Context
value - Throws:
NamingException
- if an error occurs
-
destroySubcontext
public void destroySubcontext(String name) throws NamingException
- Specified by:
destroySubcontext
in interfaceContext
- Parameters:
name
- name of subcontext to remove- Throws:
NamingException
- if an error occurs
-
destroySubcontext
public void destroySubcontext(Name name) throws NamingException
- Specified by:
destroySubcontext
in interfaceContext
- Parameters:
name
- name of subcontext to remove- Throws:
NamingException
- if an error occurs
-
lookup
public Object lookup(Name name) throws NamingException
Lookup a binding by name- Specified by:
lookup
in interfaceContext
- Parameters:
name
- name of bound object- Throws:
NamingException
- if an error occurs
-
lookup
public Object lookup(String name) throws NamingException
Lookup binding of an object by name- Specified by:
lookup
in interfaceContext
- Parameters:
name
- name of bound object- Returns:
- object bound to name
- Throws:
NamingException
- if an error occurs
-
lookupLink
public Object lookupLink(Name name) throws NamingException
Lookup link bound to name- Specified by:
lookupLink
in interfaceContext
- Parameters:
name
- name of link binding- Returns:
- LinkRef or plain object bound at name
- Throws:
NamingException
- if an error occurs
-
lookupLink
public Object lookupLink(String name) throws NamingException
Lookup link bound to name- Specified by:
lookupLink
in interfaceContext
- Parameters:
name
- name of link binding- Returns:
- LinkRef or plain object bound at name
- Throws:
NamingException
- if an error occurs
-
list
public NamingEnumeration list(Name name) throws NamingException
List all names bound at Context named by Name- Specified by:
list
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NamingEnumeration
value - Throws:
NamingException
- if an error occurs
-
list
public NamingEnumeration list(String name) throws NamingException
List all names bound at Context named by Name- Specified by:
list
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NamingEnumeration
value - Throws:
NamingException
- if an error occurs
-
listBindings
public NamingEnumeration listBindings(Name name) throws NamingException
List all Bindings present at Context named by Name- Specified by:
listBindings
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NamingEnumeration
value - Throws:
NamingException
- if an error occurs
-
listBindings
public NamingEnumeration listBindings(String name) throws NamingException
List all Bindings at Name- Specified by:
listBindings
in interfaceContext
- Parameters:
name
- aString
value- Returns:
- a
NamingEnumeration
value - Throws:
NamingException
- if an error occurs
-
rebind
public void rebind(Name name, Object obj) throws NamingException
Overwrite or create a binding- Specified by:
rebind
in interfaceContext
- Parameters:
name
- aName
valueobj
- anObject
value- Throws:
NamingException
- if an error occurs
-
rebind
public void rebind(String name, Object obj) throws NamingException
Overwrite or create a binding from Name to Object- Specified by:
rebind
in interfaceContext
- Parameters:
name
- aString
valueobj
- anObject
value- Throws:
NamingException
- if an error occurs
-
unbind
public void unbind(String name) throws NamingException
Not supported.- Specified by:
unbind
in interfaceContext
- Parameters:
name
- aString
value- Throws:
NamingException
- if an error occurs
-
unbind
public void unbind(Name name) throws NamingException
Not supported.- Specified by:
unbind
in interfaceContext
- Parameters:
name
- aString
value- Throws:
NamingException
- if an error occurs
-
rename
public void rename(Name oldName, Name newName) throws NamingException
Not supported- Specified by:
rename
in interfaceContext
- Parameters:
oldName
- aName
valuenewName
- aName
value- Throws:
NamingException
- if an error occurs
-
rename
public void rename(String oldName, String newName) throws NamingException
Not supported- Specified by:
rename
in interfaceContext
- Parameters:
oldName
- aName
valuenewName
- aName
value- Throws:
NamingException
- if an error occurs
-
composeName
public Name composeName(Name name, Name prefix) throws NamingException
Join two names together. These are treated as CompoundNames.- Specified by:
composeName
in interfaceContext
- Parameters:
name
- aName
valueprefix
- aName
value- Returns:
- a
Name
value - Throws:
NamingException
- if an error occurs
-
composeName
public String composeName(String name, String prefix) throws NamingException
Join two names together. These are treated as CompoundNames.- Specified by:
composeName
in interfaceContext
- Parameters:
name
- aName
valueprefix
- aName
value- Returns:
- a
Name
value - Throws:
NamingException
- if an error occurs
-
close
public void close() throws NamingException
Do nothing- Specified by:
close
in interfaceContext
- Throws:
NamingException
- if an error occurs
-
getNameParser
public NameParser getNameParser(Name name)
Return a NameParser for this Context.- Specified by:
getNameParser
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NameParser
value
-
getNameParser
public NameParser getNameParser(String name)
Return a NameParser for this Context.- Specified by:
getNameParser
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NameParser
value
-
getNameInNamespace
public String getNameInNamespace() throws 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 interfaceContext
- Returns:
- the full name of this Context
- Throws:
NamingException
- if an error occurs
-
addToEnvironment
public Object addToEnvironment(String propName, Object propVal) throws NamingException
Add an environment setting to this Context- Specified by:
addToEnvironment
in interfaceContext
- Parameters:
propName
- name of the property to addpropVal
- value of the property to add- Returns:
- propVal or previous value of the property
- Throws:
NamingException
- if an error occurs
-
removeFromEnvironment
public Object removeFromEnvironment(String propName) throws NamingException
Remove a property from this Context's environment.- Specified by:
removeFromEnvironment
in interfaceContext
- Parameters:
propName
- name of property to remove- Returns:
- value of property or null if it didn't exist
- Throws:
NamingException
- if an error occurs
-
getEnvironment
public Hashtable getEnvironment()
Get the environment of this Context.- Specified by:
getEnvironment
in interfaceContext
- Returns:
- a copy of the environment of this Context.
-
addBinding
public void addBinding(Name name, Object obj) throws NameAlreadyBoundException
Add a name to object binding to this Context.- Parameters:
name
- aName
valueobj
- anObject
value- Throws:
NameAlreadyBoundException
- if name already bound
-
getBinding
public Binding getBinding(Name name)
Get a name to object binding from this Context- Parameters:
name
- aName
value- Returns:
- a
Binding
value
-
getBinding
public Binding getBinding(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(Name name)
-
toCanonicalName
public Name toCanonicalName(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(Appendable out, String indent) throws IOException
- Specified by:
dump
in interfaceDumpable
- Throws:
IOException
-
addListener
public void addListener(NamingContext.Listener listener)
-
removeListener
public boolean removeListener(NamingContext.Listener listener)
-
-