Package org.apache.xbean.naming.context
Class AbstractContext
java.lang.Object
org.apache.xbean.naming.context.AbstractContext
- All Implemented Interfaces:
Serializable
,Context
,NestedContextFactory
- Direct Known Subclasses:
AbstractFederatedContext
,ImmutableContext
,ImmutableContext.NestedImmutableContext
public abstract class AbstractContext
extends Object
implements Context, NestedContextFactory, Serializable
- See Also:
-
Field Summary
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
ConstructorsModifierConstructorDescriptionprotected
AbstractContext
(String nameInNamespace) AbstractContext
(String nameInNamespace, ContextAccess contextAccess) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
addBinding
(String name, Object value, boolean rebind) protected void
addBinding
(Context context, String name, Object value, boolean rebind) Binds the specified value to the specified name within the specified context.protected void
addDeepBinding
(Name name, Object value, boolean rebind, boolean createIntermediateContexts) addToEnvironment
(String propName, Object propVal) void
void
void
close()
composeName
(String name, String prefix) composeName
(Name name, Name prefix) createSubcontext
(String name) createSubcontext
(Name name) protected Context
createSubcontextTree
(String path, Name name, Object value) Creates a context tree which will be rooted at the specified path and contain a single entry located down a path specified by the name.void
destroySubcontext
(String name) void
destroySubcontext
(Name name) protected Object
faultLookup
(String stringName, Name parsedName) When a value can not be found within this context, this method is called as a last ditch effort befrore thowing a null pointer exception.protected Object
getBinding
(String name) Gets the object bound to the name.Gets a map of the bindings for the current node (i.e., no names with slashes).protected ContextAccess
protected Object
getDeepBinding
(String name) Gets the object bound to the name.Always returns a new (empty) Hashtable.Gets the name of this context withing the global namespace.protected String
getNameInNamespace
(String path) Gets the name of a path withing the global namespace context.protected Name
getNameInNamespace
(Name path) Gets the name of a path withing the global namespace context.protected NameParser
A parser that can turn Strings into javax.naming.Name objects.getNameParser
(String name) getNameParser
(Name name) protected Name
Gets the name of this context withing the global namespace.protected static int
protected static boolean
protected NamingEnumeration<NameClassPair>
list()
protected NamingEnumeration<Binding>
listBindings
(String name) listBindings
(Name name) protected Object
Finds the specified entry.protected Context
lookupFinalContext
(Name name) lookupLink
(String name) lookupLink
(Name name) void
void
protected abstract boolean
removeBinding
(String name, boolean removeNotEmptyContext) Removes the binding from the context.protected void
removeDeepBinding
(Name name, boolean pruneEmptyContexts) protected void
removeDeepBinding
(Name name, boolean pruneEmptyContexts, boolean removeNotEmptyContext) removeFromEnvironment
(String propName) void
void
void
void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.xbean.naming.context.NestedContextFactory
createNestedSubcontext, isNestedSubcontext
-
Constructor Details
-
AbstractContext
-
AbstractContext
-
-
Method Details
-
close
- Specified by:
close
in interfaceContext
- Throws:
NamingException
-
getContextAccess
-
getDeepBinding
Gets the object bound to the name. The name may contain slashes.- Parameters:
name
- the name- Returns:
- the object bound to the name, or null if not found
-
getBinding
Gets the object bound to the name. The name will not contain slashes.- Parameters:
name
- the name- Returns:
- the object bound to the name, or null if not found
- Throws:
NamingException
- on error
-
lookup
Finds the specified entry. Normally there is no need to override this method; instead you should simply implement the getDeepBindings(String) and getBindings(String) method. This method will follow links except for the final element which is always just returned without inspection. This means this method can be used to implement lookupLink.- Parameters:
stringName
- the string version of the name; maybe nullparsedName
- the parsed name; may be null- Returns:
- the value bound to the name
- Throws:
NamingException
- if no value is bound to that name or if a problem occurs during the lookup
-
faultLookup
When a value can not be found within this context, this method is called as a last ditch effort befrore thowing a null pointer exception.- Parameters:
stringName
- the string version of the name; will not be nullparsedName
- the parsed name; will not be null- Returns:
- the value or null if no fault value could be found
-
lookupFinalContext
- Throws:
NamingException
-
getBindings
Gets a map of the bindings for the current node (i.e., no names with slashes). This method must not return null.- Returns:
- a Map from binding name to binding value
- Throws:
NamingException
- if a problem occurs while getting the bindigns
-
addDeepBinding
protected void addDeepBinding(Name name, Object value, boolean rebind, boolean createIntermediateContexts) throws NamingException - Throws:
NamingException
-
addBinding
protected void addBinding(Context context, String name, Object value, boolean rebind) throws NamingException Binds the specified value to the specified name within the specified context. If the specified context is an AbstractContext and is a nested subcontext, this method will call the direct addBinding method, otherwise it will call public (re)bind method.- Parameters:
context
- the context to add the binding toname
- the binding namevalue
- the value to bindrebind
- if true, this method will replace any exsiting binding, otherwise a NamingException will be thrown- Throws:
NamingException
- if a problem occurs while (re)binding
-
addBinding
protected abstract boolean addBinding(String name, Object value, boolean rebind) throws NamingException - Throws:
NamingException
-
createSubcontextTree
Creates a context tree which will be rooted at the specified path and contain a single entry located down a path specified by the name. All necessary intermediate contexts will be created using the createContext method.- Parameters:
path
- the path to the context that will contains this contextname
- the name under which the value should be boundvalue
- the value- Returns:
- a context with the value bound at the specified name
- Throws:
NamingException
- if a problem occurs while creating the subcontext tree
-
removeBinding
protected abstract boolean removeBinding(String name, boolean removeNotEmptyContext) throws NamingException Removes the binding from the context. The name will not contain a path and the value will not be a nested context although it may be a foreign context.- Parameters:
name
- name under which the value should be boundremoveNotEmptyContext
- ??? TODO figure this out- Returns:
- whether removal was successful
- Throws:
NamingException
- if a problem occurs during the bind such as a value already being bound
-
removeDeepBinding
- Throws:
NamingException
-
removeDeepBinding
protected void removeDeepBinding(Name name, boolean pruneEmptyContexts, boolean removeNotEmptyContext) throws NamingException - Throws:
NamingException
-
isEmpty
- Throws:
NamingException
-
getSize
- Throws:
NamingException
-
getEnvironment
Always returns a new (empty) Hashtable.- Specified by:
getEnvironment
in interfaceContext
- Returns:
- a new (empty) Hashtable
-
addToEnvironment
- Specified by:
addToEnvironment
in interfaceContext
- Throws:
NamingException
-
removeFromEnvironment
- Specified by:
removeFromEnvironment
in interfaceContext
- Throws:
NamingException
-
getNameInNamespace
Gets the name of this context withing the global namespace. This method may return null if the location of the node in the global namespace is not known- Specified by:
getNameInNamespace
in interfaceContext
- Returns:
- the name of this context within the global namespace or null if unknown.
-
getParsedNameInNamespace
Gets the name of this context withing the global namespace. This method may return null if the location of the node in the global namespace is not known- Returns:
- the name of this context within the global namespace or null if unknown.
-
getNameInNamespace
Gets the name of a path withing the global namespace context.- Parameters:
path
- path to extend- Returns:
- full path in namespace
-
getNameInNamespace
Gets the name of a path withing the global namespace context.- Parameters:
path
- path to extend- Returns:
- full path in namespace
- Throws:
NamingException
- on error
-
getNameParser
A parser that can turn Strings into javax.naming.Name objects.- Returns:
- ContextUtil.NAME_PARSER
-
getNameParser
- Specified by:
getNameParser
in interfaceContext
-
getNameParser
- Specified by:
getNameParser
in interfaceContext
-
composeName
- Specified by:
composeName
in interfaceContext
- Throws:
NamingException
-
composeName
- Specified by:
composeName
in interfaceContext
- Throws:
NamingException
-
lookup
- Specified by:
lookup
in interfaceContext
- Throws:
NamingException
-
lookup
- Specified by:
lookup
in interfaceContext
- Throws:
NamingException
-
lookupLink
- Specified by:
lookupLink
in interfaceContext
- Throws:
NamingException
-
lookupLink
- Specified by:
lookupLink
in interfaceContext
- Throws:
NamingException
-
bind
- Specified by:
bind
in interfaceContext
- Throws:
NamingException
-
bind
- Specified by:
bind
in interfaceContext
- Throws:
NamingException
-
rebind
- Specified by:
rebind
in interfaceContext
- Throws:
NamingException
-
rebind
- Specified by:
rebind
in interfaceContext
- Throws:
NamingException
-
rename
- Specified by:
rename
in interfaceContext
- Throws:
NamingException
-
rename
- Specified by:
rename
in interfaceContext
- Throws:
NamingException
-
unbind
- Specified by:
unbind
in interfaceContext
- Throws:
NamingException
-
unbind
- Specified by:
unbind
in interfaceContext
- Throws:
NamingException
-
list
- Throws:
NamingException
-
listBindings
- Throws:
NamingException
-
list
- Specified by:
list
in interfaceContext
- Throws:
NamingException
-
list
- Specified by:
list
in interfaceContext
- Throws:
NamingException
-
listBindings
- Specified by:
listBindings
in interfaceContext
- Throws:
NamingException
-
listBindings
- Specified by:
listBindings
in interfaceContext
- Throws:
NamingException
-
createSubcontext
- Specified by:
createSubcontext
in interfaceContext
- Throws:
NamingException
-
createSubcontext
- Specified by:
createSubcontext
in interfaceContext
- Throws:
NamingException
-
destroySubcontext
- Specified by:
destroySubcontext
in interfaceContext
- Throws:
NamingException
-
destroySubcontext
- Specified by:
destroySubcontext
in interfaceContext
- Throws:
NamingException
-