org.apache.avalon.excalibur.naming
Class AbstractContext

java.lang.Object
  |
  +--org.apache.avalon.excalibur.naming.AbstractContext
All Implemented Interfaces:
javax.naming.Context
Direct Known Subclasses:
AbstractLocalContext, AbstractURLContext, RemoteContext

public abstract class AbstractContext
extends java.lang.Object
implements javax.naming.Context

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

Version:
$Revision: 1.2 $
Author:
Peter Donald

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

Field Detail

m_environment

protected java.util.Hashtable m_environment
Constructor Detail

AbstractContext

public AbstractContext()

AbstractContext

public AbstractContext(java.util.Hashtable environment)
Method Detail

getNameParser

protected abstract javax.naming.NameParser getNameParser()
                                                  throws javax.naming.NamingException

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String key,
                                         java.lang.Object value)
                                  throws javax.naming.NamingException
Add a key-value pair to environment
Specified by:
addToEnvironment in interface javax.naming.Context
Parameters:
key - the key
value - the value
Returns:
the value

close

public void close()
Release resources associated with context.
Specified by:
close in interface javax.naming.Context

isSelf

protected boolean isSelf(javax.naming.Name name)

bind

public void bind(java.lang.String name,
                 java.lang.Object object)
          throws javax.naming.NamingException
Bind an object to a name.
Specified by:
bind in interface javax.naming.Context
Parameters:
name - the name to bind to
object - the object
Throws:
javax.naming.NamingException - if an error occurs such as bad name or invalid binding

bind

public void bind(javax.naming.Name name,
                 java.lang.Object object)
          throws javax.naming.NamingException
Bind an object to a name.
Specified by:
bind in interface javax.naming.Context
Parameters:
name - the name to bind to
object - the object
Throws:
javax.naming.NamingException - if an error occurs such as bad name or invalid binding

bind

protected abstract void bind(javax.naming.Name name,
                             java.lang.Object object,
                             boolean rebind)
                      throws javax.naming.NamingException
Helper method to bind

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
                             throws javax.naming.NamingException
Compose a name form a name and a prefix.
Specified by:
composeName in interface javax.naming.Context
Parameters:
name - the name
prefix - the prefix
Returns:
the composed name
Throws:
javax.naming.NamingException - if a badly formatted name for context

composeName

public javax.naming.Name composeName(javax.naming.Name name,
                                     javax.naming.Name prefix)
                              throws javax.naming.NamingException
Compose a name form a name and a prefix.
Specified by:
composeName in interface javax.naming.Context
Parameters:
name - the name
prefix - the prefix
Returns:
the composed name
Throws:
javax.naming.NamingException - if a badly formatted name for context

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Create a Subcontext.
Specified by:
createSubcontext in interface javax.naming.Context
Parameters:
name - the name of subcontext
Returns:
the created context
Throws:
javax.naming.NamingException - if an error occurs (ie context exists, badly formated name etc)

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Destroy a Subcontext.
Specified by:
destroySubcontext in interface javax.naming.Context
Parameters:
name - the name of subcontext to destroy
Throws:
javax.naming.NamingException - if an error occurs such as malformed name or context not exiting or not empty

getEnvironment

public java.util.Hashtable getEnvironment()
                                   throws javax.naming.NamingException
Return a copy of environment.
Specified by:
getEnvironment in interface javax.naming.Context
Returns:
the environment

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Get the NameParser for the named context.
Specified by:
getNameParser in interface javax.naming.Context
Parameters:
name -  
Returns:
the NameParser
Throws:
javax.naming.NamingException - if an error occurs

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Get the NameParser for the named context.
Specified by:
getNameParser in interface javax.naming.Context
Parameters:
name -  
Returns:
the NameParser
Throws:
javax.naming.NamingException - if an error occurs

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Enumerates the names bound in the named context, along with the objects bound to them.
Specified by:
list in interface javax.naming.Context
Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
javax.naming.NamingException - if an error occurs

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Enumerates the names bound in the named context, along with the objects bound to them.
Specified by:
listBindings in interface javax.naming.Context
Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
javax.naming.NamingException - if an error occurs

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Get the object named.
Specified by:
lookup in interface javax.naming.Context
Parameters:
name - the name
Returns:
the object
Throws:
javax.naming.NamingException - if an error occurs (ie object name is inavlid or unbound)

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Get the object named following all links.
Specified by:
lookupLink in interface javax.naming.Context
Parameters:
name - the name
Returns:
the object
Throws:
javax.naming.NamingException - if an error occurs (ie object name is inavlid or unbound)

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Get the object named following all links.
Specified by:
lookupLink in interface javax.naming.Context
Parameters:
name - the name
Returns:
the object
Throws:
javax.naming.NamingException - if an error occurs (ie object name is inavlid or unbound)

rebind

public void rebind(java.lang.String name,
                   java.lang.Object object)
            throws javax.naming.NamingException
Binds a name to an object, overwriting any existing binding.
Specified by:
rebind in interface javax.naming.Context
Parameters:
name - the name
object - the object
Throws:
javax.naming.NamingException - if an error occurs

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object object)
            throws javax.naming.NamingException
Binds a name to an object, overwriting any existing binding.
Specified by:
rebind in interface javax.naming.Context
Parameters:
name - the name
object - the object
Throws:
javax.naming.NamingException - if an error occurs

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String key)
                                       throws javax.naming.NamingException
Remove a key-value pair form environment and return it.
Specified by:
removeFromEnvironment in interface javax.naming.Context
Parameters:
key - the key
Returns:
the value

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws javax.naming.NamingException
Rename a already bound object
Specified by:
rename in interface javax.naming.Context
Parameters:
oldName - the old name
newName - the new name
Throws:
javax.naming.NamingException - if an error occurs

rename

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

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Unbind a object from a name.
Specified by:
unbind in interface javax.naming.Context
Parameters:
name - the name
Throws:
javax.naming.NamingException - if an error occurs

getPathName

protected javax.naming.Name getPathName(javax.naming.Name name)
                                 throws javax.naming.NamingException
Get name components minus leaf name component.
Parameters:
name - the name elements leading up to last element
Returns:
the name
Throws:
javax.naming.NamingException - if an error occurs

getLeafName

protected javax.naming.Name getLeafName(javax.naming.Name name)
                                 throws javax.naming.NamingException
Get leaf name component from specified Name object.
Parameters:
name - a value of type 'Name'
Returns:
a value of type 'Name'
Throws:
javax.naming.NamingException - if an error occurs


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.