com.sun.rowset.providers
Class RIOptimisticProvider

java.lang.Object
  extended byjavax.sql.rowset.spi.SyncProvider
      extended bycom.sun.rowset.providers.RIOptimisticProvider
All Implemented Interfaces:
java.io.Serializable

public final class RIOptimisticProvider
extends SyncProvider
implements java.io.Serializable

The reference implementation of a JDBC Rowset synchronization provider providing optimistic synchronization with a relational datastore using any JDBC technology-enabled driver.

1.0 Backgroud

This synchronization provider is registered with the SyncFactory by default as the com.sun.rowset.providers.RIOptimisticProvider. As an extension of the SyncProvider abstract class, it provides the reader and writer classes required by disconnected rowsets as javax.sql.RowSetReader and javax.sql.RowSetWriter interface implementations. As a reference implementation, RIOptimisticProvider provides a fully functional implementation offering a medium grade classification of syncrhonization, namely GRADE_CHECK_MODIFIED_AT_COMMIT. A disconnected RowSet implementation using the RIOptimisticProvider can expect the writer to check only rows that have been modified in the RowSet against the values in the data source. If there is a conflict, that is, if a value in the data source has been changed by another party, the RIOptimisticProvider will not write any of the changes to the data source and will throw a SyncProviderException object.

2.0 Usage

Standard disconnected RowSet implementations may opt to use this SyncProvider implementation in one of two ways:
  1. By specifically calling the setSyncProvider method defined in the CachedRowSet interface
         CachedRowset crs = new FooCachedRowSetImpl();
         crs.setSyncProvider("com.sun.rowset.providers.RIOptimisticProvider"); 
     
  2. By specifying it in the constructor of the RowSet implementation
         CachedRowset crs = new FooCachedRowSetImpl(
                             "com.sun.rowset.providers.RIOptimisticProvider"); 
     
Note that because the RIOptimisticProvider implementation is the default provider, it will always be the provider when no provider ID is specified to the constructor.

See the standard RowSet reference implementations in the com.sun.rowset package for more details.

Author:
Jonathan Bruce
See Also:
SyncProvider, SyncProviderException, SyncFactory, SyncFactoryException, Serialized Form

Field Summary
 
Fields inherited from class javax.sql.rowset.spi.SyncProvider
DATASOURCE_DB_LOCK, DATASOURCE_NO_LOCK, DATASOURCE_ROW_LOCK, DATASOURCE_TABLE_LOCK, GRADE_CHECK_ALL_AT_COMMIT, GRADE_CHECK_MODIFIED_AT_COMMIT, GRADE_LOCK_WHEN_LOADED, GRADE_LOCK_WHEN_MODIFIED, GRADE_NONE, NONUPDATABLE_VIEW_SYNC, UPDATABLE_VIEW_SYNC
 
Constructor Summary
RIOptimisticProvider()
          Creates an RIOptimisticProvider object initialized with the fully qualified class name of this SyncProvider implementation and a default reader and writer.
 
Method Summary
 int getDataSourceLock()
          Returns the active data source lock severity in this reference implementation of the SyncProvider abstract class.
 int getProviderGrade()
          Returns the SyncProvider grade of synchronization that RowSet objects can expect when using this implementation.
 java.lang.String getProviderID()
          Returns the 'javax.sql.rowset.providers.RIOptimisticProvider' provider identification string.
 javax.sql.RowSetReader getRowSetReader()
          Returns the javax.sql.RowSetReader object for this RIOptimisticProvider object.
 javax.sql.RowSetWriter getRowSetWriter()
          Returns the javax.sql.RowSetWriter object for this RIOptimisticProvider object.
 java.lang.String getVendor()
          Returns the vendor name of the Reference Implemntation Optimistic Syncchronication Provider
 java.lang.String getVersion()
          Returns the release version ID of the Reference Implementation Optimistic Synchronization Provider.
 void setDataSourceLock(int datasource_lock)
          Modifies the data source lock severity according to the standard SyncProvider classifications.
 int supportsUpdatableView()
          Returns the supported updatable view abilities of the reference implementation of the SyncProvider abstract class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RIOptimisticProvider

public RIOptimisticProvider()
Creates an RIOptimisticProvider object initialized with the fully qualified class name of this SyncProvider implementation and a default reader and writer.

This provider is available to all disconnected RowSet implementations as the default persistence provider.

Method Detail

getProviderID

public java.lang.String getProviderID()
Returns the 'javax.sql.rowset.providers.RIOptimisticProvider' provider identification string.

Specified by:
getProviderID in class SyncProvider
Returns:
String Provider ID of this persistence provider

getRowSetWriter

public javax.sql.RowSetWriter getRowSetWriter()
Returns the javax.sql.RowSetWriter object for this RIOptimisticProvider object. This is the writer that will write changes made to the Rowset object back to the data source.

Specified by:
getRowSetWriter in class SyncProvider
Returns:
the javax.sql.RowSetWriter object for this RIOptimisticProvider object

getRowSetReader

public javax.sql.RowSetReader getRowSetReader()
Returns the javax.sql.RowSetReader object for this RIOptimisticProvider object. This is the reader that will populate a RowSet object using this RIOptimisticProvider.

Specified by:
getRowSetReader in class SyncProvider
Returns:
the javax.sql.RowSetReader object for this RIOptimisticProvider object

getProviderGrade

public int getProviderGrade()
Returns the SyncProvider grade of synchronization that RowSet objects can expect when using this implementation. As an optimisic synchonization provider, the writer will only check rows that have been modified in the RowSet object.

Specified by:
getProviderGrade in class SyncProvider
Returns:
an int that is one of the following constants: SyncProvider.GRADE_NONE, SyncProvider.GRADE_CHECK_MODIFIED_AT_COMMIT, SyncProvider.GRADE_CHECK_ALL_AT_COMMIT, SyncProvider.GRADE_LOCK_WHEN_MODIFIED, SyncProvider.GRADE_LOCK_WHEN_LOADED

setDataSourceLock

public void setDataSourceLock(int datasource_lock)
                       throws SyncProviderException
Modifies the data source lock severity according to the standard SyncProvider classifications.

Specified by:
setDataSourceLock in class SyncProvider
Parameters:
datasource_lock - An int indicating the level of locking to be set; must be one of the following constants:
            
       SyncProvider.DATASOURCE_NO_LOCK,
       SyncProvider.DATASOURCE_ROW_LOCK,
       SyncProvider.DATASOURCE_TABLE_LOCK,
       SyncProvider.DATASOURCE_DB_LOCk
 
Throws:
SyncProviderException - if the parameter specified is not SyncProvider.DATASOURCE_NO_LOCK
See Also:
SyncProvider.getDataSourceLock()

getDataSourceLock

public int getDataSourceLock()
                      throws SyncProviderException
Returns the active data source lock severity in this reference implementation of the SyncProvider abstract class.

Specified by:
getDataSourceLock in class SyncProvider
Returns:
SyncProvider.DATASOURCE_NO_LOCK. The reference implementation does not support data source locks.
Throws:
SyncProviderException
See Also:
SyncProvider.setDataSourceLock(int)

supportsUpdatableView

public int supportsUpdatableView()
Returns the supported updatable view abilities of the reference implementation of the SyncProvider abstract class.

Specified by:
supportsUpdatableView in class SyncProvider
Returns:
SyncProvider.NONUPDATABLE_VIEW_SYNC. The the reference implementation does not support updating tables that are the source of a view.

getVersion

public java.lang.String getVersion()
Returns the release version ID of the Reference Implementation Optimistic Synchronization Provider.

Specified by:
getVersion in class SyncProvider
Returns:
the String detailing the version number of this SyncProvider

getVendor

public java.lang.String getVendor()
Returns the vendor name of the Reference Implemntation Optimistic Syncchronication Provider

Specified by:
getVendor in class SyncProvider
Returns:
the String detailing the vendor name of this SyncProvider