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 interfaceNamingContext.ListenerNaming Context Listener.
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Binding>_bindingsprotected Hashtable<String,Object>_envprotected String_nameprotected NamingContext_parentprotected NameParser_parserstatic StringDEEP_BINDINGstatic StringLOCK_PROPERTYstatic StringUNLOCK_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 voidaddBinding(Name name, Object obj)Add a name to object binding to this Context.voidaddListener(NamingContext.Listener listener)ObjectaddToEnvironment(String propName, Object propVal)Add an environment setting to this Contextvoidbind(String name, Object obj)Bind a name (as a String) to an objectvoidbind(Name name, Object obj)Bind a name to an objectObjectclone()Clone this NamingContextvoidclose()Do nothingStringcomposeName(String name, String prefix)Join two names together.NamecomposeName(Name name, Name prefix)Join two names together.ContextcreateSubcontext(String name)Create a Context as a child of this oneContextcreateSubcontext(Name name)Create a context as a child of this onevoiddestroySubcontext(String name)voiddestroySubcontext(Name name)Stringdump()voiddump(Appendable out, String indent)BindinggetBinding(String name)Get a name to object binding from this ContextBindinggetBinding(Name name)Get a name to object binding from this ContextMap<String,Binding>getBindings()HashtablegetEnvironment()Get the environment of this Context.StringgetName()Getter for _nameStringgetNameInNamespace()Get the full name of this Context node by visiting it's ancestors back to root.NameParsergetNameParser(String name)Return a NameParser for this Context.NameParsergetNameParser(Name name)Return a NameParser for this Context.ContextgetParent()Getter for _parentbooleanisLocked()NamingEnumerationlist(String name)List all names bound at Context named by NameNamingEnumerationlist(Name name)List all names bound at Context named by NameNamingEnumerationlistBindings(String name)List all Bindings at NameNamingEnumerationlistBindings(Name name)List all Bindings present at Context named by NameObjectlookup(String name)Lookup binding of an object by nameObjectlookup(Name name)Lookup a binding by nameObjectlookupLink(String name)Lookup link bound to nameObjectlookupLink(Name name)Lookup link bound to namevoidrebind(String name, Object obj)Overwrite or create a binding from Name to Objectvoidrebind(Name name, Object obj)Overwrite or create a bindingvoidremoveBinding(Name name)ObjectremoveFromEnvironment(String propName)Remove a property from this Context's environment.booleanremoveListener(NamingContext.Listener listener)voidrename(String oldName, String newName)Not supportedvoidrename(Name oldName, Name newName)Not supportedvoidsetBindings(Map<String,Binding> bindings)voidsetEnv(Hashtable<String,Object> env)voidsetNameParser(NameParser parser)NametoCanonicalName(Name name)Remove leading or trailing empty components from name.StringtoString()voidunbind(String name)Not supported.voidunbind(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:
clonein 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:
bindin 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:
bindin interfaceContext- Parameters:
name- aStringvalueobj- anObjectvalue- 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:
createSubcontextin interfaceContext- Parameters:
name- aNamevalue- Returns:
- a
Contextvalue - 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:
createSubcontextin interfaceContext- Parameters:
name- aStringvalue- Returns:
- a
Contextvalue - Throws:
NamingException- if an error occurs
-
destroySubcontext
public void destroySubcontext(String name) throws NamingException
- Specified by:
destroySubcontextin interfaceContext- Parameters:
name- name of subcontext to remove- Throws:
NamingException- if an error occurs
-
destroySubcontext
public void destroySubcontext(Name name) throws NamingException
- Specified by:
destroySubcontextin 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:
lookupin 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:
lookupin 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:
lookupLinkin 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:
lookupLinkin 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:
listin interfaceContext- Parameters:
name- aNamevalue- Returns:
- a
NamingEnumerationvalue - 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:
listin interfaceContext- Parameters:
name- aNamevalue- Returns:
- a
NamingEnumerationvalue - 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:
listBindingsin interfaceContext- Parameters:
name- aNamevalue- Returns:
- a
NamingEnumerationvalue - Throws:
NamingException- if an error occurs
-
listBindings
public NamingEnumeration listBindings(String name) throws NamingException
List all Bindings at Name- Specified by:
listBindingsin interfaceContext- Parameters:
name- aStringvalue- Returns:
- a
NamingEnumerationvalue - Throws:
NamingException- if an error occurs
-
rebind
public void rebind(Name name, Object obj) throws NamingException
Overwrite or create a binding- Specified by:
rebindin interfaceContext- Parameters:
name- aNamevalueobj- anObjectvalue- 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:
rebindin interfaceContext- Parameters:
name- aStringvalueobj- anObjectvalue- Throws:
NamingException- if an error occurs
-
unbind
public void unbind(String name) throws NamingException
Not supported.- Specified by:
unbindin interfaceContext- Parameters:
name- aStringvalue- Throws:
NamingException- if an error occurs
-
unbind
public void unbind(Name name) throws NamingException
Not supported.- Specified by:
unbindin interfaceContext- Parameters:
name- aStringvalue- Throws:
NamingException- if an error occurs
-
rename
public void rename(Name oldName, Name newName) throws NamingException
Not supported- Specified by:
renamein interfaceContext- Parameters:
oldName- aNamevaluenewName- aNamevalue- Throws:
NamingException- if an error occurs
-
rename
public void rename(String oldName, String newName) throws NamingException
Not supported- Specified by:
renamein interfaceContext- Parameters:
oldName- aNamevaluenewName- aNamevalue- 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:
composeNamein interfaceContext- Parameters:
name- aNamevalueprefix- aNamevalue- Returns:
- a
Namevalue - 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:
composeNamein interfaceContext- Parameters:
name- aNamevalueprefix- aNamevalue- Returns:
- a
Namevalue - Throws:
NamingException- if an error occurs
-
close
public void close() throws NamingExceptionDo nothing- Specified by:
closein interfaceContext- Throws:
NamingException- if an error occurs
-
getNameParser
public NameParser getNameParser(Name name)
Return a NameParser for this Context.- Specified by:
getNameParserin interfaceContext- Parameters:
name- aNamevalue- Returns:
- a
NameParservalue
-
getNameParser
public NameParser getNameParser(String name)
Return a NameParser for this Context.- Specified by:
getNameParserin interfaceContext- Parameters:
name- aNamevalue- Returns:
- a
NameParservalue
-
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:
getNameInNamespacein 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:
addToEnvironmentin 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:
removeFromEnvironmentin 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:
getEnvironmentin 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- aNamevalueobj- anObjectvalue- Throws:
NameAlreadyBoundException- if name already bound
-
getBinding
public Binding getBinding(Name name)
Get a name to object binding from this Context- Parameters:
name- aNamevalue- Returns:
- a
Bindingvalue
-
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:
dumpin interfaceDumpable- Throws:
IOException
-
addListener
public void addListener(NamingContext.Listener listener)
-
removeListener
public boolean removeListener(NamingContext.Listener listener)
-
-