org.codehaus.spice.jndikit
Class AbstractContext

java.lang.Object
  extended byorg.codehaus.spice.jndikit.AbstractContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
AbstractLocalContext, AbstractURLContext, RemoteContext

public abstract class AbstractContext
extends Object
implements Context

Abstract JNDI Context that can be inherited from to provide a particular type of Context.

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
AbstractContext()
           
AbstractContext(Hashtable environment)
           
 
Method Summary
 Object addToEnvironment(String key, Object value)
          Add a key-value pair to environment
 void bind(Name name, Object object)
          Bind an object to a name.
protected abstract  void bind(Name name, Object object, boolean rebind)
          Helper method to bind
 void bind(String name, Object object)
          Bind an object to a name.
 void close()
          Release resources associated with context.
 Name composeName(Name name, Name prefix)
          Compose a name form a name and a prefix.
 String composeName(String name, String prefix)
          Compose a name form a name and a prefix.
 Context createSubcontext(String name)
          Create a Subcontext.
 void destroySubcontext(String name)
          Destroy a Subcontext.
 Hashtable getEnvironment()
          Return a copy of environment.
protected  Name getLeafName(Name name)
          Get leaf name component from specified Name object.
protected abstract  NameParser getNameParser()
           
 NameParser getNameParser(Name name)
          Get the NameParser for the named context.
 NameParser getNameParser(String name)
          Get the NameParser for the named context.
protected  Name getPathName(Name name)
          Get name components minus leaf name component.
protected  Hashtable getRawEnvironment()
          Utility method to retrieve raw environment value.
protected  boolean isSelf(Name name)
           
 NamingEnumeration list(String name)
          Enumerates the names bound in the named context, along with the objects bound to them.
 NamingEnumeration listBindings(String name)
          Enumerates the names bound in the named context, along with the objects bound to them.
 Object lookup(String name)
          Get the object named.
 Object lookupLink(Name name)
          Get the object named following all links.
 Object lookupLink(String name)
          Get the object named following all links.
 void rebind(Name name, Object object)
          Binds a name to an object, overwriting any existing binding.
 void rebind(String name, Object object)
          Binds a name to an object, overwriting any existing binding.
 Object removeFromEnvironment(String key)
          Remove a key-value pair form environment and return it.
 void rename(Name oldName, Name newName)
           
 void rename(String oldName, String newName)
          Rename a already bound object
 void unbind(String name)
          Unbind a object from a name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.naming.Context
createSubcontext, destroySubcontext, getNameInNamespace, list, listBindings, lookup, unbind
 

Constructor Detail

AbstractContext

public AbstractContext()

AbstractContext

public AbstractContext(Hashtable environment)
Method Detail

getNameParser

protected abstract NameParser getNameParser()
                                     throws NamingException
Throws:
NamingException

addToEnvironment

public Object addToEnvironment(String key,
                               Object value)
                        throws NamingException
Add a key-value pair to environment

Specified by:
addToEnvironment in interface Context
Parameters:
key - the key
value - the value
Returns:
the value
Throws:
NamingException

close

public void close()
Release resources associated with context.

Specified by:
close in interface Context

isSelf

protected boolean isSelf(Name name)

bind

public void bind(String name,
                 Object object)
          throws NamingException
Bind an object to a name.

Specified by:
bind in interface Context
Parameters:
name - the name to bind to
object - the object
Throws:
NamingException - if an error occurs such as bad name or invalid binding

bind

public void bind(Name name,
                 Object object)
          throws NamingException
Bind an object to a name.

Specified by:
bind in interface Context
Parameters:
name - the name to bind to
object - the object
Throws:
NamingException - if an error occurs such as bad name or invalid binding

bind

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

Throws:
NamingException

composeName

public String composeName(String name,
                          String prefix)
                   throws NamingException
Compose a name form a name and a prefix.

Specified by:
composeName in interface Context
Parameters:
name - the name
prefix - the prefix
Returns:
the composed name
Throws:
NamingException - if a badly formatted name for context

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Compose a name form a name and a prefix.

Specified by:
composeName in interface Context
Parameters:
name - the name
prefix - the prefix
Returns:
the composed name
Throws:
NamingException - if a badly formatted name for context

createSubcontext

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

Specified by:
createSubcontext in interface Context
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(String name)
                       throws NamingException
Destroy a Subcontext.

Specified by:
destroySubcontext in interface Context
Parameters:
name - the name of subcontext to destroy
Throws:
NamingException - if an error occurs such as malformed name or context not exiting or not empty

getEnvironment

public Hashtable getEnvironment()
                         throws NamingException
Return a copy of environment.

Specified by:
getEnvironment in interface Context
Returns:
the environment
Throws:
NamingException

getNameParser

public NameParser getNameParser(String name)
                         throws NamingException
Get the NameParser for the named context.

Specified by:
getNameParser in interface Context
Parameters:
name -
Returns:
the NameParser
Throws:
NamingException - if an error occurs

getNameParser

public NameParser getNameParser(Name name)
                         throws NamingException
Get the NameParser for the named context.

Specified by:
getNameParser in interface Context
Parameters:
name -
Returns:
the NameParser
Throws:
NamingException - if an error occurs

list

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

Specified by:
list in interface Context
Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
NamingException - if an error occurs

listBindings

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

Specified by:
listBindings in interface Context
Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
NamingException - if an error occurs

lookup

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

Specified by:
lookup in interface Context
Parameters:
name - the name
Returns:
the object
Throws:
NamingException - if an error occurs (ie object name is inavlid or unbound)

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Get the object named following all links.

Specified by:
lookupLink in interface Context
Parameters:
name - the name
Returns:
the object
Throws:
NamingException - if an error occurs (ie object name is inavlid or unbound)

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Get the object named following all links.

Specified by:
lookupLink in interface Context
Parameters:
name - the name
Returns:
the object
Throws:
NamingException - if an error occurs (ie object name is inavlid or unbound)

rebind

public void rebind(String name,
                   Object object)
            throws NamingException
Binds a name to an object, overwriting any existing binding.

Specified by:
rebind in interface Context
Parameters:
name - the name
object - the object
Throws:
NamingException - if an error occurs

rebind

public void rebind(Name name,
                   Object object)
            throws NamingException
Binds a name to an object, overwriting any existing binding.

Specified by:
rebind in interface Context
Parameters:
name - the name
object - the object
Throws:
NamingException - if an error occurs

removeFromEnvironment

public Object removeFromEnvironment(String key)
                             throws NamingException
Remove a key-value pair form environment and return it.

Specified by:
removeFromEnvironment in interface Context
Parameters:
key - the key
Returns:
the value
Throws:
NamingException

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Rename a already bound object

Specified by:
rename in interface Context
Parameters:
oldName - the old name
newName - the new name
Throws:
NamingException - if an error occurs

rename

public void rename(Name oldName,
                   Name newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException

unbind

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

Specified by:
unbind in interface Context
Parameters:
name - the name
Throws:
NamingException - if an error occurs

getRawEnvironment

protected final Hashtable getRawEnvironment()
Utility method to retrieve raw environment value. This means that null will be returned if the value is null.

Returns:
the environment hashtable or null

getPathName

protected Name getPathName(Name name)
                    throws NamingException
Get name components minus leaf name component.

Parameters:
name - the name elements leading up to last element
Returns:
the name
Throws:
NamingException - if an error occurs

getLeafName

protected Name getLeafName(Name name)
                    throws NamingException
Get leaf name component from specified Name object.

Parameters:
name - the name to retrieve leaf from
Returns:
the leaf name component
Throws:
NamingException - if an error occurs


Copyright © 1999-2007 Codehaus. All Rights Reserved.