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.-
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>_bindingsprotected java.util.Hashtable<java.lang.String,java.lang.Object>_envprotected java.lang.String_nameprotected NamingContext_parentprotected javax.naming.NameParser_parserstatic java.lang.StringDEEP_BINDINGstatic java.lang.StringLOCK_PROPERTYstatic java.lang.StringUNLOCK_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)ConstructorprotectedNamingContext(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 voidaddBinding(javax.naming.Name name, java.lang.Object obj)Add a name to object binding to this Context.voidaddListener(NamingContext.Listener listener)java.lang.ObjectaddToEnvironment(java.lang.String propName, java.lang.Object propVal)Add an environment setting to this Contextvoidbind(java.lang.String name, java.lang.Object obj)Bind a name (as a String) to an objectvoidbind(javax.naming.Name name, java.lang.Object obj)Bind a name to an objectvoidclose()Do nothingjava.lang.StringcomposeName(java.lang.String name, java.lang.String prefix)Join two names together.javax.naming.NamecomposeName(javax.naming.Name name, javax.naming.Name prefix)Join two names together.javax.naming.ContextcreateSubcontext(java.lang.String name)Create a Context as a child of this onejavax.naming.ContextcreateSubcontext(javax.naming.Name name)Create a context as a child of this onevoiddestroySubcontext(java.lang.String name)voiddestroySubcontext(javax.naming.Name name)java.lang.Stringdump()voiddump(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.BindinggetBinding(java.lang.String name)Get a name to object binding from this Contextjavax.naming.BindinggetBinding(javax.naming.Name name)Get a name to object binding from this Contextjava.util.HashtablegetEnvironment()Get the environment of this Context.java.lang.StringgetName()Getter for _namejava.lang.StringgetNameInNamespace()Get the full name of this Context node by visiting it's ancestors back to root.javax.naming.NameParsergetNameParser(java.lang.String name)Return a NameParser for this Context.javax.naming.NameParsergetNameParser(javax.naming.Name name)Return a NameParser for this Context.javax.naming.ContextgetParent()Getter for _parentbooleanisDeepBindingSupported()booleanisLocked()javax.naming.NamingEnumerationlist(java.lang.String name)List all names bound at Context named by Namejavax.naming.NamingEnumerationlist(javax.naming.Name name)List all names bound at Context named by Namejavax.naming.NamingEnumerationlistBindings(java.lang.String name)List all Bindings at Namejavax.naming.NamingEnumerationlistBindings(javax.naming.Name name)List all Bindings present at Context named by Namejava.lang.Objectlookup(java.lang.String name)Lookup binding of an object by namejava.lang.Objectlookup(javax.naming.Name name)Lookup a binding by namejava.lang.ObjectlookupLink(java.lang.String name)Lookup link bound to namejava.lang.ObjectlookupLink(javax.naming.Name name)Lookup link bound to namevoidrebind(java.lang.String name, java.lang.Object obj)Overwrite or create a binding from Name to Objectvoidrebind(javax.naming.Name name, java.lang.Object obj)Overwrite or create a bindingvoidremoveBinding(javax.naming.Name name)java.lang.ObjectremoveFromEnvironment(java.lang.String propName)Remove a property from this Context's environment.booleanremoveListener(NamingContext.Listener listener)voidrename(java.lang.String oldName, java.lang.String newName)Not supportedvoidrename(javax.naming.Name oldName, javax.naming.Name newName)Not supportedvoidsetEnv(java.util.Hashtable<java.lang.String,java.lang.Object> env)voidsetNameParser(javax.naming.NameParser parser)javax.naming.ContextshallowCopy(java.util.Hashtable<java.lang.String,java.lang.Object> env)javax.naming.NametoCanonicalName(javax.naming.Name name)Remove leading or trailing empty components from name.java.lang.StringtoString()voidunbind(java.lang.String name)Not supported.voidunbind(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.NamingExceptionBind a name to an object- Specified by:
bindin 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.NamingExceptionBind a name (as a String) to an object- Specified by:
bindin interfacejavax.naming.Context- Parameters:
name- aStringvalueobj- anObjectvalue- Throws:
javax.naming.NamingException- if an error occurs
-
createSubcontext
public javax.naming.Context createSubcontext(javax.naming.Name name) throws javax.naming.NamingExceptionCreate a context as a child of this one- Specified by:
createSubcontextin interfacejavax.naming.Context- Parameters:
name- aNamevalue- Returns:
- a
Contextvalue - Throws:
javax.naming.NamingException- if an error occurs
-
createSubcontext
public javax.naming.Context createSubcontext(java.lang.String name) throws javax.naming.NamingExceptionCreate a Context as a child of this one- Specified by:
createSubcontextin interfacejavax.naming.Context- Parameters:
name- aStringvalue- Returns:
- a
Contextvalue - Throws:
javax.naming.NamingException- if an error occurs
-
destroySubcontext
public void destroySubcontext(java.lang.String name) throws javax.naming.NamingException- Specified by:
destroySubcontextin 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:
destroySubcontextin 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.NamingExceptionLookup a binding by name- Specified by:
lookupin 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.NamingExceptionLookup binding of an object by name- Specified by:
lookupin 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.NamingExceptionLookup link bound to name- Specified by:
lookupLinkin 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.NamingExceptionLookup link bound to name- Specified by:
lookupLinkin 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.NamingExceptionList all names bound at Context named by Name- Specified by:
listin interfacejavax.naming.Context- Parameters:
name- aNamevalue- Returns:
- a
NamingEnumerationvalue - Throws:
javax.naming.NamingException- if an error occurs
-
list
public javax.naming.NamingEnumeration list(java.lang.String name) throws javax.naming.NamingExceptionList all names bound at Context named by Name- Specified by:
listin interfacejavax.naming.Context- Parameters:
name- aNamevalue- Returns:
- a
NamingEnumerationvalue - Throws:
javax.naming.NamingException- if an error occurs
-
listBindings
public javax.naming.NamingEnumeration listBindings(javax.naming.Name name) throws javax.naming.NamingExceptionList all Bindings present at Context named by Name- Specified by:
listBindingsin interfacejavax.naming.Context- Parameters:
name- aNamevalue- Returns:
- a
NamingEnumerationvalue - Throws:
javax.naming.NamingException- if an error occurs
-
listBindings
public javax.naming.NamingEnumeration listBindings(java.lang.String name) throws javax.naming.NamingExceptionList all Bindings at Name- Specified by:
listBindingsin interfacejavax.naming.Context- Parameters:
name- aStringvalue- Returns:
- a
NamingEnumerationvalue - Throws:
javax.naming.NamingException- if an error occurs
-
rebind
public void rebind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingExceptionOverwrite or create a binding- Specified by:
rebindin interfacejavax.naming.Context- Parameters:
name- aNamevalueobj- anObjectvalue- Throws:
javax.naming.NamingException- if an error occurs
-
rebind
public void rebind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingExceptionOverwrite or create a binding from Name to Object- Specified by:
rebindin interfacejavax.naming.Context- Parameters:
name- aStringvalueobj- anObjectvalue- Throws:
javax.naming.NamingException- if an error occurs
-
unbind
public void unbind(java.lang.String name) throws javax.naming.NamingExceptionNot supported.- Specified by:
unbindin interfacejavax.naming.Context- Parameters:
name- aStringvalue- Throws:
javax.naming.NamingException- if an error occurs
-
unbind
public void unbind(javax.naming.Name name) throws javax.naming.NamingExceptionNot supported.- Specified by:
unbindin interfacejavax.naming.Context- Parameters:
name- aStringvalue- Throws:
javax.naming.NamingException- if an error occurs
-
rename
public void rename(javax.naming.Name oldName, javax.naming.Name newName) throws javax.naming.NamingExceptionNot supported- Specified by:
renamein interfacejavax.naming.Context- Parameters:
oldName- aNamevaluenewName- aNamevalue- Throws:
javax.naming.NamingException- if an error occurs
-
rename
public void rename(java.lang.String oldName, java.lang.String newName) throws javax.naming.NamingExceptionNot supported- Specified by:
renamein interfacejavax.naming.Context- Parameters:
oldName- aNamevaluenewName- aNamevalue- 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.NamingExceptionJoin two names together. These are treated as CompoundNames.- Specified by:
composeNamein interfacejavax.naming.Context- Parameters:
name- aNamevalueprefix- aNamevalue- Returns:
- a
Namevalue - 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.NamingExceptionJoin two names together. These are treated as CompoundNames.- Specified by:
composeNamein interfacejavax.naming.Context- Parameters:
name- aNamevalueprefix- aNamevalue- Returns:
- a
Namevalue - Throws:
javax.naming.NamingException- if an error occurs
-
close
public void close() throws javax.naming.NamingExceptionDo nothing- Specified by:
closein 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:
getNameParserin interfacejavax.naming.Context- Parameters:
name- aNamevalue- Returns:
- a
NameParservalue
-
getNameParser
public javax.naming.NameParser getNameParser(java.lang.String name)
Return a NameParser for this Context.- Specified by:
getNameParserin interfacejavax.naming.Context- Parameters:
name- aNamevalue- Returns:
- a
NameParservalue
-
getNameInNamespace
public java.lang.String getNameInNamespace() throws javax.naming.NamingExceptionGet 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 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.NamingExceptionAdd an environment setting to this Context- Specified by:
addToEnvironmentin 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.NamingExceptionRemove a property from this Context's environment.- Specified by:
removeFromEnvironmentin 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:
getEnvironmentin 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.NameAlreadyBoundExceptionAdd a name to object binding to this Context.- Parameters:
name- aNamevalueobj- anObjectvalue- 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- aNamevalue- Returns:
- a
Bindingvalue
-
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.IOExceptionDescription copied from interface:DumpableDump 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:
toStringin classjava.lang.Object
-
-