org.apache.avalon.excalibur.datasource.ids
Class AbstractDataSourceBlockIdGenerator

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.excalibur.datasource.ids.AbstractIdGenerator
          extended byorg.apache.avalon.excalibur.datasource.ids.AbstractDataSourceIdGenerator
              extended byorg.apache.avalon.excalibur.datasource.ids.AbstractDataSourceBlockIdGenerator
All Implemented Interfaces:
Component, Configurable, Disposable, IdGenerator, Initializable, LogEnabled, Serviceable, ThreadSafe
Direct Known Subclasses:
TableIdGenerator

public abstract class AbstractDataSourceBlockIdGenerator
extends AbstractDataSourceIdGenerator

The AbstractDataSourceBlockIdGenerator allocates blocks of ids from a DataSource and then provides them as needed. This is useful in reducing communication with the DataSource.

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

Field Summary
 
Fields inherited from class org.apache.avalon.excalibur.datasource.ids.AbstractDataSourceIdGenerator
m_dataSource, m_nextId
 
Fields inherited from interface org.apache.avalon.excalibur.datasource.ids.IdGenerator
ROLE
 
Constructor Summary
AbstractDataSourceBlockIdGenerator()
           
 
Method Summary
protected abstract  java.math.BigDecimal allocateBigDecimalIdBlock(int blockSize)
          Allocates a block, of the given size, of ids from the database.
protected abstract  long allocateLongIdBlock(int blockSize)
          Allocates a block, of the given size, of ids from the database.
 void configure(Configuration configuration)
          Called by the Container to configure the component.
protected  java.math.BigDecimal getNextBigDecimalIdInner()
          Gets the next id as a Big Decimal.
protected  long getNextLongIdInner()
          Gets the next id as a long.
 void initialize()
          Called by the Container to initialize the component.
 
Methods inherited from class org.apache.avalon.excalibur.datasource.ids.AbstractDataSourceIdGenerator
dispose, getConnection, service
 
Methods inherited from class org.apache.avalon.excalibur.datasource.ids.AbstractIdGenerator
getNextBigDecimalId, getNextByteId, getNextIntegerId, getNextLongId, getNextLongIdChecked, getNextShortId, isUsingBigDecimals, setUseBigDecimals
 
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
 

Constructor Detail

AbstractDataSourceBlockIdGenerator

public AbstractDataSourceBlockIdGenerator()
Method Detail

allocateBigDecimalIdBlock

protected abstract java.math.BigDecimal allocateBigDecimalIdBlock(int blockSize)
                                                           throws IdException
Allocates a block, of the given size, of ids from the database.

Parameters:
blockSize - number of Ids which are to be allocated.
Returns:
The first id in the allocated block.
Throws:
IdException - if there it was not possible to allocate a block of ids.

allocateLongIdBlock

protected abstract long allocateLongIdBlock(int blockSize)
                                     throws IdException
Allocates a block, of the given size, of ids from the database.

Parameters:
blockSize - number of Ids which are to be allocated.
Returns:
The first id in the allocated block.
Throws:
IdException - if there it was not possible to allocate a block of ids.

getNextBigDecimalIdInner

protected java.math.BigDecimal getNextBigDecimalIdInner()
                                                 throws IdException
Gets the next id as a Big Decimal. This method will only be called when synchronized and when the data type is configured to be BigDecimal.

Specified by:
getNextBigDecimalIdInner in class AbstractIdGenerator
Returns:
the next id as a BigDecimal.
Throws:
IdException - if an Id could not be allocated for any reason.

getNextLongIdInner

protected long getNextLongIdInner()
                           throws IdException
Gets the next id as a long. This method will only be called when synchronized and when the data type is configured to be long.

Specified by:
getNextLongIdInner in class AbstractIdGenerator
Returns:
the next id as a long.
Throws:
IdException - if an Id could not be allocated for any reason.

configure

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

Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractDataSourceIdGenerator
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
Overrides:
initialize in class AbstractDataSourceIdGenerator
Throws:
java.lang.Exception - if there were any problems durring initialization.


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