org.pfsw.db.util
Class DBMultiCategoryIdGeneratorBuilder

java.lang.Object
  extended by org.pfsw.db.util.DBMultiCategoryIdGeneratorBuilder

public class DBMultiCategoryIdGeneratorBuilder
extends java.lang.Object

A builder supporting fluent API to create a database backed multi-category identifier generator where the generators for the different categories all share the same database table.


Constructor Summary
protected DBMultiCategoryIdGeneratorBuilder(javax.sql.DataSource dataSource)
           
 
Method Summary
 DBMultiCategoryIdGeneratorBuilder add(java.lang.String categoryName, long startId)
          Add a category with an ID producer using the given startId.
 DBMultiCategoryIdGeneratorBuilder add(java.lang.String categoryName, long startId, int blockSize)
          Add a category with an ID producer using the given startId and blockSize.
 DBMultiCategoryIdGeneratorBuilder add(java.lang.String categoryName, long startId, int blockSize, int length)
          Add a category with an ID producer using the given startId and blockSize and length.
 DBMultiCategoryIdGeneratorBuilder addCategories(IdGeneratorCategorySpec... specifications)
          Adds the categories with ID producers according to the given specs.
 DBMultiCategoryIdGeneratorBuilder addCategories(java.lang.String... categoryNames)
          Adds the given category names for which to register an ID producer.
 MultiCategoryIdentifierGenerator build()
           
static DBMultiCategoryIdGeneratorBuilder create(javax.sql.DataSource dataSource)
           
static DBMultiCategoryIdGeneratorBuilder create(javax.sql.DataSource dataSource, IdGeneratorTableSpec tableSpec)
           
protected  java.util.List<IdGeneratorCategorySpec> getCategorySpecs()
           
protected  javax.sql.DataSource getDataSource()
           
protected  DefaultMultiCategoryIdentifierGenerator getMultiCategoryIdGenerator()
           
protected  IdGeneratorTableSpec getTableSpec()
           
protected  boolean isNewCategory(java.lang.String categoryName)
          Returns true if no category with the given name has yet been registered.
protected  boolean isTableAlreadyCreated()
           
protected  void regsiterIdGenerator(IdGeneratorCategorySpec categorySpec)
           
protected  void setTableAlreadyCreated(boolean isTableCreated)
           
protected  void setTableSpec(IdGeneratorTableSpec tableSpec)
           
 DBMultiCategoryIdGeneratorBuilder tableAlreadyCreated()
          Invoke this method to signal that the table has been already created in the database.
 DBMultiCategoryIdGeneratorBuilder tableSpec(IdGeneratorTableSpec tableSpecification)
          If the default table or column names are not acceptable, specify here the names to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBMultiCategoryIdGeneratorBuilder

protected DBMultiCategoryIdGeneratorBuilder(javax.sql.DataSource dataSource)
Method Detail

create

public static DBMultiCategoryIdGeneratorBuilder create(javax.sql.DataSource dataSource)

create

public static DBMultiCategoryIdGeneratorBuilder create(javax.sql.DataSource dataSource,
                                                       IdGeneratorTableSpec tableSpec)

add

public DBMultiCategoryIdGeneratorBuilder add(java.lang.String categoryName,
                                             long startId)
Add a category with an ID producer using the given startId.


add

public DBMultiCategoryIdGeneratorBuilder add(java.lang.String categoryName,
                                             long startId,
                                             int blockSize)
Add a category with an ID producer using the given startId and blockSize.


add

public DBMultiCategoryIdGeneratorBuilder add(java.lang.String categoryName,
                                             long startId,
                                             int blockSize,
                                             int length)
Add a category with an ID producer using the given startId and blockSize and length.


addCategories

public DBMultiCategoryIdGeneratorBuilder addCategories(java.lang.String... categoryNames)
Adds the given category names for which to register an ID producer.


addCategories

public DBMultiCategoryIdGeneratorBuilder addCategories(IdGeneratorCategorySpec... specifications)
Adds the categories with ID producers according to the given specs.


tableSpec

public DBMultiCategoryIdGeneratorBuilder tableSpec(IdGeneratorTableSpec tableSpecification)
If the default table or column names are not acceptable, specify here the names to be used.


tableAlreadyCreated

public DBMultiCategoryIdGeneratorBuilder tableAlreadyCreated()
Invoke this method to signal that the table has been already created in the database.


build

public MultiCategoryIdentifierGenerator build()

regsiterIdGenerator

protected void regsiterIdGenerator(IdGeneratorCategorySpec categorySpec)

isNewCategory

protected boolean isNewCategory(java.lang.String categoryName)
Returns true if no category with the given name has yet been registered.


getDataSource

protected javax.sql.DataSource getDataSource()

getTableSpec

protected IdGeneratorTableSpec getTableSpec()

setTableSpec

protected void setTableSpec(IdGeneratorTableSpec tableSpec)

getCategorySpecs

protected java.util.List<IdGeneratorCategorySpec> getCategorySpecs()

getMultiCategoryIdGenerator

protected DefaultMultiCategoryIdentifierGenerator getMultiCategoryIdGenerator()

isTableAlreadyCreated

protected boolean isTableAlreadyCreated()

setTableAlreadyCreated

protected void setTableAlreadyCreated(boolean isTableCreated)