org.apache.slide.store
Interface SequenceStore

All Superinterfaces:
Service, javax.transaction.xa.XAResource
All Known Subinterfaces:
Store
All Known Implementing Classes:
AbstractStore

public interface SequenceStore
extends Service

Store for sequence support. A sequence is an entity that provides unique numbers. A store supports sequences when it implements this interface and the method isSupported returns true.

Version:
$Revision: 1.3 $

Field Summary
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Method Summary
 boolean createSequence(java.lang.String sequenceName)
          Creates a sequence if it does not already exist.
 boolean isSequenceSupported()
          Checks if this store instance actually supports sequences.
 long nextSequenceValue(java.lang.String sequenceName)
          Gets the next value of the sequence.
 boolean sequenceExists(java.lang.String sequenceName)
          Checks if the sequence already exists.
 
Methods inherited from interface org.apache.slide.common.Service
cacheResults, connect, connect, connectIfNeeded, connectIfNeeded, disconnect, getLogger, initialize, isConnected, reset, setNamespace, setParameters, setScope
 
Methods inherited from interface javax.transaction.xa.XAResource
commit, end, forget, getTransactionTimeout, isSameRM, prepare, recover, rollback, setTransactionTimeout, start
 

Method Detail

isSequenceSupported

public boolean isSequenceSupported()
Checks if this store instance actually supports sequences. It may seem clear this store supports sequences as it implements this interface, but a request to the underlying persistence store might be needed to dynamically find out.

Returns:
true if the store supports sequences, false otherwise

sequenceExists

public boolean sequenceExists(java.lang.String sequenceName)
                       throws ServiceAccessException
Checks if the sequence already exists.

Parameters:
sequenceName - the name of the sequence you want to check
Returns:
true if the sequence already exists, false otherwise
Throws:
ServiceAccessException - if anything goes wrong while accessing the sequence

createSequence

public boolean createSequence(java.lang.String sequenceName)
                       throws ServiceAccessException
Creates a sequence if it does not already exist.

Parameters:
sequenceName - the name of the sequence you want to create
Returns:
true if the sequence has been created, false if it already existed
Throws:
ServiceAccessException - if anything goes wrong while accessing the sequence

nextSequenceValue

public long nextSequenceValue(java.lang.String sequenceName)
                       throws ServiceAccessException
Gets the next value of the sequence. Note that the sequence may not deliver consecutive or continuous values. The only thing that is assured is the value will be unique in the scope of the sequence, i.e. this method will never return the same value for the same sequence. A sequence of valid values might be
1,2,3,4,5,...
, but it might just as well be
10,787875845,1,2,434,...
. However, it may not be
1,2,1,3,...
. as a sequence must never return the same value twice or more times.

Returns:
the next value of the sequence
Throws:
ServiceAccessException - if anything goes wrong while accessing the sequence