SequencerFactory Class

com.bea.p13n.util.jdbc
SequencerFactory Class

public final class SequencerFactory

    extends Object

This class implements the Singleton design pattern for obtaining database sequencers. A single instance of a Sequencer exists to create sequence numbers. The sequence numbers are backed by a database, but blocks of sequence numbers are cached in the Sequencer instance.

This factory creates and maintains Sequencer instances so that multiple calls to one of the createSequencer methods with the same arguments will return the same reusable instance.

Related Topics

Sequencer


Hierarchy
Object
  SequencerFactory

Method Summary

public static Sequencer
createSequencer(String sequenceName)
Returns the singleton Sequencer for the given sequence name backed by the sequencer's default data source.
public static Sequencer
createSequencer(String sequenceName, long cacheSize)
Returns the singleton Sequencer for the given sequence name and the given cache size.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   

Method Detail

createSequencer(String) Method

public static Sequencer createSequencer(String sequenceName)
Returns the singleton Sequencer for the given sequence name backed by the sequencer's default data source. A Sequencer is created if needed, but if one has already been created then that instance is returned.

The sequencer expects a DataSource named "weblogic.jdbc.jts.SequencerPool" which must be associated with a non-XA connection pool.

The default cache size for this sequencer is 2000. So the Sequencer will only need to access the database every 2000 calls to getNext().

Note that if a new sequencer is created for the first time, it will not interact with the database until the first call to getNext() on the returned Sequencer. Therefore, if you have an invalid DataSource object or the sequenceName is not a valid key for the database (i.e. is too long or contains characters the database can't handle), then you may see SQLExceptions on the first call to getNext().

Parameters

sequenceName
The name of the managed sequence. This name is used as the primary key (row name) in the database. The sequence name may not be null or an empty string.

Returns

singleton named Sequencer

createSequencer(String, long) Method

public static Sequencer createSequencer(String sequenceName, 
                                        long cacheSize)
Returns the singleton Sequencer for the given sequence name and the given cache size. A Sequencer is created if needed, but if one has already been created then that instance is returned.

Parameters

sequenceName
The name of the managed sequence. This name is used as the primary key (row name) in the database. The sequence name may not be null or an empty string.
cacheSize
The cache size. The cache is the size of the block that a sequencer instance keeps in memory. The larger the cache, the less often the sequencer must go to the database. If this parameter is zero, the default cache size (2000) is used. The cache size may not be less than zero.

Returns

singleton named Sequencer with the given cacheSize

Related Topics

SequencerFactory.createSequencer(String)