© 2005 BEA Systems, Inc.

com.beasys.commerce.util
Class JDBCSequencer

java.lang.Object
  extended bycom.beasys.commerce.util.JDBCSequencer
All Implemented Interfaces:
Sequencer

Deprecated. Use com.bea.p13n.util.jdbc.Sequencer and com.bea.p13n.util.jdbc.SequencerFactory

public class JDBCSequencer
extends Object
implements Sequencer

The JDBCSequencer class is a portable implementation for generating unique sequence numbers. JDBCSequencer uses a caching strategy where a block of sequence numbers is allocated in memory. When the block of sequence numbers is exhausted, JDBCSequencer obtains a new range of sequence numbers from the database. This approach has the advantage of minimizing the database access but it can create sequence numbers to be skipped if the server is restarted.

This implementation uses the WLCS_SEQUENCER table to maintain the current values of the different sequences. Each sequence is represented by a row in the WLCS_SEQUENCER and a row is automatically inserted for a sequence that does not exists already.

When allocating a new block of sequence numbers, JDBCSequencer uses a retry loop for obtaining an application lock (IS_LOCKED column in WLCS_SEQUENCER) before incrementing the current value of a sequence. Two properties can be defined in the weblogiccommerce.properties file to control the number of retries and the datasource name to use for obtaining a database connection:

Note:JDBSequencer must run in WebLogic because it must suspend the current transaction when allocating a new block of sequence numbers.

See Also:
Sequencer, SequencerFactory

Field Summary
static long DEFAULT_CACHE_SIZE
          Deprecated.  
static String DEFAULT_SEQUENCE_NAME
          Deprecated.  
static String DEFAULT_SEQUENCER_DATASOURCE_NAME
          Deprecated.  
static String DEFAULT_SEQUENCER_NAME
          Deprecated.  
static long DEFAULT_STEP_SIZE
          Deprecated.  
static String SEQUENCE_LOCK_IDENTIFIER
          Deprecated.  
static String SEQUENCE_NAME_IDENTIFIER
          Deprecated.  
static String SEQUENCE_VALUE_IDENTIFIER
          Deprecated.  
static String SEQUENCER_DATASOURCE_NAME_PROPERTY
          Deprecated.  
static String SEQUENCER_MAX_RETRY_PROPERTY
          Deprecated.  
 
Constructor Summary
JDBCSequencer()
          Deprecated. Default constructor.
JDBCSequencer(String sequencerName, String sequenceName)
          Deprecated. Creates a new JDBCSequencer with the supplied sequencer name and managed sequence name.
JDBCSequencer(String sequencerName, String sequenceName, long cacheSize)
          Deprecated. Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, and cache size.
JDBCSequencer(String sequencerName, String sequenceName, long cacheSize, long stepSize)
          Deprecated. Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, cache size, and step size.
 
Method Summary
protected  void allocateSequenceBlock()
          Deprecated. Allocates a new block of sequence numbers from the database.
protected  void cleanUpResources()
          Deprecated. Closes any open DB resources.
 long getCacheSize()
          Deprecated. Returns the cache size.
 long getCurrent()
          Deprecated. Gets the current sequence number associated with this sequencer.
 long getCurrent(Connection databaseConnection)
          Deprecated. JDBCSequencer must allocate the sequence block using a separate transaction because the database updates can be undone if a rollback occurs on the passed connection. Replaced by getNext()
 long getIncrementAmount()
          Deprecated. Replaced by getCacheSize
 long getNext()
          Deprecated. Gets the next sequence number.
 long getNext(Connection databaseConnection)
          Deprecated. JDBCSequencer must allocate the sequence block using a separate transaction because the database updates can be undone if a rollback occurs on the passed connection. Replaced by getNext()
 String getSequenceName()
          Deprecated. Returns the name of the sequence that is managed by this sequencer.
 String getSequencerName()
          Deprecated. Returns the name of this sequencer.
 long getStepSize()
          Deprecated. Returns the step size.
 void setCacheSize(long cacheSize)
          Deprecated. Sets the cache size.
 void setIncrementAmount(long incrementAmount)
          Deprecated. Replaced by setCacheSize
 void setSequenceName(String sequenceName)
          Deprecated. Sets the name of the sequence that is managed by this sequencer.
 void setSequencerName(String sequencerName)
          Deprecated. Sets the name of this sequencer.
 void setStepSize(long stepSize)
          Deprecated. Sets the step size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CACHE_SIZE

public static final long DEFAULT_CACHE_SIZE
Deprecated. 
See Also:
Constant Field Values

DEFAULT_SEQUENCE_NAME

public static final String DEFAULT_SEQUENCE_NAME
Deprecated. 
See Also:
Constant Field Values

DEFAULT_SEQUENCER_DATASOURCE_NAME

public static final String DEFAULT_SEQUENCER_DATASOURCE_NAME
Deprecated. 
See Also:
Constant Field Values

DEFAULT_SEQUENCER_NAME

public static final String DEFAULT_SEQUENCER_NAME
Deprecated. 
See Also:
Constant Field Values

DEFAULT_STEP_SIZE

public static final long DEFAULT_STEP_SIZE
Deprecated. 
See Also:
Constant Field Values

SEQUENCE_LOCK_IDENTIFIER

public static final String SEQUENCE_LOCK_IDENTIFIER
Deprecated. 
See Also:
Constant Field Values

SEQUENCE_NAME_IDENTIFIER

public static final String SEQUENCE_NAME_IDENTIFIER
Deprecated. 
See Also:
Constant Field Values

SEQUENCE_VALUE_IDENTIFIER

public static final String SEQUENCE_VALUE_IDENTIFIER
Deprecated. 
See Also:
Constant Field Values

SEQUENCER_DATASOURCE_NAME_PROPERTY

public static final String SEQUENCER_DATASOURCE_NAME_PROPERTY
Deprecated. 
See Also:
Constant Field Values

SEQUENCER_MAX_RETRY_PROPERTY

public static final String SEQUENCER_MAX_RETRY_PROPERTY
Deprecated. 
See Also:
Constant Field Values
Constructor Detail

JDBCSequencer

public JDBCSequencer()
Deprecated. 
Default constructor.


JDBCSequencer

public JDBCSequencer(String sequencerName,
                     String sequenceName)
Deprecated. 
Creates a new JDBCSequencer with the supplied sequencer name and managed sequence name.


JDBCSequencer

public JDBCSequencer(String sequencerName,
                     String sequenceName,
                     long cacheSize)
Deprecated. 
Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, and cache size.


JDBCSequencer

public JDBCSequencer(String sequencerName,
                     String sequenceName,
                     long cacheSize,
                     long stepSize)
Deprecated. 
Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, cache size, and step size.

Method Detail

allocateSequenceBlock

protected final void allocateSequenceBlock()
                                    throws SQLException
Deprecated. 
Allocates a new block of sequence numbers from the database. If a transaction is in progress, it is suspended during the database updates required for incrementing the current value of the sequence and resumed after.

Throws:
SQLException - on error.
SQLException

cleanUpResources

protected final void cleanUpResources()
Deprecated. 
Closes any open DB resources.


getCacheSize

public long getCacheSize()
Deprecated. 
Returns the cache size. The cache size defines how often the sequencer will allocate a block of unique sequence numbers from the database. When the sequencer exhausts its supplied of allocated numbers, it will allocate a new sequence of numbers from the database.

Specified by:
getCacheSize in interface Sequencer
Returns:
The cache size.

getCurrent

public long getCurrent()
                throws SQLException
Deprecated. 
Gets the current sequence number associated with this sequencer.

Throws:
SQLException - on error.
SQLException

getCurrent

public long getCurrent(Connection databaseConnection)
                throws SQLException
Deprecated. JDBCSequencer must allocate the sequence block using a separate transaction because the database updates can be undone if a rollback occurs on the passed connection. Replaced by getNext()

Gets the current sequence number associated with this sequencer.

Specified by:
getCurrent in interface Sequencer
Parameters:
databaseConnection - The database connection used to generate the next sequence number.
Throws:
SQLException - on error.
SQLException

getIncrementAmount

public long getIncrementAmount()
Deprecated. Replaced by getCacheSize

Returns the increment amount. The increment amount defines how often the sequencer will allocate a block of unique sequence numbers from the database. When the sequencer exhausts its supplied of allocated numbers, it will allocate a new sequence of numbers from the database.

Specified by:
getIncrementAmount in interface Sequencer
Returns:
The increment amount.
See Also:
getCacheSize()

getNext

public long getNext()
             throws SQLException
Deprecated. 
Gets the next sequence number. A new block of sequence numbers is allocated if the cache of numbers is exhausted.

Returns:
the next sequence number
Throws:
SQLException - on error.
SQLException

getNext

public long getNext(Connection databaseConnection)
             throws SQLException
Deprecated. JDBCSequencer must allocate the sequence block using a separate transaction because the database updates can be undone if a rollback occurs on the passed connection. Replaced by getNext()

Gets the next sequence number using the supplied database connection. The database connection will not be automatically closed upon method return. This class is thread safe.

Specified by:
getNext in interface Sequencer
Parameters:
databaseConnection - The database connection used to generate the next sequence number.
Throws:
SQLException - on error.
SQLException

getSequenceName

public String getSequenceName()
Deprecated. 
Returns the name of the sequence that is managed by this sequencer.

Specified by:
getSequenceName in interface Sequencer
Returns:
The sequence name.

getSequencerName

public String getSequencerName()
Deprecated. 
Returns the name of this sequencer.

Specified by:
getSequencerName in interface Sequencer
Returns:
The sequencer name.

getStepSize

public long getStepSize()
Deprecated. 
Returns the step size. The step size determines the difference between the values returned from successive calls to getNext().

Specified by:
getStepSize in interface Sequencer
Returns:
The step size.

setCacheSize

public void setCacheSize(long cacheSize)
Deprecated. 
Sets the cache size. The cache size defines how often the sequencer will allocate a block of unique sequence numbers from the database. When the sequencer exhausts its supplied of allocated numbers, it will allocate a new sequence of numbers from the database.

Specified by:
setCacheSize in interface Sequencer
Parameters:
cacheSize - The cache size.

setIncrementAmount

public void setIncrementAmount(long incrementAmount)
Deprecated. Replaced by setCacheSize

Sets the increment amount. The increment amount defines how often the sequencer will allocate a block of unique sequence numbers from the database. When the sequencer exhausts its supplied of allocated numbers, it will allocate a new sequence of numbers from the database.

Specified by:
setIncrementAmount in interface Sequencer
Parameters:
incrementAmount - The increment amount.
See Also:
setCacheSize(long)

setSequenceName

public void setSequenceName(String sequenceName)
Deprecated. 
Sets the name of the sequence that is managed by this sequencer.

Specified by:
setSequenceName in interface Sequencer
Parameters:
sequenceName - The new sequence name.

setSequencerName

public void setSequencerName(String sequencerName)
Deprecated. 
Sets the name of this sequencer.

Specified by:
setSequencerName in interface Sequencer
Parameters:
sequencerName - The new sequencer name.

setStepSize

public void setStepSize(long stepSize)
Deprecated. 
Sets the step size. The step size determines the difference between the values returned from successive calls to getNext().

Specified by:
setStepSize in interface Sequencer
Parameters:
stepSize - The step size.

© 2005 BEA Systems, Inc.

Copyright © 2005 BEA Systems, Inc. All Rights Reserved