org.apache.avalon.excalibur.datasource.cluster
Class AbstractDataSourceCluster

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.excalibur.datasource.cluster.AbstractDataSourceCluster
All Implemented Interfaces:
Configurable, Disposable, Initializable, LogEnabled, Serviceable, ThreadSafe
Direct Known Subclasses:
DefaultHashedDataSourceCluster, DefaultIndexedDataSourceCluster, DefaultRoundRobinDataSourceCluster

public abstract class AbstractDataSourceCluster
extends AbstractLogEnabled
implements Serviceable, Configurable, Initializable, Disposable, ThreadSafe

Since:
4.1
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:20 $
Author:
Avalon Development Team

Field Summary
protected  int m_size
           
 
Constructor Summary
AbstractDataSourceCluster()
           
 
Method Summary
 void configure(Configuration configuration)
          Called by the Container to configure the component.
 void dispose()
          Called by the Container to dispose the component.
 int getClusterSize()
          Returns the number of DataSources in the cluster.
 java.sql.Connection getConnectionForIndex(int index)
          Gets a Connection to a database given an index.
 void initialize()
          Called by the Container to initialize the component.
 void service(ServiceManager manager)
          Called by the Container to tell the component which ComponentLocator is controlling it.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_size

protected int m_size
Constructor Detail

AbstractDataSourceCluster

public AbstractDataSourceCluster()
Method Detail

getClusterSize

public int getClusterSize()
Returns the number of DataSources in the cluster.

Returns:
size of the cluster.

getConnectionForIndex

public java.sql.Connection getConnectionForIndex(int index)
                                          throws java.sql.SQLException
Gets a Connection to a database given an index.

Parameters:
index - Index of the DataSource for which a connection is to be returned.
Throws:
NoValidConnectionException - when there is no valid Connection wrapper available in the classloader or when the index is not valid.
NoValidConnectionException - when there are no more available Connections in the pool.
java.sql.SQLException

service

public void service(ServiceManager manager)
             throws ServiceException
Called by the Container to tell the component which ComponentLocator is controlling it.

Specified by:
service in interface Serviceable
Parameters:
manager - which curently owns the component.
Throws:
ServiceException - if an error occurs

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Called by the Container to configure the component.

Specified by:
configure in interface Configurable
Parameters:
configuration - configuration info used to setup the component.
Throws:
ConfigurationException - if there are any problems with the configuration.

initialize

public void initialize()
                throws java.lang.Exception
Called by the Container to initialize the component.

Specified by:
initialize in interface Initializable
Throws:
java.lang.Exception - if there were any problems durring initialization.

dispose

public void dispose()
Called by the Container to dispose the component.

Specified by:
dispose in interface Disposable


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.