Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2002 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.beasys.commerce.util
Class JDBCSequencer

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

Deprecated. Use `com.bea.p13n.util.jdbc.internal.JdbcHelper`

public class JDBCSequencer
extends java.lang.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:

- `commerce.jdbcSequencer.maxRetry` default value is 5 (1 second wait each retry)
- `commerce.jdbcSequencer.dataSource.name` default value is "weblogic.jdbc.jts.commercePool"

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

See Also:
  `Sequencer`

Field Summary
`static long` | `DEFAULT_CACHE_SIZE` Deprecated.
`static java.lang.String` | `DEFAULT_SEQUENCE_NAME` Deprecated.
`static java.lang.String` | `DEFAULT_SEQUENCER_DATASOURCE_NAME` Deprecated.
`static java.lang.String` | `DEFAULT_SEQUENCER_NAME` Deprecated.
`static long` | `DEFAULT_STEP_SIZE` Deprecated.
`static java.lang.String` | `SEQUENCE_LOCK_IDENTIFIER` Deprecated.
`static java.lang.String` | `SEQUENCE_NAME_IDENTIFIER` Deprecated.
`static java.lang.String` | `SEQUENCE_VALUE_IDENTIFIER` Deprecated.
`static java.lang.String` | `SEQUENCER_DATASOURCE_NAME_PROPERTY` Deprecated.
`static java.lang.String` | `SEQUENCER_MAX_RETRY_PROPERTY` Deprecated.

Constructor Summary
`JDBCSequencer()` Deprecated. Default constructor.
`JDBCSequencer(java.lang.String sequencerName, java.lang.String sequenceName)` Deprecated. Creates a new `JDBCSequencer` with the supplied sequencer name and managed sequence name.
`JDBCSequencer(java.lang.String sequencerName, java.lang.String sequenceName, long cacheSize)` Deprecated. 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)` 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(java.sql.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(java.sql.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()`
`java.lang.String` | `getSequenceName()` Deprecated. Returns the name of the sequence that is managed by this sequencer.
`java.lang.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(java.lang.String sequenceName)` Deprecated. Sets the name of the sequence that is managed by this sequencer.
`void` | `setSequencerName(java.lang.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.

### DEFAULT_STEP_SIZE

    public static final long DEFAULT_STEP_SIZE

  Deprecated.

### SEQUENCER_DATASOURCE_NAME_PROPERTY

    public static final java.lang.String SEQUENCER_DATASOURCE_NAME_PROPERTY

  Deprecated.

### SEQUENCER_MAX_RETRY_PROPERTY

    public static final java.lang.String SEQUENCER_MAX_RETRY_PROPERTY

  Deprecated.

### DEFAULT_SEQUENCER_DATASOURCE_NAME

    public static final java.lang.String DEFAULT_SEQUENCER_DATASOURCE_NAME

  Deprecated.

### DEFAULT_SEQUENCER_NAME

    public static final java.lang.String DEFAULT_SEQUENCER_NAME

  Deprecated.

### DEFAULT_SEQUENCE_NAME

    public static final java.lang.String DEFAULT_SEQUENCE_NAME

  Deprecated.

### SEQUENCE_NAME_IDENTIFIER

    public static final java.lang.String SEQUENCE_NAME_IDENTIFIER

  Deprecated.

### SEQUENCE_VALUE_IDENTIFIER

    public static final java.lang.String SEQUENCE_VALUE_IDENTIFIER

  Deprecated.

### SEQUENCE_LOCK_IDENTIFIER

    public static final java.lang.String SEQUENCE_LOCK_IDENTIFIER

  Deprecated.

Constructor Detail

### JDBCSequencer

    public JDBCSequencer()

  Deprecated.
  Default constructor.

### JDBCSequencer

    public JDBCSequencer(java.lang.String sequencerName,
                         java.lang.String sequenceName)

  Deprecated.
  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)

  Deprecated.
  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)

  Deprecated.
  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

  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.

### getNext

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

### getCurrent

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

### getCurrent

    public long getCurrent()
                    throws java.sql.SQLException

  Deprecated.
  Gets the current sequence number associated with this sequencer.

  Throws:
    `SQLException` - on error.

### allocateSequenceBlock

    protected final void allocateSequenceBlock()
                                        throws java.sql.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.

### cleanUpResources

    protected final void cleanUpResources()

  Deprecated.
  Closes any open DB resources.

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

  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.

### 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.

### 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.

### 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.

### getSequencerName

    public java.lang.String getSequencerName()

  Deprecated.
  Returns the name of this sequencer.
  Specified by:
    getSequencerName in interface Sequencer

  Returns:
    The sequencer name.

### setSequencerName

    public void setSequencerName(java.lang.String sequencerName)

  Deprecated.
  Sets the name of this sequencer.
  Specified by:
    setSequencerName in interface Sequencer

  Parameters:
    `sequencerName` - The new sequencer name.

### getSequenceName

    public java.lang.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.

### setSequenceName

    public void setSequenceName(java.lang.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.

Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2002 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 BEA Systems, Inc. All Rights Reserved