Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2008 BEA Systems, Inc. All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.beasys.commerce.util
Class JDBCSequencer

    java.lang.Object
      com.beasys.commerce.util.JDBCSequencer

All Implemented Interfaces
  Sequencer

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

    @Deprecated
    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:

- `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`, `SequencerFactory`

Field Summary
`static long` | `DEFAULT_CACHE_SIZE` Deprecated See BEA Commerce product offering
`static String` | `DEFAULT_SEQUENCE_NAME` Deprecated See BEA Commerce product offering
`static String` | `DEFAULT_SEQUENCER_DATASOURCE_NAME` Deprecated See BEA Commerce product offering
`static String` | `DEFAULT_SEQUENCER_NAME` Deprecated See BEA Commerce product offering
`static long` | `DEFAULT_STEP_SIZE` Deprecated See BEA Commerce product offering
`static String` | `SEQUENCE_LOCK_IDENTIFIER` Deprecated See BEA Commerce product offering
`static String` | `SEQUENCE_NAME_IDENTIFIER` Deprecated See BEA Commerce product offering
`static String` | `SEQUENCE_VALUE_IDENTIFIER` Deprecated See BEA Commerce product offering
`static String` | `SEQUENCER_DATASOURCE_NAME_PROPERTY` Deprecated See BEA Commerce product offering
`static String` | `SEQUENCER_MAX_RETRY_PROPERTY` Deprecated See BEA Commerce product offering

Constructor Summary
`JDBCSequencer()` Deprecated See BEA Commerce product offering
`JDBCSequencer(String sequencerName, String sequenceName)` Deprecated See BEA Commerce product offering
`JDBCSequencer(String sequencerName, String sequenceName, long cacheSize)` Deprecated See BEA Commerce product offering
`JDBCSequencer(String sequencerName, String sequenceName, long cacheSize, long stepSize)` Deprecated See BEA Commerce product offering

Method Summary
`protected void` | `allocateSequenceBlock()` Deprecated See BEA Commerce product offering
`protected void` | `cleanUpResources()` Deprecated See BEA Commerce product offering
`long` | `getCacheSize()` Deprecated See BEA Commerce product offering
`long` | `getCurrent()` Deprecated See BEA Commerce product offering
`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 See BEA Commerce product offering
`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 See BEA Commerce product offering
`String` | `getSequencerName()` Deprecated See BEA Commerce product offering
`long` | `getStepSize()` Deprecated See BEA Commerce product offering
`void` | `setCacheSize(long cacheSize)` Deprecated See BEA Commerce product offering
`void` | `setIncrementAmount(long incrementAmount)` Deprecated Replaced by setCacheSize
`void` | `setSequenceName(String sequenceName)` Deprecated See BEA Commerce product offering
`void` | `setSequencerName(String sequencerName)` Deprecated See BEA Commerce product offering
`void` | `setStepSize(long stepSize)` Deprecated See BEA Commerce product offering

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 BEA Commerce product offering
  See Also
    Constants Summary

### DEFAULT_STEP_SIZE

    public static final long DEFAULT_STEP_SIZE

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### SEQUENCER_DATASOURCE_NAME_PROPERTY

    public static final String SEQUENCER_DATASOURCE_NAME_PROPERTY

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### SEQUENCER_MAX_RETRY_PROPERTY

    public static final String SEQUENCER_MAX_RETRY_PROPERTY

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### DEFAULT_SEQUENCER_DATASOURCE_NAME

    public static final String DEFAULT_SEQUENCER_DATASOURCE_NAME

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### DEFAULT_SEQUENCER_NAME

    public static final String DEFAULT_SEQUENCER_NAME

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### DEFAULT_SEQUENCE_NAME

    public static final String DEFAULT_SEQUENCE_NAME

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### SEQUENCE_NAME_IDENTIFIER

    public static final String SEQUENCE_NAME_IDENTIFIER

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### SEQUENCE_VALUE_IDENTIFIER

    public static final String SEQUENCE_VALUE_IDENTIFIER

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

### SEQUENCE_LOCK_IDENTIFIER

    public static final String SEQUENCE_LOCK_IDENTIFIER

  Deprecated See BEA Commerce product offering
  See Also
    Constants Summary

Constructor Detail

### JDBCSequencer

    public JDBCSequencer()

  Deprecated See BEA Commerce product offering

  Default constructor.

### JDBCSequencer

    public JDBCSequencer(String sequencerName,
                         String sequenceName)

  Deprecated See BEA Commerce product offering

  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(String sequencerName,
                         String sequenceName,
                         long cacheSize)

  Deprecated See BEA Commerce product offering

  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(String sequencerName,
                         String sequenceName,
                         long cacheSize,
                         long stepSize)

  Deprecated See BEA Commerce product offering

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

### getNext

    public long getNext()
                 throws SQLException

  Deprecated See BEA Commerce product offering

  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`

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

### getCurrent

    public long getCurrent()
                    throws SQLException

  Deprecated See BEA Commerce product offering

  Gets the current sequence number associated with this sequencer.

  Throws
    ``SQLException`` - on error.
    `SQLException`

### allocateSequenceBlock

    protected final void allocateSequenceBlock()
                                        throws SQLException

  Deprecated See BEA Commerce product offering

  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 See BEA Commerce product offering

  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 See BEA Commerce product offering

  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 See BEA Commerce product offering

  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 See BEA Commerce product offering

  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 See BEA Commerce product offering

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

  Deprecated See BEA Commerce product offering

  Returns the name of this sequencer.

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

### setSequencerName

    public void setSequencerName(String sequencerName)

  Deprecated See BEA Commerce product offering

  Sets the name of this sequencer.

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

### getSequenceName

    public String getSequenceName()

  Deprecated See BEA Commerce product offering

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

  Deprecated See BEA Commerce product offering

  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
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 BEA Systems, Inc. All Rights Reserved