net.larsan.urd.jndi
Class ContextBase

java.lang.Object
  |
  +--net.larsan.urd.jndi.ContextBase
All Implemented Interfaces:
javax.naming.Context, javax.naming.event.EventContext
Direct Known Subclasses:
ContextImpl

public abstract class ContextBase
extends java.lang.Object
implements javax.naming.event.EventContext

Abstract base class for the Urd JNDI context. This class does the following:

This class can use the following variables:
      ContextBase.ROOT_ADDRESS - which should point to the root address
      Contextbase.ROOT_PORT - root address port number
 
If the environment variable above is missing in the context environment the context will asume the default values localhost and 8666.

So far we don't support multiple namespaces so the URL support in this class is trivial. It only checks that the URL in question is referring to the current root context, then strips away host information and works on the remaining path.

Public non-delegated mehtods of class are subject to a permission check using a AccessPermission. This permission should be granted to the framework but not the services.

Event handlers set on a context automaticly propragates up to its subcontext. And any subcontext will inherit an eventual event handler from its parent on creation.

This context only handles NamespaceChangeListeners.

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Field Summary
protected static AccessPermission ACCESS_PERMISSION
           
protected  java.util.Hashtable env
           
protected  EventHandler handler
           
protected  java.lang.String localName
           
protected static javax.naming.NameParser nameParser
           
protected  ContextBase parent
           
protected  int port
           
protected  java.lang.String root
           
static java.lang.String ROOT_ADDRESS
           
static java.lang.String ROOT_PORT
           
 
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
ContextBase(ContextBase parent, java.util.Hashtable env, java.lang.String localName)
           
 
Method Summary
 void addNamingListener(javax.naming.Name name, int scope, javax.naming.event.NamingListener listener)
           
 void addNamingListener(java.lang.String name, int scope, javax.naming.event.NamingListener listener)
           
 java.lang.Object addToEnvironment(java.lang.String name, java.lang.Object object)
          Add to environment
 void bind(java.lang.String name, java.lang.Object object)
           
protected  void checkAccess()
          Check access permission.
 void close()
          Deregister event handler
 java.lang.String composeName(java.lang.String nameOne, java.lang.String nameTwo)
           
 javax.naming.Context createSubcontext(java.lang.String name)
           
 void destroySubcontext(java.lang.String name)
           
protected  javax.naming.Context findRootContext()
          Find the root context of this namespace.
 java.util.Hashtable getEnvironment()
          Get envioronment
protected  EventHandler getEventHandler()
          Get event handler
 java.lang.String getNameInNamespace()
          Get the local name in the namespace.
 javax.naming.NameParser getNameParser(java.lang.String name)
           
protected  ContextBase getParent()
          Get the parent context of this context.
 javax.naming.NamingEnumeration list(java.lang.String name)
           
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
           
 java.lang.Object lookup(java.lang.String name)
           
 java.lang.Object lookupLink(java.lang.String name)
           
protected  void objectAdded(java.lang.String name, java.lang.Object o)
          Fire addition event through the event handler if one exists.
protected  void objectRemoved(java.lang.String name, java.lang.Object o)
          Fire removal event through the event handler if one exists.
protected  void objectRenamed(java.lang.String name, java.lang.Object o)
          Fire renaming event through the event handler if one exists.
 void rebind(java.lang.String name, java.lang.Object object)
           
 java.lang.Object removeFromEnvironment(java.lang.String name)
          Remove from environment
 void removeNamingListener(javax.naming.event.NamingListener listener)
           
 void rename(java.lang.String oldName, java.lang.String newName)
           
 void setHandler(EventHandler handler)
           
 boolean targetMustExist()
          We do not require a target to exist before signing up.
 void unbind(java.lang.String 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
bind, composeName, createSubcontext, destroySubcontext, getNameParser, list, listBindings, lookup, lookupLink, rebind, rename, unbind
 

Field Detail

ROOT_ADDRESS

public static final java.lang.String ROOT_ADDRESS
See Also:
Constant Field Values

ROOT_PORT

public static final java.lang.String ROOT_PORT
See Also:
Constant Field Values

ACCESS_PERMISSION

protected static final AccessPermission ACCESS_PERMISSION

nameParser

protected static final javax.naming.NameParser nameParser

port

protected int port

root

protected java.lang.String root

env

protected java.util.Hashtable env

localName

protected java.lang.String localName

parent

protected ContextBase parent

handler

protected EventHandler handler
Constructor Detail

ContextBase

public ContextBase(ContextBase parent,
                   java.util.Hashtable env,
                   java.lang.String localName)
Method Detail

setHandler

public void setHandler(EventHandler handler)
                throws javax.naming.NamingException
javax.naming.NamingException

addNamingListener

public void addNamingListener(javax.naming.Name name,
                              int scope,
                              javax.naming.event.NamingListener listener)
                       throws javax.naming.NamingException
Specified by:
addNamingListener in interface javax.naming.event.EventContext
javax.naming.NamingException

addNamingListener

public void addNamingListener(java.lang.String name,
                              int scope,
                              javax.naming.event.NamingListener listener)
                       throws javax.naming.NamingException
Specified by:
addNamingListener in interface javax.naming.event.EventContext
javax.naming.NamingException

removeNamingListener

public void removeNamingListener(javax.naming.event.NamingListener listener)
                          throws javax.naming.NamingException
Specified by:
removeNamingListener in interface javax.naming.event.EventContext
javax.naming.NamingException

targetMustExist

public boolean targetMustExist()
We do not require a target to exist before signing up.

Specified by:
targetMustExist in interface javax.naming.event.EventContext
Returns:
False

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context
javax.naming.NamingException

bind

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

rebind

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

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context
javax.naming.NamingException

rename

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

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context
javax.naming.NamingException

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context
javax.naming.NamingException

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context
javax.naming.NamingException

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context
javax.naming.NamingException

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context
javax.naming.NamingException

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context
javax.naming.NamingException

composeName

public java.lang.String composeName(java.lang.String nameOne,
                                    java.lang.String nameTwo)
                             throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context
javax.naming.NamingException

close

public void close()
           throws javax.naming.NamingException
Deregister event handler

Specified by:
close in interface javax.naming.Context
javax.naming.NamingException

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String name,
                                         java.lang.Object object)
                                  throws javax.naming.NamingException
Add to environment

Specified by:
addToEnvironment in interface javax.naming.Context
javax.naming.NamingException

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String name)
                                       throws javax.naming.NamingException
Remove from environment

Specified by:
removeFromEnvironment in interface javax.naming.Context
javax.naming.NamingException

getEnvironment

public java.util.Hashtable getEnvironment()
                                   throws javax.naming.NamingException
Get envioronment

Specified by:
getEnvironment in interface javax.naming.Context
javax.naming.NamingException

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Get the local name in the namespace.

Specified by:
getNameInNamespace in interface javax.naming.Context
javax.naming.NamingException

objectAdded

protected void objectAdded(java.lang.String name,
                           java.lang.Object o)
                    throws javax.naming.NamingException
Fire addition event through the event handler if one exists.

javax.naming.NamingException

objectRemoved

protected void objectRemoved(java.lang.String name,
                             java.lang.Object o)
                      throws javax.naming.NamingException
Fire removal event through the event handler if one exists.

javax.naming.NamingException

objectRenamed

protected void objectRenamed(java.lang.String name,
                             java.lang.Object o)
                      throws javax.naming.NamingException
Fire renaming event through the event handler if one exists.

javax.naming.NamingException

findRootContext

protected javax.naming.Context findRootContext()
Find the root context of this namespace. This returns always return the root on the namespace even if it is the current context.


getParent

protected ContextBase getParent()
Get the parent context of this context. Returns null if the current context is the root of the namespace.


checkAccess

protected void checkAccess()
Check access permission. This method should be called by all public methods in this class and subclasses to make sure no service can execute directly on the jdni context.


getEventHandler

protected EventHandler getEventHandler()
Get event handler