Enhydra 5.1 API

org.enhydra.servlet.connectionMethods
Class ConnectionMethodManager

java.lang.Object
  |
  +--org.enhydra.servlet.connectionMethods.ConnectionMethodManager

public class ConnectionMethodManager
extends java.lang.Object

This class maintains a set of ConnectionMethods. Each ConnectionMethod is associated with an identification string (symbolic name). This ID string is used to retrieve a ConnectionMethod.

This class does not monitor the creation of ConnectionMethods. If you create one, you are responsible for adding it. These public methods are the only things that modify the set of ConnectionMethods managed by this class. (Note that this is different than the ServletManager, which is responsible for creating the Servlets it manages.)

Author:
Andy John
See Also:
ConnectionMethod

Field Summary
static java.lang.String APACHE
           
static java.lang.String BIND_ADDR
           
static java.lang.String CGI
           
static java.lang.String CLIENT_TIMEOUT
           
static java.lang.String CONNECTION
           
static java.lang.String CONNECTION_METHOD
           
static java.lang.String ENHYDRADIRECTOR
           
static java.lang.String ENHYDRADIRECTOR_CONNECTION
           
static java.lang.String HTTP
           
static java.lang.String HTTP_CONNECTION
           
static java.lang.String HTTPS
           
static java.lang.String HTTPS_CONNECTION
           
static java.lang.String IIS
           
protected static org.apache.log4j.Logger logger
          The logging channel.
static java.lang.String NUM_THREADS
           
static java.lang.String PORT
           
static java.lang.String QUEUE_SIZE
           
static java.lang.String RMI
           
static java.lang.String SERVER_HOST
           
static java.lang.String SERVER_PORT
           
static java.lang.String THREAD_TIMEOUT
           
static java.lang.String TYPE
           
static java.lang.String WAI
           
 
Constructor Summary
ConnectionMethodManager()
          Create a new, empty, ConnectionMethodManager.
 
Method Summary
 void add(java.lang.String connectionID, ConnectionMethod cm)
          Add a ConnectionMethod to the set.
protected  void addConnectionMethod(Config connectionConfig, java.lang.String id)
          This function will try to retrieve a Class object for the given connection method.
 void createConnectionSection(Config config)
          Asks each connection method to write itself out to the config file
 void delete(java.lang.String connectionID)
          Remove a ConnectionMethod from the set.
 ConnectionMethod get(java.lang.String connectionID)
          Look up a ConnectionMethod from the set, by its identifier string.
 java.util.Hashtable getDefaultConnectionMethods()
          Return the hashtable of 'default' connection methods plus any additional connection methods found in the conf file maked as ConnectionMethod. =
 java.lang.String[] getIDs()
          Get all the names of the ConnectionMethods currently in the set.
 java.lang.String getUniqueName()
          Generate a unique name that is not currently in the table.
 void initConnectionMethods(Config config)
          Parse the Connection section of the config file and attempt to create all specified connection types.
 java.lang.String toString()
          Returns a multi-line list of the contents of this manager, connection methods and channels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PORT

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

BIND_ADDR

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

NUM_THREADS

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

QUEUE_SIZE

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

THREAD_TIMEOUT

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

CLIENT_TIMEOUT

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

SERVER_HOST

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

SERVER_PORT

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

CONNECTION_METHOD

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

CONNECTION

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

TYPE

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

APACHE

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

CGI

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

HTTP

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

HTTPS

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

IIS

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

RMI

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

WAI

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

ENHYDRADIRECTOR

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

HTTP_CONNECTION

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

HTTPS_CONNECTION

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

ENHYDRADIRECTOR_CONNECTION

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

logger

protected static org.apache.log4j.Logger logger
The logging channel.

Constructor Detail

ConnectionMethodManager

public ConnectionMethodManager()
Create a new, empty, ConnectionMethodManager.

Method Detail

initConnectionMethods

public void initConnectionMethods(Config config)
                           throws ConnectionMethodException
Parse the Connection section of the config file and attempt to create all specified connection types.

Parameters:
config - The config object representating the config file
Throws:
ConnectionMethodException - if a specified connection method does not exist or the connection method fails to initialize itself properly.

addConnectionMethod

protected void addConnectionMethod(Config connectionConfig,
                                   java.lang.String id)
                            throws ConnectionMethodException
This function will try to retrieve a Class object for the given connection method. The first attempt will assume the Type specified in the config file is an abbreviated name (eg. Http) and use a translation table to find the appropriate class name. If this fails, the Type specified in the config file will be assumed to be a fully qualified class name and an attempt to retrieve the Class object will be made again. If it fails, an exception is thrown. Otherwise the Class object is instantiated and the connection method is initiailized and added to the connection pool.

Parameters:
connectionConfig - The portion of the config file relevant to this connection method
id - The id associated with this connection method
Throws:
ConnectionMethodException - if a specified connection method does not exist or the connection method fails to initialize itself properly.

add

public void add(java.lang.String connectionID,
                ConnectionMethod cm)
         throws ConnectionMethodException
Add a ConnectionMethod to the set. It will be referred to by the given identifer string.

Parameters:
connectionID - The name to use to refer to the ConnectionMethod.
cm - The ConnectionMethod to store.
Throws:
ConnectionMethodException - If the ID is already in use.

get

public ConnectionMethod get(java.lang.String connectionID)
Look up a ConnectionMethod from the set, by its identifier string.

Parameters:
connectionID - The symbolic name to look up.
Returns:
The ConnectionMethod, or null if the name is not found.

getIDs

public java.lang.String[] getIDs()
Get all the names of the ConnectionMethods currently in the set.

Returns:
All the connectionIDs

getDefaultConnectionMethods

public java.util.Hashtable getDefaultConnectionMethods()
Return the hashtable of 'default' connection methods plus any additional connection methods found in the conf file maked as ConnectionMethod. =

Returns:
All the 'default' connection methods held in connectionTable plus those found in the config file

delete

public void delete(java.lang.String connectionID)
            throws ConnectionMethodException
Remove a ConnectionMethod from the set.

Parameters:
connectionID - The name of the ConnectionMethod to remove.
Throws:
ConnectionMethodException - If the ID is not found.

getUniqueName

public java.lang.String getUniqueName()
Generate a unique name that is not currently in the table. This may be used when adding a new connection method and you don't have a specific ID string you want to use. The names generated by this function are unique across all calls to this function, not just unique given the current set of connection methods. Therefore it is safe to get a name and use it later. The name will not be given out again, so the name should be unused when you want to use it to add a connection method.

Returns:
A connection method ID that is not currently in use.

createConnectionSection

public void createConnectionSection(Config config)
                             throws ConfigException,
                                    KeywordValueException
Asks each connection method to write itself out to the config file

Parameters:
config - The config file
ConfigException
KeywordValueException

toString

public java.lang.String toString()
Returns a multi-line list of the contents of this manager, connection methods and channels.

Overrides:
toString in class java.lang.Object

Enhydra 5.1 API