org.osjava.sj.jndi
Class AbstractContext

java.lang.Object
  extended by org.osjava.sj.jndi.AbstractContext
All Implemented Interfaces:
Cloneable, Context
Direct Known Subclasses:
MemoryContext

public abstract class AbstractContext
extends Object
implements Cloneable, Context

The heart of the system, the abstract implementation of context for simple-jndi. There are no abstract methods in this class, but it is not meant to be instantiated, but extended instead.

Since:
Simple-JNDI 0.11
Version:
$Rev: 2684 $ $Date: 2008-05-24 22:19:06 -0700 (Sat, 24 May 2008) $
Author:
Robert M. Zigweid

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
protected AbstractContext()
          Creates a AbstractContext.
protected AbstractContext(AbstractContext that)
          Create a new context based upon the environment of the passed context.
protected AbstractContext(boolean systemOverride)
          Creates a AbstractContext.
protected AbstractContext(boolean systemOverride, NameParser parser)
          Creates a AbstractContext.
protected AbstractContext(Hashtable env)
          Creates a AbstractContext.
protected AbstractContext(Hashtable env, boolean systemOverride)
          Creates a AbstractContext.
protected AbstractContext(Hashtable env, boolean systemOverride, NameParser parser)
          Creates a AbstractContext.
protected AbstractContext(Hashtable env, NameParser parser)
          Creates a AbstractContext.
protected AbstractContext(NameParser parser)
          Creates a AbstractContext.
 
Method Summary
 Object addToEnvironment(String name, Object object)
           
 void bind(Name name, Object object)
           
 void bind(String name, Object object)
           
 void close()
           
 Name composeName(Name name, Name prefix)
           
 String composeName(String name, String prefix)
           
abstract  Context createSubcontext(Name name)
           
 Context createSubcontext(String name)
           
 void destroySubcontext(Name name)
           
 void destroySubcontext(String name)
           
 Hashtable getEnvironment()
           
 String getNameInNamespace()
           
 NameParser getNameParser(Name name)
           
 NameParser getNameParser(String name)
           
protected  Hashtable getSubContexts()
          Convenience method returning the subcontexts that this context parents.
 boolean isEmpty()
          Determine whether or not the context is empty.
static boolean isSharedAndLoaded()
          Whether this context is running in shared mode AND has already been loaded with data.
 NamingEnumeration list(Name name)
           
 NamingEnumeration list(String name)
           
 NamingEnumeration listBindings(Name name)
           
 NamingEnumeration listBindings(String name)
           
 Object lookup(Name name)
          Return the named object.
 Object lookup(String name)
           
 Object lookupLink(Name name)
           
 Object lookupLink(String name)
           
 void rebind(Name name, Object object)
           
 void rebind(String name, Object object)
           
 Object removeFromEnvironment(String name)
           
 void rename(Name oldName, Name newName)
           
 void rename(String oldName, String newName)
           
 void setNameInNamespace(Name name)
          Set the name of the Context.
protected  void setNameInNamespace(String name)
          Set the name of the Context.
 void unbind(Name name)
           
 void unbind(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractContext

protected AbstractContext()
Creates a AbstractContext.


AbstractContext

protected AbstractContext(Hashtable env)
Creates a AbstractContext.

Parameters:
env - a Hashtable containing the Context's environemnt.

AbstractContext

protected AbstractContext(Hashtable env,
                          boolean systemOverride)
Creates a AbstractContext.

Parameters:
env - a Hashtable containing the Context's environment.
systemOverride - allow System Parameters to override the environment that is passed in.

AbstractContext

protected AbstractContext(Hashtable env,
                          NameParser parser)
Creates a AbstractContext.

Parameters:
env - a Hashtable containing the Context's environment.
parser - the NameParser being used by the Context.

AbstractContext

protected AbstractContext(boolean systemOverride)
Creates a AbstractContext.

Parameters:
systemOverride - allow System Parameters to override the environment that is passed in.

AbstractContext

protected AbstractContext(boolean systemOverride,
                          NameParser parser)
Creates a AbstractContext.

Parameters:
systemOverride - allow System Parameters to override the environment that is passed in.
parser - the NameParser being used by the Context.

AbstractContext

protected AbstractContext(NameParser parser)
Creates a AbstractContext.

Parameters:
parser - the NameParser being used by the Context.

AbstractContext

protected AbstractContext(Hashtable env,
                          boolean systemOverride,
                          NameParser parser)
Creates a AbstractContext.

Parameters:
env - a Hashtable containing the Context's environment.
systemOverride - allow System Parameters to override the environment that is passed in.
parser - the NameParser being used by the Context.

AbstractContext

protected AbstractContext(AbstractContext that)
Create a new context based upon the environment of the passed context.

Parameters:
that -
Method Detail

lookup

public Object lookup(Name name)
              throws NamingException
Return the named object. This implementation looks for things in the following order:
  1. The empty element to duplicate the context.
  2. A named object in the environment.
  3. A named object in the Context's store
  4. A named sub-Context of this Context
Unlike many implementations of the JNDI specification, this implementation returns null when a name is not found, rather than throwing an exception. The specification does not appear to state which way it should be.

Specified by:
lookup in interface Context
Throws:
NamingException
See Also:
Context.lookup(javax.naming.Name)

lookup

public Object lookup(String name)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException
See Also:
Context.lookup(java.lang.String)

bind

public void bind(Name name,
                 Object object)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException
See Also:
Context.bind(javax.naming.Name, java.lang.Object)

bind

public void bind(String name,
                 Object object)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException
See Also:
Context.bind(java.lang.String, java.lang.Object)

rebind

public void rebind(Name name,
                   Object object)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException
See Also:
Context.rebind(javax.naming.Name, java.lang.Object)

rebind

public void rebind(String name,
                   Object object)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException
See Also:
Context.rebind(java.lang.String, java.lang.Object)

unbind

public void unbind(Name name)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException
See Also:
Context.unbind(javax.naming.Name)

unbind

public void unbind(String name)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException
See Also:
Context.unbind(java.lang.String)

rename

public void rename(Name oldName,
                   Name newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException
See Also:
Context.rename(javax.naming.Name, javax.naming.Name)

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException
See Also:
Context.rename(java.lang.String, java.lang.String)

list

public NamingEnumeration list(Name name)
                       throws NamingException
Specified by:
list in interface Context
Throws:
NamingException
See Also:
Context.list(javax.naming.Name)

list

public NamingEnumeration list(String name)
                       throws NamingException
Specified by:
list in interface Context
Throws:
NamingException
See Also:
Context.list(java.lang.String)

listBindings

public NamingEnumeration listBindings(Name name)
                               throws NamingException
Specified by:
listBindings in interface Context
Throws:
NamingException
See Also:
Context.listBindings(javax.naming.Name)

listBindings

public NamingEnumeration listBindings(String name)
                               throws NamingException
Specified by:
listBindings in interface Context
Throws:
NamingException
See Also:
Context.listBindings(java.lang.String)

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException
See Also:
Context.destroySubcontext(javax.naming.Name)

destroySubcontext

public void destroySubcontext(String name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException
See Also:
Context.destroySubcontext(java.lang.String)

createSubcontext

public abstract Context createSubcontext(Name name)
                                  throws NamingException
Specified by:
createSubcontext in interface Context
Throws:
NamingException
See Also:
Context.createSubcontext(javax.naming.Name)

createSubcontext

public Context createSubcontext(String name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
Throws:
NamingException
See Also:
Context.createSubcontext(java.lang.String)

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException
See Also:
Context.lookupLink(javax.naming.Name)

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException
See Also:
Context.lookupLink(java.lang.String)

getNameParser

public NameParser getNameParser(Name name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException
See Also:
Context.getNameParser(javax.naming.Name)

getNameParser

public NameParser getNameParser(String name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException
See Also:
Context.getNameParser(java.lang.String)

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Specified by:
composeName in interface Context
Throws:
NamingException
See Also:
Context.composeName(javax.naming.Name, javax.naming.Name)

composeName

public String composeName(String name,
                          String prefix)
                   throws NamingException
Specified by:
composeName in interface Context
Throws:
NamingException
See Also:
Context.composeName(java.lang.String, java.lang.String)

addToEnvironment

public Object addToEnvironment(String name,
                               Object object)
                        throws NamingException
Specified by:
addToEnvironment in interface Context
Throws:
NamingException
See Also:
Context.addToEnvironment(java.lang.String, java.lang.Object)

removeFromEnvironment

public Object removeFromEnvironment(String name)
                             throws NamingException
Specified by:
removeFromEnvironment in interface Context
Throws:
NamingException
See Also:
Context.removeFromEnvironment(java.lang.String)

getEnvironment

public Hashtable getEnvironment()
                         throws NamingException
Specified by:
getEnvironment in interface Context
Throws:
NamingException
See Also:
Context.getEnvironment()

close

public void close()
           throws NamingException
Specified by:
close in interface Context
Throws:
NamingException
See Also:
Context.close()

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Specified by:
getNameInNamespace in interface Context
Throws:
NamingException
See Also:
Context.getNameInNamespace()

isEmpty

public boolean isEmpty()
Determine whether or not the context is empty. Objects bound directly to the context or subcontexts are all that is considered. The environment of the context is not considered.

Returns:
true of the context is empty, else false.

setNameInNamespace

public void setNameInNamespace(Name name)
                        throws NamingException
Set the name of the Context. This is only used from createSubcontext. It might get replaced by adding more constructors, but there is really no reason to expose it publicly anyway.

Parameters:
name - the Name of the context.
Throws:
NamingException - if the subContext already has a name.

setNameInNamespace

protected void setNameInNamespace(String name)
                           throws NamingException
Set the name of the Context. This is only used from createSubcontext. It might get replaced by adding more constructors, but there is really no reason to expose it publicly anyway.

Parameters:
name - a String representation of the Name of the context.
Throws:
NamingException - if the subContext already has a name.

getSubContexts

protected Hashtable getSubContexts()
Convenience method returning the subcontexts that this context parents.

Returns:
a Hashtable of context objects that are parented by this context.

isSharedAndLoaded

public static boolean isSharedAndLoaded()
Whether this context is running in shared mode AND has already been loaded with data.



Copyright © 2003-2008 OSJava. All Rights Reserved.