Package org.eclipse.jetty.jndi
Class NamingContext
java.lang.Object
org.eclipse.jetty.jndi.NamingContext
NamingContext
Implementation of Context interface.
Notes: All Names are expected to be Compound, not Composite.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Naming Context Listener.Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ConcurrentMap<String,
Binding> protected String
protected NamingContext
protected NameParser
static final String
static final String
static final String
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
ModifierConstructorDescriptionNamingContext
(Hashtable<String, Object> env, String name, NamingContext parent, NameParser parser) Constructorprotected
NamingContext
(Hashtable<String, Object> env, String name, NamingContext parent, NameParser parser, ConcurrentMap<String, Binding> bindings) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBinding
(Name name, Object obj) Add a name to object binding to this Context.void
addListener
(NamingContext.Listener listener) addToEnvironment
(String propName, Object propVal) Add an environment setting to this Contextvoid
Bind a name (as a String) to an objectvoid
Bind a name to an objectvoid
close()
Do nothingcomposeName
(String name, String prefix) Join two names together.composeName
(Name name, Name prefix) Join two names together.createSubcontext
(String name) Create a Context as a child of this onecreateSubcontext
(Name name) Create a context as a child of this onevoid
destroySubcontext
(String name) void
destroySubcontext
(Name name) dump()
void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.getBinding
(String name) Get a name to object binding from this ContextgetBinding
(Name name) Get a name to object binding from this ContextGet the environment of this Context.getName()
Getter for _nameGet the full name of this Context node by visiting it's ancestors back to root.getNameParser
(String name) Return a NameParser for this Context.getNameParser
(Name name) Return a NameParser for this Context.Getter for _parentboolean
boolean
isLocked()
List all names bound at Context named by NameList all names bound at Context named by NamelistBindings
(String name) List all Bindings at NamelistBindings
(Name name) List all Bindings present at Context named by NameLookup binding of an object by nameLookup a binding by namelookupLink
(String name) Lookup link bound to namelookupLink
(Name name) Lookup link bound to namevoid
Overwrite or create a binding from Name to Objectvoid
Overwrite or create a bindingvoid
removeBinding
(Name name) removeFromEnvironment
(String propName) Remove a property from this Context's environment.boolean
removeListener
(NamingContext.Listener listener) void
Not supportedvoid
Not supportedfinal void
void
setNameParser
(NameParser parser) shallowCopy
(Hashtable<String, Object> env) toCanonicalName
(Name name) Remove leading or trailing empty components from name.toString()
void
Not supported.void
Not supported.
-
Field Details
-
DEEP_BINDING
- See Also:
-
LOCK_PROPERTY
- See Also:
-
UNLOCK_PROPERTY
- See Also:
-
_env
-
_bindings
-
_parent
-
_name
-
_parser
-
-
Constructor Details
-
NamingContext
public NamingContext(Hashtable<String, Object> env, String name, NamingContext parent, 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(Hashtable<String, Object> env, String name, NamingContext parent, NameParser parser, ConcurrentMap<String, Binding> bindings)
-
-
Method Details
-
shallowCopy
- Returns:
- A shallow copy of the Context with the same bindings, but with the passed environment
-
isDeepBindingSupported
public boolean isDeepBindingSupported() -
getName
Getter for _name- Returns:
- name of this Context (relative, not absolute)
-
getParent
Getter for _parent- Returns:
- parent Context
-
setNameParser
-
setEnv
-
bind
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
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
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
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
- Specified by:
destroySubcontext
in interfaceContext
- Parameters:
name
- name of subcontext to remove- Throws:
NamingException
- if an error occurs
-
destroySubcontext
- Specified by:
destroySubcontext
in interfaceContext
- Parameters:
name
- name of subcontext to remove- Throws:
NamingException
- if an error occurs
-
lookup
Lookup a binding by name- Specified by:
lookup
in interfaceContext
- Parameters:
name
- name of bound object- Throws:
NamingException
- if an error occurs
-
lookup
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
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
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
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
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
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
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
Overwrite or create a binding- Specified by:
rebind
in interfaceContext
- Parameters:
name
- aName
valueobj
- anObject
value- Throws:
NamingException
- if an error occurs
-
rebind
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
Not supported.- Specified by:
unbind
in interfaceContext
- Parameters:
name
- aString
value- Throws:
NamingException
- if an error occurs
-
unbind
Not supported.- Specified by:
unbind
in interfaceContext
- Parameters:
name
- aString
value- Throws:
NamingException
- if an error occurs
-
rename
Not supported- Specified by:
rename
in interfaceContext
- Parameters:
oldName
- aName
valuenewName
- aName
value- Throws:
NamingException
- if an error occurs
-
rename
Not supported- Specified by:
rename
in interfaceContext
- Parameters:
oldName
- aName
valuenewName
- aName
value- Throws:
NamingException
- if an error occurs
-
composeName
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
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
Do nothing- Specified by:
close
in interfaceContext
- Throws:
NamingException
- if an error occurs
-
getNameParser
Return a NameParser for this Context.- Specified by:
getNameParser
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NameParser
value
-
getNameParser
Return a NameParser for this Context.- Specified by:
getNameParser
in interfaceContext
- Parameters:
name
- aName
value- Returns:
- a
NameParser
value
-
getNameInNamespace
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
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
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
Get the environment of this Context.- Specified by:
getEnvironment
in interfaceContext
- Returns:
- a copy of the environment of this Context.
-
addBinding
Add a name to object binding to this Context.- Parameters:
name
- aName
valueobj
- anObject
value- Throws:
NameAlreadyBoundException
- if name already bound
-
getBinding
Get a name to object binding from this Context- Parameters:
name
- aName
value- Returns:
- a
Binding
value
-
getBinding
Get a name to object binding from this Context- Parameters:
name
- as a String- Returns:
- null or the Binding
-
removeBinding
-
toCanonicalName
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
-
dump
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.- Specified by:
dump
in interfaceDumpable
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
addListener
-
removeListener
-
toString
-