org.codehaus.spice.jndikit
Class AbstractLocalContext

java.lang.Object
  extended by org.codehaus.spice.jndikit.AbstractContext
      extended by org.codehaus.spice.jndikit.AbstractLocalContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
MemoryContext

public abstract class AbstractLocalContext
extends AbstractContext

Abstract local JNDI Context that can be inherited from to provide a particular type of Context. These contexts are assumed to be on the same machine.

Version:
$Revision: 1.1 $
Author:
Peter Donald

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
AbstractLocalContext(Namespace namespace, Hashtable environment, Context parent)
           
 
Method Summary
protected  void bind(Name name, Object object, boolean rebind)
          Helper method to bind
protected  void checkUnbindContext(Name name, Object entry)
           
protected abstract  Context cloneContext()
           
 void close()
          Release resources associated with context.
 Context createSubcontext(Name name)
          Create a Subcontext.
 void destroySubcontext(Name name)
           
protected abstract  void doLocalBind(Name name, Object object)
           
protected abstract  NamingEnumeration doLocalList()
           
protected abstract  NamingEnumeration doLocalListBindings()
           
protected abstract  Object doLocalLookup(Name name)
          Actually lookup raw entry in local context.
protected abstract  void doLocalUnbind(Name name)
          Actually unbind raw entry in local context.
 String getNameInNamespace()
           
protected  NameParser getNameParser()
           
protected  Namespace getNamespace()
          Utility method to retrieve the Namespace.
protected  Context getParent()
          Utility method to retrieve parent Context.
protected  boolean isDestroyableContext(Object object)
           
 NamingEnumeration list(Name name)
          Enumerates the names bound in the named context.
 NamingEnumeration listBindings(Name name)
          Enumerates the names bound in the named context, along with the objects bound to them.
protected  Object localLookup(Name name)
          Lookup entry in local context.
 Object lookup(Name name)
          Get the object named.
protected  Context lookupSubContext(Name name)
          Lookup a sub-context of current context.
protected abstract  Context newContext()
           
 void unbind(Name name)
          Unbind a object from a name.
 
Methods inherited from class org.codehaus.spice.jndikit.AbstractContext
addToEnvironment, bind, bind, composeName, composeName, createSubcontext, destroySubcontext, getEnvironment, getLeafName, getNameParser, getNameParser, getPathName, getRawEnvironment, isSelf, list, listBindings, lookup, lookupLink, lookupLink, rebind, rebind, removeFromEnvironment, rename, rename, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLocalContext

public AbstractLocalContext(Namespace namespace,
                            Hashtable environment,
                            Context parent)
Method Detail

getParent

protected final Context getParent()
Utility method to retrieve parent Context.

Returns:
the parent Context if any

getNamespace

protected final Namespace getNamespace()
Utility method to retrieve the Namespace.

Returns:
the Namespace

isDestroyableContext

protected boolean isDestroyableContext(Object object)
                                throws NamingException
Throws:
NamingException

newContext

protected abstract Context newContext()
                               throws NamingException
Throws:
NamingException

cloneContext

protected abstract Context cloneContext()
                                 throws NamingException
Throws:
NamingException

bind

protected void bind(Name name,
                    Object object,
                    boolean rebind)
             throws NamingException
Helper method to bind

Specified by:
bind in class AbstractContext
Throws:
NamingException

doLocalBind

protected abstract void doLocalBind(Name name,
                                    Object object)
                             throws NamingException
Throws:
NamingException

close

public void close()
Description copied from class: AbstractContext
Release resources associated with context.

Specified by:
close in interface Context
Overrides:
close in class AbstractContext

createSubcontext

public Context createSubcontext(Name name)
                         throws NamingException
Create a Subcontext.

Parameters:
name - the name of subcontext
Returns:
the created context
Throws:
NamingException - if an error occurs (ie context exists, badly formated name etc)

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Throws:
NamingException

checkUnbindContext

protected void checkUnbindContext(Name name,
                                  Object entry)
                           throws NamingException
Throws:
NamingException

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Throws:
NamingException

getNameParser

protected NameParser getNameParser()
                            throws NamingException
Specified by:
getNameParser in class AbstractContext
Throws:
NamingException

list

public NamingEnumeration list(Name name)
                       throws NamingException
Enumerates the names bound in the named context.

Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
NamingException - if an error occurs

doLocalList

protected abstract NamingEnumeration doLocalList()
                                          throws NamingException
Throws:
NamingException

doLocalListBindings

protected abstract NamingEnumeration doLocalListBindings()
                                                  throws NamingException
Throws:
NamingException

listBindings

public NamingEnumeration listBindings(Name name)
                               throws NamingException
Enumerates the names bound in the named context, along with the objects bound to them.

Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
NamingException - if an error occurs

lookup

public Object lookup(Name name)
              throws NamingException
Get the object named.

Parameters:
name - the name
Returns:
the object
Throws:
NamingException - if an error occurs (ie object name is inavlid or unbound)

localLookup

protected Object localLookup(Name name)
                      throws NamingException
Lookup entry in local context.

Parameters:
name - the name in local context (size() == 1)
Returns:
the bound object
Throws:
NamingException - if an error occurs

doLocalLookup

protected abstract Object doLocalLookup(Name name)
                                 throws NamingException
Actually lookup raw entry in local context. When overidding this it is not neccesary to resolve references etc.

Parameters:
name - the name in local context (size() == 1)
Returns:
the bound object
Throws:
NamingException - if an error occurs

lookupSubContext

protected Context lookupSubContext(Name name)
                            throws NamingException
Lookup a sub-context of current context. Note that name must have 1 or more elements.

Parameters:
name - the name of subcontext
Returns:
the sub-Context
Throws:
NamingException - if an error occurs (like named entry is not a Context)

unbind

public void unbind(Name name)
            throws NamingException
Unbind a object from a name.

Parameters:
name - the name
Throws:
NamingException - if an error occurs

doLocalUnbind

protected abstract void doLocalUnbind(Name name)
                               throws NamingException
Actually unbind raw entry in local context.

Parameters:
name - the name in local context (size() == 1)
Throws:
NamingException - if an error occurs


Copyright © 1999-2008 Codehaus. All Rights Reserved.