BEA Systems, Inc.

com.beasys.commerce.util
Class JDBCSequencer

java.lang.Object
  |
  +--com.beasys.commerce.util.JDBCSequencer

public class JDBCSequencer
extends java.lang.Object
implements Sequencer


Field Summary
static long DEFAULT_CACHE_SIZE
           
static java.lang.String DEFAULT_SEQUENCE_NAME
           
static java.lang.String DEFAULT_SEQUENCER_NAME
           
static long DEFAULT_STEP_SIZE
           
static java.lang.String SEQUENCE_NAME_IDENTIFIER
           
static java.lang.String SEQUENCE_VALUE_IDENTIFIER
           
 
Constructor Summary
JDBCSequencer()
          Default constructor.
JDBCSequencer(java.lang.String sequencerName, java.lang.String sequenceName)
          Creates a new JDBCSequencer with the supplied sequencer name and managed sequence name.
JDBCSequencer(java.lang.String sequencerName, java.lang.String sequenceName, long cacheSize)
          Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, and cache size.
JDBCSequencer(java.lang.String sequencerName, java.lang.String sequenceName, long cacheSize, long stepSize)
          Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, cache size, and step size.
 
Method Summary
 long getCacheSize()
          Returns the cache size.
 long getCurrent(java.sql.Connection databaseConnection)
          Gets the current sequence number associated with this sequencer.
 long getIncrementAmount()
          Deprecated. Replaced by getCacheSize
 long getNext(java.sql.Connection databaseConnection)
          Gets the next sequence number using the supplied database connection.
 java.lang.String getSequenceName()
          Returns the name of the sequence that is managed by this sequencer.
 java.lang.String getSequencerName()
          Returns the name of this sequencer.
 long getStepSize()
          Returns the step size.
 void setCacheSize(long cacheSize)
          Sets the cache size.
 void setIncrementAmount(long incrementAmount)
          Deprecated. Replaced by setCacheSize
 void setSequenceName(java.lang.String sequenceName)
          Sets the name of the sequence that is managed by this sequencer.
 void setSequencerName(java.lang.String sequencerName)
          Sets the name of this sequencer.
 void setStepSize(long stepSize)
          Sets the step size.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CACHE_SIZE

public static final long DEFAULT_CACHE_SIZE

DEFAULT_STEP_SIZE

public static final long DEFAULT_STEP_SIZE

DEFAULT_SEQUENCER_NAME

public static final java.lang.String DEFAULT_SEQUENCER_NAME

DEFAULT_SEQUENCE_NAME

public static final java.lang.String DEFAULT_SEQUENCE_NAME

SEQUENCE_NAME_IDENTIFIER

public static final java.lang.String SEQUENCE_NAME_IDENTIFIER

SEQUENCE_VALUE_IDENTIFIER

public static final java.lang.String SEQUENCE_VALUE_IDENTIFIER
Constructor Detail

JDBCSequencer

public JDBCSequencer()
Default constructor.

JDBCSequencer

public JDBCSequencer(java.lang.String sequencerName,
                     java.lang.String sequenceName)
Creates a new JDBCSequencer with the supplied sequencer name and managed sequence name.
Parameters:
sequencerName - The name of the new sequencer.
sequenceName - The name of the managed sequence.

JDBCSequencer

public JDBCSequencer(java.lang.String sequencerName,
                     java.lang.String sequenceName,
                     long cacheSize)
Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, and cache size.
Parameters:
sequencerName - The name of the new sequencer.
sequenceName - The name of the managed sequence.
cacheSize - The cache size.

JDBCSequencer

public JDBCSequencer(java.lang.String sequencerName,
                     java.lang.String sequenceName,
                     long cacheSize,
                     long stepSize)
Creates a new JDBCSequencer with the supplied sequencer name, managed sequence name, cache size, and step size.
Parameters:
sequencerName - The name of the new sequencer.
sequenceName - The name of the managed sequence.
cacheSize - The cache size.
Method Detail

getNext

public long getNext(java.sql.Connection databaseConnection)
             throws java.sql.SQLException
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.

getCurrent

public long getCurrent(java.sql.Connection databaseConnection)
                throws java.sql.SQLException
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.

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()

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)

getCacheSize

public long getCacheSize()
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.

setCacheSize

public void setCacheSize(long cacheSize)
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.

getStepSize

public long getStepSize()
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.

setStepSize

public void setStepSize(long stepSize)
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.

getSequencerName

public java.lang.String getSequencerName()
Returns the name of this sequencer.
Specified by:
getSequencerName in interface Sequencer
Returns:
The sequencer name.

setSequencerName

public void setSequencerName(java.lang.String sequencerName)
Sets the name of this sequencer.
Specified by:
setSequencerName in interface Sequencer
Parameters:
sequencerName - The new sequencer name.

getSequenceName

public java.lang.String getSequenceName()
Returns the name of the sequence that is managed by this sequencer.
Specified by:
getSequenceName in interface Sequencer
Returns:
The sequence name.

setSequenceName

public void setSequenceName(java.lang.String sequenceName)
Sets the name of the sequence that is managed by this sequencer.
Specified by:
setSequenceName in interface Sequencer
Parameters:
sequenceName - The new sequence name.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved