org.objectweb.carol.jndi.spi
Class AbsInitialContextFactory

java.lang.Object
  extended by org.objectweb.carol.jndi.spi.AbsInitialContextFactory
All Implemented Interfaces:
javax.naming.spi.InitialContextFactory
Direct Known Subclasses:
CmiContextWrapperFactory, IIOPContextWrapperFactory, IRMIContextWrapperFactory, JacORBIIOPContextWrapperFactory, JEREMIEContextWrapperFactory, JRMPContextWrapperFactory

public abstract class AbsInitialContextFactory
extends java.lang.Object
implements javax.naming.spi.InitialContextFactory

Instantiate the class of the given SPI and Handle a cache mechanism for storing contexts. It avoids to build new Context. When wanting to integrate a new protocol, extends this class and define getReferencingFactory() and getWrapperClass() method. Also, there are some others methods that you could redefine like init() or addExtraConfInEnvironment() to your specific needs.

Author:
Florent Benoit

Constructor Summary
AbsInitialContextFactory()
           
 
Method Summary
protected  void addExtraConfInEnvironment(java.util.Hashtable environment)
          This method should be redefined by subclasses For some protocols, there is a need to populate environment with some settings
protected  java.lang.Object[] getClassArgs(java.util.Hashtable environment)
          Gets the values to give to the constructor of the given class (provided by getWrapperClass())
protected  java.lang.Class[] getClassConstructor()
          Gets the arguments of the constructor of the given class (provided by getWrapperClass())
 javax.naming.Context getInitialContext(java.util.Hashtable environment)
          Creates an Initial Context for beginning name resolution.
protected  java.lang.String getKey(java.util.Hashtable environment)
           
protected  java.lang.String getReferencingFactory()
           
protected abstract  java.lang.Class getWrapperClass()
           
protected  void init()
          This method should be redefined by subclasses For some protocols, there are some initialization stuff to do
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbsInitialContextFactory

public AbsInitialContextFactory()
Method Detail

getReferencingFactory

protected java.lang.String getReferencingFactory()
Returns:
the real factory of this wrapper. The default is to use the URLInitialContextFactory which will pass to the NamingManager the protocol specified in the context url in order to retrieve a context factory.

getWrapperClass

protected abstract java.lang.Class getWrapperClass()
Returns:
class of the wrapper (to be instantiated + pool).

getInitialContext

public javax.naming.Context getInitialContext(java.util.Hashtable environment)
                                       throws javax.naming.NamingException
Creates an Initial Context for beginning name resolution. Special requirements of this context are supplied using environment.

Specified by:
getInitialContext in interface javax.naming.spi.InitialContextFactory
Parameters:
environment - The possibly null environment specifying information to be used in the creation of the initial context.
Returns:
A non-null initial context object that implements the Context interface.
Throws:
javax.naming.NamingException - If cannot create an initial context.

getKey

protected java.lang.String getKey(java.util.Hashtable environment)
Parameters:
environment - env to determine the key
Returns:
the key or null if we don't want to cache it

getClassArgs

protected java.lang.Object[] getClassArgs(java.util.Hashtable environment)
                                   throws javax.naming.NamingException
Gets the values to give to the constructor of the given class (provided by getWrapperClass())

Parameters:
environment - given environment
Returns:
array of objects for the constructor
Throws:
javax.naming.NamingException - if the new InitialContext fails

getClassConstructor

protected java.lang.Class[] getClassConstructor()
Gets the arguments of the constructor of the given class (provided by getWrapperClass())

Returns:
array of objects for the constructor

addExtraConfInEnvironment

protected void addExtraConfInEnvironment(java.util.Hashtable environment)
This method should be redefined by subclasses For some protocols, there is a need to populate environment with some settings

Parameters:
environment - hashtable containing the environment

init

protected void init()
             throws javax.naming.NamingException
This method should be redefined by subclasses For some protocols, there are some initialization stuff to do

Throws:
javax.naming.NamingException - if there is an exception