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
ConstructorsModifierConstructorDescriptionprotectedAbstractContext(String nameInNamespace) AbstractContext(String nameInNamespace, ContextAccess contextAccess) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanaddBinding(String name, Object value, boolean rebind) protected voidaddBinding(Context context, String name, Object value, boolean rebind) Binds the specified value to the specified name within the specified context.protected voidaddDeepBinding(Name name, Object value, boolean rebind, boolean createIntermediateContexts) addToEnvironment(String propName, Object propVal) voidvoidvoidclose()composeName(String name, String prefix) composeName(Name name, Name prefix) createSubcontext(String name) createSubcontext(Name name) protected ContextcreateSubcontextTree(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.voiddestroySubcontext(String name) voiddestroySubcontext(Name name) protected ObjectfaultLookup(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 ObjectgetBinding(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 ContextAccessprotected ObjectgetDeepBinding(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 StringgetNameInNamespace(String path) Gets the name of a path withing the global namespace context.protected NamegetNameInNamespace(Name path) Gets the name of a path withing the global namespace context.protected NameParserA parser that can turn Strings into javax.naming.Name objects.getNameParser(String name) getNameParser(Name name) protected NameGets the name of this context withing the global namespace.protected static intprotected static booleanprotected NamingEnumeration<NameClassPair>list()protected NamingEnumeration<Binding>listBindings(String name) listBindings(Name name) protected ObjectFinds the specified entry.protected ContextlookupFinalContext(Name name) lookupLink(String name) lookupLink(Name name) voidvoidprotected abstract booleanremoveBinding(String name, boolean removeNotEmptyContext) Removes the binding from the context.protected voidremoveDeepBinding(Name name, boolean pruneEmptyContexts) protected voidremoveDeepBinding(Name name, boolean pruneEmptyContexts, boolean removeNotEmptyContext) removeFromEnvironment(String propName) voidvoidvoidvoidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.xbean.naming.context.NestedContextFactory
createNestedSubcontext, isNestedSubcontext
-
Constructor Details
-
AbstractContext
-
AbstractContext
-
-
Method Details
-
close
- Specified by:
closein 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:
getEnvironmentin interfaceContext- Returns:
- a new (empty) Hashtable
-
addToEnvironment
- Specified by:
addToEnvironmentin interfaceContext- Throws:
NamingException
-
removeFromEnvironment
- Specified by:
removeFromEnvironmentin 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:
getNameInNamespacein 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:
getNameParserin interfaceContext
-
getNameParser
- Specified by:
getNameParserin interfaceContext
-
composeName
- Specified by:
composeNamein interfaceContext- Throws:
NamingException
-
composeName
- Specified by:
composeNamein interfaceContext- Throws:
NamingException
-
lookup
- Specified by:
lookupin interfaceContext- Throws:
NamingException
-
lookup
- Specified by:
lookupin interfaceContext- Throws:
NamingException
-
lookupLink
- Specified by:
lookupLinkin interfaceContext- Throws:
NamingException
-
lookupLink
- Specified by:
lookupLinkin interfaceContext- Throws:
NamingException
-
bind
- Specified by:
bindin interfaceContext- Throws:
NamingException
-
bind
- Specified by:
bindin interfaceContext- Throws:
NamingException
-
rebind
- Specified by:
rebindin interfaceContext- Throws:
NamingException
-
rebind
- Specified by:
rebindin interfaceContext- Throws:
NamingException
-
rename
- Specified by:
renamein interfaceContext- Throws:
NamingException
-
rename
- Specified by:
renamein interfaceContext- Throws:
NamingException
-
unbind
- Specified by:
unbindin interfaceContext- Throws:
NamingException
-
unbind
- Specified by:
unbindin interfaceContext- Throws:
NamingException
-
list
- Throws:
NamingException
-
listBindings
- Throws:
NamingException
-
list
- Specified by:
listin interfaceContext- Throws:
NamingException
-
list
- Specified by:
listin interfaceContext- Throws:
NamingException
-
listBindings
- Specified by:
listBindingsin interfaceContext- Throws:
NamingException
-
listBindings
- Specified by:
listBindingsin interfaceContext- Throws:
NamingException
-
createSubcontext
- Specified by:
createSubcontextin interfaceContext- Throws:
NamingException
-
createSubcontext
- Specified by:
createSubcontextin interfaceContext- Throws:
NamingException
-
destroySubcontext
- Specified by:
destroySubcontextin interfaceContext- Throws:
NamingException
-
destroySubcontext
- Specified by:
destroySubcontextin interfaceContext- Throws:
NamingException
-