com.resilientedge.util.naming
Class DelegatingCtx

java.lang.Object
  |
  +--com.resilientedge.util.naming.AbstractCtx
        |
        +--com.resilientedge.util.naming.DelegatingCtx
All Implemented Interfaces:
javax.naming.Context, ContextAncestors, javax.naming.event.EventContext

public class DelegatingCtx
extends AbstractCtx

DelegatingCtx does not have internal bindings but instead delegates its call to other contexts. It is up to a derived class to create the delegated contexts and initialize this context with them. The subcontext does not extend the namespace. The items in the subcontext are seen as items of this context.

Internally DelegatingCtx maintains two types of bindings. One binding is read-write and is set using setBindingContext .The other contexts are read-only and are set using addOtherContext . This arraingment can cause unusual behavior since a name may be sucessfully retrieved but may not be able to be rebound or renamed. Only bindings that are directly bound to this context can be modified. All others may only be retrieved.

One other side affect of this implementation is that the list methods are attached to the read-write binding only and does not travers the read-only bindings. This may be changed in the future.

Author:
jgardner

Fields inherited from interface javax.naming.event.EventContext
OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
 
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 DelegatingCtx()
          Construct a PreferenceCtx.
  DelegatingCtx(javax.naming.Context bindingContext)
          Construct a PreferenceCtx.
protected DelegatingCtx(javax.naming.Context parent, java.util.Hashtable env)
          Construct a PreferenceCtx with an environment and parent Context.
protected DelegatingCtx(java.util.Hashtable env)
          Construct a PreferenceCtx with an environment.
 
Method Summary
 void addOtherContext(javax.naming.Context ctx)
          Add a read-only delegate Context to this context.
 void addOtherContext(int index, javax.naming.Context ctx)
          Add a read-only delegate Context to this context.
 void bind(javax.naming.Name name, java.lang.Object obj)
           
protected  javax.naming.NameParser getNameParser()
           
 javax.naming.NameParser getNameParser(javax.naming.Name name)
           
 javax.naming.NamingEnumeration list(javax.naming.Name name)
           
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
           
 java.lang.Object lookup(javax.naming.Name name)
          Lookup a name.
 java.lang.Object lookupLink(javax.naming.Name name)
           
 void rebind(javax.naming.Name name, java.lang.Object obj)
           
 void removeOtherContext(javax.naming.Context ctx)
          Remove a read-only delegate Context from this context.
 void rename(javax.naming.Name oldName, javax.naming.Name newName)
           
 void setBindingContext(javax.naming.Context ctx)
          Set the read-write delegate Context to this context.
 void unbind(javax.naming.Name name)
           
 
Methods inherited from class com.resilientedge.util.naming.AbstractCtx
addNamingListener, addNamingListener, addToEnvironment, bind, close, composeName, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, fireObjectChangeEvent, getEnvironment, getNameInNamespace, getNameParser, getParentContext, getRootContext, list, listBindings, lookup, lookupLink, rebind, removeFromEnvironment, removeNamingListener, rename, setParentContext, targetMustExist, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingCtx

public DelegatingCtx(javax.naming.Context bindingContext)
Construct a PreferenceCtx.
Parameters:
bindingContext - Parameter Description

DelegatingCtx

protected DelegatingCtx()
Construct a PreferenceCtx.

DelegatingCtx

protected DelegatingCtx(java.util.Hashtable env)
Construct a PreferenceCtx with an environment.
Parameters:
env - Parameter Description

DelegatingCtx

protected DelegatingCtx(javax.naming.Context parent,
                        java.util.Hashtable env)
Construct a PreferenceCtx with an environment and parent Context.
Parameters:
parent - Parameter Description
env - Parameter Description
Method Detail

setBindingContext

public void setBindingContext(javax.naming.Context ctx)
Set the read-write delegate Context to this context.
Parameters:
ctx - A Context that will be share this naming space.

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Overrides:
getNameParser in class AbstractCtx
Parameters:
name - Parameter Description
Returns:
The NameParser value
Throws:
javax.naming.NamingException - Exception Description

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Lookup a name. If the name is not found in the read-write binding then search the read-only bindings for the same name.
Parameters:
name - Parameter Description
Returns:
Returned Value Description
Throws:
javax.naming.NamingException - Exception Description

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Parameters:
name - Parameter Description
obj - Parameter Description
Throws:
javax.naming.NamingException - Exception Description

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Parameters:
name - Parameter Description
obj - Parameter Description
Throws:
javax.naming.NamingException - Exception Description

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Parameters:
name - Parameter Description
Throws:
javax.naming.NamingException - Exception Description

rename

public void rename(javax.naming.Name oldName,
                   javax.naming.Name newName)
            throws javax.naming.NamingException
Parameters:
oldName - Parameter Description
newName - Parameter Description
Throws:
javax.naming.NamingException - Exception Description

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                    throws javax.naming.NamingException
Parameters:
name - Parameter Description
Returns:
Returned Value Description
Throws:
javax.naming.NamingException - Exception Description

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                            throws javax.naming.NamingException
Parameters:
name - Parameter Description
Returns:
Returned Value Description
Throws:
javax.naming.NamingException - Exception Description

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Parameters:
name - Parameter Description
Returns:
Returned Value Description
Throws:
javax.naming.NamingException - Exception Description

addOtherContext

public void addOtherContext(javax.naming.Context ctx)
Add a read-only delegate Context to this context.
Parameters:
ctx - A Context that will be share this naming space.

addOtherContext

public void addOtherContext(int index,
                            javax.naming.Context ctx)
Add a read-only delegate Context to this context.
Parameters:
ctx - A Context that will be share this naming space.
index - The feature to be added to the OtherContext attribute
Throws:
ArrayIndexOutOfBoundsException -  

removeOtherContext

public void removeOtherContext(javax.naming.Context ctx)
Remove a read-only delegate Context from this context.
Parameters:
ctx - A Context to remove.

getNameParser

protected javax.naming.NameParser getNameParser()
                                         throws javax.naming.NamingException
Overrides:
getNameParser in class AbstractCtx
Returns:
The NameParser value
Throws:
javax.naming.NamingException - Exception Description


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.