org.apache.avalon.excalibur.datasource.ids
Class AbstractDataSourceBlockIdGenerator
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.avalon.excalibur.datasource.ids.AbstractIdGenerator
org.apache.avalon.excalibur.datasource.ids.AbstractDataSourceIdGenerator
org.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:
| Field Summary |
private int |
m_allocated
The number of ids which have been allocated from the current block. |
private int |
m_blockSize
The number of ids loaded in each block. |
private java.math.BigDecimal |
m_firstBigDecimal
The first id in a batch of Ids loaded in from the DataSource. |
private long |
m_firstLong
The first id in a batch of Ids loaded in from the DataSource. |
| Fields inherited from interface org.apache.avalon.excalibur.datasource.ids.IdGenerator |
ROLE |
| 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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_firstBigDecimal
private java.math.BigDecimal m_firstBigDecimal
-
The first id in a batch of Ids loaded in from the DataSource.
m_firstLong
private long m_firstLong
-
The first id in a batch of Ids loaded in from the DataSource.
m_blockSize
private int m_blockSize
-
The number of ids loaded in each block.
m_allocated
private int m_allocated
-
The number of ids which have been allocated from the current block.
AbstractDataSourceBlockIdGenerator
public AbstractDataSourceBlockIdGenerator()
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.
Please see keelframework.org for information about new Keel releases.