Package org.apache.xbean.naming.context
Class AbstractContext
- java.lang.Object
-
- org.apache.xbean.naming.context.AbstractContext
-
- All Implemented Interfaces:
java.io.Serializable,javax.naming.Context,NestedContextFactory
- Direct Known Subclasses:
AbstractFederatedContext,ImmutableContext,ImmutableContext.NestedImmutableContext
public abstract class AbstractContext extends java.lang.Object implements javax.naming.Context, NestedContextFactory, java.io.Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractContext(java.lang.String nameInNamespace)AbstractContext(java.lang.String nameInNamespace, ContextAccess contextAccess)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleanaddBinding(java.lang.String name, java.lang.Object value, boolean rebind)protected voidaddBinding(javax.naming.Context context, java.lang.String name, java.lang.Object value, boolean rebind)Binds the specified value to the specified name within the specified context.protected voidaddDeepBinding(javax.naming.Name name, java.lang.Object value, boolean rebind, boolean createIntermediateContexts)java.lang.ObjectaddToEnvironment(java.lang.String propName, java.lang.Object propVal)voidbind(java.lang.String name, java.lang.Object obj)voidbind(javax.naming.Name name, java.lang.Object obj)voidclose()java.lang.StringcomposeName(java.lang.String name, java.lang.String prefix)javax.naming.NamecomposeName(javax.naming.Name name, javax.naming.Name prefix)javax.naming.ContextcreateSubcontext(java.lang.String name)javax.naming.ContextcreateSubcontext(javax.naming.Name name)protected javax.naming.ContextcreateSubcontextTree(java.lang.String path, javax.naming.Name name, java.lang.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(java.lang.String name)voiddestroySubcontext(javax.naming.Name name)protected java.lang.ObjectfaultLookup(java.lang.String stringName, javax.naming.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 java.lang.ObjectgetBinding(java.lang.String name)Gets the object bound to the name.protected abstract java.util.Map<java.lang.String,java.lang.Object>getBindings()Gets a map of the bindings for the current node (i.e., no names with slashes).protected ContextAccessgetContextAccess()protected java.lang.ObjectgetDeepBinding(java.lang.String name)Gets the object bound to the name.java.util.HashtablegetEnvironment()Always returns a new (empty) Hashtable.java.lang.StringgetNameInNamespace()Gets the name of this context withing the global namespace.protected java.lang.StringgetNameInNamespace(java.lang.String path)Gets the name of a path withing the global namespace context.protected javax.naming.NamegetNameInNamespace(javax.naming.Name path)Gets the name of a path withing the global namespace context.protected javax.naming.NameParsergetNameParser()A parser that can turn Strings into javax.naming.Name objects.javax.naming.NameParsergetNameParser(java.lang.String name)javax.naming.NameParsergetNameParser(javax.naming.Name name)protected javax.naming.NamegetParsedNameInNamespace()Gets the name of this context withing the global namespace.protected static intgetSize(javax.naming.Context context)protected static booleanisEmpty(javax.naming.Context context)protected javax.naming.NamingEnumeration<javax.naming.NameClassPair>list()javax.naming.NamingEnumeration<javax.naming.NameClassPair>list(java.lang.String name)javax.naming.NamingEnumeration<javax.naming.NameClassPair>list(javax.naming.Name name)protected javax.naming.NamingEnumeration<javax.naming.Binding>listBindings()javax.naming.NamingEnumeration<javax.naming.Binding>listBindings(java.lang.String name)javax.naming.NamingEnumeration<javax.naming.Binding>listBindings(javax.naming.Name name)java.lang.Objectlookup(java.lang.String name)protected java.lang.Objectlookup(java.lang.String stringName, javax.naming.Name parsedName)Finds the specified entry.java.lang.Objectlookup(javax.naming.Name name)protected javax.naming.ContextlookupFinalContext(javax.naming.Name name)java.lang.ObjectlookupLink(java.lang.String name)java.lang.ObjectlookupLink(javax.naming.Name name)voidrebind(java.lang.String name, java.lang.Object obj)voidrebind(javax.naming.Name name, java.lang.Object obj)protected abstract booleanremoveBinding(java.lang.String name, boolean removeNotEmptyContext)Removes the binding from the context.protected voidremoveDeepBinding(javax.naming.Name name, boolean pruneEmptyContexts)protected voidremoveDeepBinding(javax.naming.Name name, boolean pruneEmptyContexts, boolean removeNotEmptyContext)java.lang.ObjectremoveFromEnvironment(java.lang.String propName)voidrename(java.lang.String oldName, java.lang.String newName)voidrename(javax.naming.Name oldName, javax.naming.Name newName)voidunbind(java.lang.String name)voidunbind(javax.naming.Name name)-
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 Detail
-
AbstractContext
protected AbstractContext(java.lang.String nameInNamespace)
-
AbstractContext
public AbstractContext(java.lang.String nameInNamespace, ContextAccess contextAccess)
-
-
Method Detail
-
close
public void close() throws javax.naming.NamingException- Specified by:
closein interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
getContextAccess
protected ContextAccess getContextAccess()
-
getDeepBinding
protected java.lang.Object getDeepBinding(java.lang.String name)
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
protected java.lang.Object getBinding(java.lang.String name) throws javax.naming.NamingExceptionGets 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:
javax.naming.NamingException- on error
-
lookup
protected java.lang.Object lookup(java.lang.String stringName, javax.naming.Name parsedName) throws javax.naming.NamingExceptionFinds 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:
javax.naming.NamingException- if no value is bound to that name or if a problem occurs during the lookup
-
faultLookup
protected java.lang.Object faultLookup(java.lang.String stringName, javax.naming.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.- 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
protected javax.naming.Context lookupFinalContext(javax.naming.Name name) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
getBindings
protected abstract java.util.Map<java.lang.String,java.lang.Object> getBindings() throws javax.naming.NamingExceptionGets 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:
javax.naming.NamingException- if a problem occurs while getting the bindigns
-
addDeepBinding
protected void addDeepBinding(javax.naming.Name name, java.lang.Object value, boolean rebind, boolean createIntermediateContexts) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
addBinding
protected void addBinding(javax.naming.Context context, java.lang.String name, java.lang.Object value, boolean rebind) throws javax.naming.NamingExceptionBinds 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:
javax.naming.NamingException- if a problem occurs while (re)binding
-
addBinding
protected abstract boolean addBinding(java.lang.String name, java.lang.Object value, boolean rebind) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
createSubcontextTree
protected javax.naming.Context createSubcontextTree(java.lang.String path, javax.naming.Name name, java.lang.Object value) throws javax.naming.NamingExceptionCreates 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:
javax.naming.NamingException- if a problem occurs while creating the subcontext tree
-
removeBinding
protected abstract boolean removeBinding(java.lang.String name, boolean removeNotEmptyContext) throws javax.naming.NamingExceptionRemoves 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:
javax.naming.NamingException- if a problem occurs during the bind such as a value already being bound
-
removeDeepBinding
protected void removeDeepBinding(javax.naming.Name name, boolean pruneEmptyContexts) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
removeDeepBinding
protected void removeDeepBinding(javax.naming.Name name, boolean pruneEmptyContexts, boolean removeNotEmptyContext) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
isEmpty
protected static boolean isEmpty(javax.naming.Context context) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
getSize
protected static int getSize(javax.naming.Context context) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
getEnvironment
public java.util.Hashtable getEnvironment()
Always returns a new (empty) Hashtable.- Specified by:
getEnvironmentin interfacejavax.naming.Context- Returns:
- a new (empty) Hashtable
-
addToEnvironment
public java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal) throws javax.naming.NamingException- Specified by:
addToEnvironmentin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
removeFromEnvironment
public java.lang.Object removeFromEnvironment(java.lang.String propName) throws javax.naming.NamingException- Specified by:
removeFromEnvironmentin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
getNameInNamespace
public java.lang.String 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 interfacejavax.naming.Context- Returns:
- the name of this context within the global namespace or null if unknown.
-
getParsedNameInNamespace
protected javax.naming.Name 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
protected java.lang.String getNameInNamespace(java.lang.String path)
Gets the name of a path withing the global namespace context.- Parameters:
path- path to extend- Returns:
- full path in namespace
-
getNameInNamespace
protected javax.naming.Name getNameInNamespace(javax.naming.Name path) throws javax.naming.NamingExceptionGets the name of a path withing the global namespace context.- Parameters:
path- path to extend- Returns:
- full path in namespace
- Throws:
javax.naming.NamingException- on error
-
getNameParser
protected javax.naming.NameParser getNameParser()
A parser that can turn Strings into javax.naming.Name objects.- Returns:
- ContextUtil.NAME_PARSER
-
getNameParser
public javax.naming.NameParser getNameParser(javax.naming.Name name)
- Specified by:
getNameParserin interfacejavax.naming.Context
-
getNameParser
public javax.naming.NameParser getNameParser(java.lang.String name)
- Specified by:
getNameParserin interfacejavax.naming.Context
-
composeName
public javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix) throws javax.naming.NamingException- Specified by:
composeNamein interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
composeName
public java.lang.String composeName(java.lang.String name, java.lang.String prefix) throws javax.naming.NamingException- Specified by:
composeNamein interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
lookup
public java.lang.Object lookup(java.lang.String name) throws javax.naming.NamingException- Specified by:
lookupin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
lookup
public java.lang.Object lookup(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
lookupin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
lookupLink
public java.lang.Object lookupLink(java.lang.String name) throws javax.naming.NamingException- Specified by:
lookupLinkin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
lookupLink
public java.lang.Object lookupLink(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
lookupLinkin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
bind
public void bind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException- Specified by:
bindin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
bind
public void bind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException- Specified by:
bindin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
rebind
public void rebind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException- Specified by:
rebindin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
rebind
public void rebind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException- Specified by:
rebindin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
rename
public void rename(java.lang.String oldName, java.lang.String newName) throws javax.naming.NamingException- Specified by:
renamein interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
rename
public void rename(javax.naming.Name oldName, javax.naming.Name newName) throws javax.naming.NamingException- Specified by:
renamein interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
unbind
public void unbind(java.lang.String name) throws javax.naming.NamingException- Specified by:
unbindin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
unbind
public void unbind(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
unbindin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
list
protected javax.naming.NamingEnumeration<javax.naming.NameClassPair> list() throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
listBindings
protected javax.naming.NamingEnumeration<javax.naming.Binding> listBindings() throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
list
public javax.naming.NamingEnumeration<javax.naming.NameClassPair> list(java.lang.String name) throws javax.naming.NamingException- Specified by:
listin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
list
public javax.naming.NamingEnumeration<javax.naming.NameClassPair> list(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
listin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
listBindings
public javax.naming.NamingEnumeration<javax.naming.Binding> listBindings(java.lang.String name) throws javax.naming.NamingException- Specified by:
listBindingsin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
listBindings
public javax.naming.NamingEnumeration<javax.naming.Binding> listBindings(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
listBindingsin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
createSubcontext
public javax.naming.Context createSubcontext(java.lang.String name) throws javax.naming.NamingException- Specified by:
createSubcontextin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
createSubcontext
public javax.naming.Context createSubcontext(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
createSubcontextin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
destroySubcontext
public void destroySubcontext(java.lang.String name) throws javax.naming.NamingException- Specified by:
destroySubcontextin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
destroySubcontext
public void destroySubcontext(javax.naming.Name name) throws javax.naming.NamingException- Specified by:
destroySubcontextin interfacejavax.naming.Context- Throws:
javax.naming.NamingException
-
-