- java.lang.Object
-
- javax.sql.rowset.spi.SyncProvider
-
public abstract class SyncProvider extends Object
The synchronization mechanism that provides reader/writer capabilities for disconnectedRowSetobjects. ASyncProviderimplementation is a class that extends theSyncProviderabstract class.A
SyncProviderimplementation is identified by a unique ID, which is its fully qualified class name. This name must be registered with theSyncFactorySPI, thus making the implementation available to allRowSetimplementations. The factory mechanism in the reference implementation uses this name to instantiate the implementation, which can then provide aRowSetobject with its reader (ajavax.sql.RowSetReaderobject) and its writer (ajavax.sql.RowSetWriterobject).The Jdbc
RowSetImplementations specification provides two reference implementations of theSyncProviderabstract class:RIOptimisticProviderandRIXMLProvider. TheRIOptimisticProvidercan set anyRowSetimplementation with aRowSetReaderobject and aRowSetWriterobject. However, only theRIXMLProviderimplementation can set anXmlReaderobject and anXmlWriterobject. AWebRowSetobject uses theXmlReaderobject to read data in XML format to populate itself with that data. It uses theXmlWriterobject to write itself to a stream orjava.io.Writerobject in XML format.1.0 Naming Convention for Implementations
As a guide to namingSyncProviderimplementations, the following should be noted:- The name for a
SyncProviderimplementation is its fully qualified class name. - It is recommended that vendors supply a
SyncProviderimplementation in a package namedproviders.
For instance, if a vendor named Fred, Inc. offered a
SyncProviderimplementation, you could have the following:Vendor name: Fred, Inc. Domain name of vendor: com.fred Package name: com.fred.providers SyncProvider implementation class name: HighAvailabilityProvider Fully qualified class name of SyncProvider implementation: com.fred.providers.HighAvailabilityProviderThe following line of code uses the fully qualified name to register this implementation with the
SyncFactorystatic instance.SyncFactory.registerProvider( "com.fred.providers.HighAvailabilityProvider");The default
SyncProviderobject provided with the reference implementation uses the following name:com.sun.rowset.providers.RIOptimisticProviderA vendor can register a
SyncProviderimplementation class name with Oracle Corporation by sending email to jdbc@sun.com. Oracle will maintain a database listing the availableSyncProviderimplementations for use with compliantRowSetimplementations. This database will be similar to the one already maintained to list available JDBC drivers.Vendors should refer to the reference implementation synchronization providers for additional guidance on how to implement a new
SyncProviderimplementation.2.0 How a
A disconnectedRowSetObject Gets Its ProviderRowsetobject may get access to aSyncProviderobject in one of the following two ways:- Using a constructor
CachedRowSet crs = new CachedRowSet( "com.fred.providers.HighAvailabilitySyncProvider"); - Using the
setSyncProvidermethodCachedRowSet crs = new CachedRowSet(); crs.setSyncProvider("com.fred.providers.HighAvailabilitySyncProvider");
By default, the reference implementations of the
RowSetsynchronization providers are always available to the Java platform. If no other pluggable synchronization providers have been correctly registered, theSyncFactorywill automatically generate an instance of the defaultSyncProviderreference implementation. Thus, in the preceding code fragment, if no implementation namedcom.fred.providers.HighAvailabilitySyncProviderhas been registered with theSyncFactoryinstance, crs will be assigned the default provider in the reference implementation, which iscom.sun.rowset.providers.RIOptimisticProvider.3.0 Violations and Synchronization Issues
If an update between a disconnectedRowSetobject and a data source violates the original query or the underlying data source constraints, this will result in undefined behavior for all disconnectedRowSetimplementations and their designatedSyncProviderimplementations. Not defining the behavior when such violations occur offers greater flexibility for aSyncProviderimplementation to determine its own best course of action.A
SyncProviderimplementation may choose to implement a specific handler to handle a subset of query violations. However if an original query violation or a more general data source constraint violation is not handled by theSyncProviderimplementation, allSyncProviderobjects must throw aSyncProviderException.4.0 Updatable SQL VIEWs
It is possible for any disconnected or connectedRowSetobject to be populated from an SQL query that is formulated originally from an SQLVIEW. While in many cases it is possible for an update to be performed to an underlying view, such an update requires additional metadata, which may vary. TheSyncProviderclass provides two constants to indicate whether an implementation supports updating an SQLVIEW.NONUPDATABLE_VIEW_SYNC- Indicates that aSyncProviderimplementation does not support synchronization with an SQLVIEWas the underlying source of data for theRowSetobject.UPDATABLE_VIEW_SYNC- Indicates that aSyncProviderimplementation supports synchronization with an SQLVIEWas the underlying source of data.
The default is for a
RowSetobject not to be updatable if it was populated with data from an SQLVIEW.5.0
TheSyncProviderConstantsSyncProviderclass provides three sets of constants that are used as return values or parameters forSyncProvidermethods.SyncProviderobjects may be implemented to perform synchronization between aRowSetobject and its underlying data source with varying degrees of care. The first group of constants indicate how synchronization is handled. For example,GRADE_NONEindicates that aSyncProviderobject will not take any care to see what data is valid and will simply write theRowSetdata to the data source.GRADE_MODIFIED_AT_COMMITindicates that the provider will check only modified data for validity. Other grades check all data for validity or set locks when data is modified or loaded.- Constants to indicate the synchronization grade of a
SyncProviderobject- SyncProvider.GRADE_NONE
- SyncProvider.GRADE_MODIFIED_AT_COMMIT
- SyncProvider.GRADE_CHECK_ALL_AT_COMMIT
- SyncProvider.GRADE_LOCK_WHEN_MODIFIED
- SyncProvider.GRADE_LOCK_WHEN_LOADED
- Constants to indicate what locks are set on the data source
- SyncProvider.DATASOURCE_NO_LOCK
- SyncProvider.DATASOURCE_ROW_LOCK
- SyncProvider.DATASOURCE_TABLE_LOCK
- SyncProvider.DATASOURCE_DB_LOCK
- Constants to indicate whether a
SyncProviderobject can perform updates to an SQLVIEW
These constants are explained in the preceding section (4.0).- SyncProvider.UPDATABLE_VIEW_SYNC
- SyncProvider.NONUPDATABLE_VIEW_SYNC
- Since:
- 1.5
- See Also:
SyncFactory,SyncFactoryException
- The name for a
-
-
Field Summary
Fields Modifier and Type Field Description static intDATASOURCE_DB_LOCKIndicates that a lock is placed on the entire data source that is the source of data for theRowSetobject that is using thisSyncProviderobject.static intDATASOURCE_NO_LOCKIndicates that no locks remain on the originating data source.static intDATASOURCE_ROW_LOCKIndicates that a lock is placed on the rows that are touched by the original SQL statement used to populate theRowSetobject that is using thisSyncProviderobject.static intDATASOURCE_TABLE_LOCKIndicates that a lock is placed on all tables that are touched by the original SQL statement used to populate theRowSetobject that is using thisSyncProviderobject.static intGRADE_CHECK_ALL_AT_COMMITIndicates a high level optimistic synchronization grade with respect to the originating data source.static intGRADE_CHECK_MODIFIED_AT_COMMITIndicates a low level optimistic synchronization grade with respect to the originating data source.static intGRADE_LOCK_WHEN_LOADEDIndicates the most pessimistic synchronization grade with respect to the originating data source.static intGRADE_LOCK_WHEN_MODIFIEDIndicates a pessimistic synchronization grade with respect to the originating data source.static intGRADE_NONEIndicates that no synchronization with the originating data source is provided.static intNONUPDATABLE_VIEW_SYNCIndicates that aSyncProviderimplementation does not support synchronization between aRowSetobject and the SQLVIEWused to populate it.static intUPDATABLE_VIEW_SYNCIndicates that aSyncProviderimplementation supports synchronization between aRowSetobject and the SQLVIEWused to populate it.
-
Constructor Summary
Constructors Constructor Description SyncProvider()Creates a defaultSyncProviderobject.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract intgetDataSourceLock()Returns the current data source lock severity level active in thisSyncProviderimplementation.abstract intgetProviderGrade()Returns a constant indicating the grade of synchronization aRowSetobject can expect from thisSyncProviderobject.abstract StringgetProviderID()Returns the unique identifier for thisSyncProviderobject.abstract RowSetReadergetRowSetReader()Returns ajavax.sql.RowSetReaderobject, which can be used to populate aRowSetobject with data.abstract RowSetWritergetRowSetWriter()Returns ajavax.sql.RowSetWriterobject, which can be used to write aRowSetobject's data back to the underlying data source.abstract StringgetVendor()Returns the vendor name of thisSyncProviderinstanceabstract StringgetVersion()Returns the release version of thisSyncProviderinstance.abstract voidsetDataSourceLock(int datasource_lock)Sets a lock on the underlying data source at the level indicated by datasource_lock.abstract intsupportsUpdatableView()Returns whether thisSyncProviderimplementation can perform synchronization between aRowSetobject and the SQLVIEWin the data source from which theRowSetobject got its data.
-
-
-
Field Detail
-
GRADE_NONE
public static final int GRADE_NONE
Indicates that no synchronization with the originating data source is provided. ASyncProviderimplementation returning this grade will simply attempt to write updates in theRowSetobject to the underlying data source without checking the validity of any data.- See Also:
- Constant Field Values
-
GRADE_CHECK_MODIFIED_AT_COMMIT
public static final int GRADE_CHECK_MODIFIED_AT_COMMIT
Indicates a low level optimistic synchronization grade with respect to the originating data source. ASyncProviderimplementation returning this grade will check only rows that have changed.- See Also:
- Constant Field Values
-
GRADE_CHECK_ALL_AT_COMMIT
public static final int GRADE_CHECK_ALL_AT_COMMIT
Indicates a high level optimistic synchronization grade with respect to the originating data source. ASyncProviderimplementation returning this grade will check all rows, including rows that have not changed.- See Also:
- Constant Field Values
-
GRADE_LOCK_WHEN_MODIFIED
public static final int GRADE_LOCK_WHEN_MODIFIED
Indicates a pessimistic synchronization grade with respect to the originating data source. ASyncProviderimplementation returning this grade will lock the row in the originating data source.- See Also:
- Constant Field Values
-
GRADE_LOCK_WHEN_LOADED
public static final int GRADE_LOCK_WHEN_LOADED
Indicates the most pessimistic synchronization grade with respect to the originating data source. ASyncProviderimplementation returning this grade will lock the entire view and/or table affected by the original statement used to populate aRowSetobject.- See Also:
- Constant Field Values
-
DATASOURCE_NO_LOCK
public static final int DATASOURCE_NO_LOCK
Indicates that no locks remain on the originating data source. This is the default lock setting for allSyncProviderimplementations unless otherwise directed by aRowSetobject.- See Also:
- Constant Field Values
-
DATASOURCE_ROW_LOCK
public static final int DATASOURCE_ROW_LOCK
Indicates that a lock is placed on the rows that are touched by the original SQL statement used to populate theRowSetobject that is using thisSyncProviderobject.- See Also:
- Constant Field Values
-
DATASOURCE_TABLE_LOCK
public static final int DATASOURCE_TABLE_LOCK
Indicates that a lock is placed on all tables that are touched by the original SQL statement used to populate theRowSetobject that is using thisSyncProviderobject.- See Also:
- Constant Field Values
-
DATASOURCE_DB_LOCK
public static final int DATASOURCE_DB_LOCK
Indicates that a lock is placed on the entire data source that is the source of data for theRowSetobject that is using thisSyncProviderobject.- See Also:
- Constant Field Values
-
UPDATABLE_VIEW_SYNC
public static final int UPDATABLE_VIEW_SYNC
Indicates that aSyncProviderimplementation supports synchronization between aRowSetobject and the SQLVIEWused to populate it.- See Also:
- Constant Field Values
-
NONUPDATABLE_VIEW_SYNC
public static final int NONUPDATABLE_VIEW_SYNC
Indicates that aSyncProviderimplementation does not support synchronization between aRowSetobject and the SQLVIEWused to populate it.- See Also:
- Constant Field Values
-
-
Method Detail
-
getProviderID
public abstract String getProviderID()
Returns the unique identifier for thisSyncProviderobject.- Returns:
- a
Stringobject with the fully qualified class name of thisSyncProviderobject
-
getRowSetReader
public abstract RowSetReader getRowSetReader()
Returns ajavax.sql.RowSetReaderobject, which can be used to populate aRowSetobject with data.- Returns:
- a
javax.sql.RowSetReaderobject
-
getRowSetWriter
public abstract RowSetWriter getRowSetWriter()
Returns ajavax.sql.RowSetWriterobject, which can be used to write aRowSetobject's data back to the underlying data source.- Returns:
- a
javax.sql.RowSetWriterobject
-
getProviderGrade
public abstract int getProviderGrade()
Returns a constant indicating the grade of synchronization aRowSetobject can expect from thisSyncProviderobject.- 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 abstract void setDataSourceLock(int datasource_lock) throws SyncProviderExceptionSets a lock on the underlying data source at the level indicated by datasource_lock. This should cause theSyncProviderto adjust its behavior by increasing or decreasing the level of optimism it provides for a successful synchronization.- Parameters:
datasource_lock- one of the following constants indicating the severity level of data source lock required:SyncProvider.DATASOURCE_NO_LOCK, SyncProvider.DATASOURCE_ROW_LOCK, SyncProvider.DATASOURCE_TABLE_LOCK, SyncProvider.DATASOURCE_DB_LOCK,- Throws:
SyncProviderException- if an unsupported data source locking level is set.- See Also:
getDataSourceLock()
-
getDataSourceLock
public abstract int getDataSourceLock() throws SyncProviderExceptionReturns the current data source lock severity level active in thisSyncProviderimplementation.- Returns:
- a constant indicating the current level of data source lock
active in this
SyncProviderobject; one of the following:SyncProvider.DATASOURCE_NO_LOCK, SyncProvider.DATASOURCE_ROW_LOCK, SyncProvider.DATASOURCE_TABLE_LOCK, SyncProvider.DATASOURCE_DB_LOCK - Throws:
SyncProviderException- if an error occurs determining the data source locking level.- See Also:
setDataSourceLock(int)
-
supportsUpdatableView
public abstract int supportsUpdatableView()
Returns whether thisSyncProviderimplementation can perform synchronization between aRowSetobject and the SQLVIEWin the data source from which theRowSetobject got its data.- Returns:
- an
intsaying whether thisSyncProviderobject supports updating an SQLVIEW; one of the following: SyncProvider.UPDATABLE_VIEW_SYNC, SyncProvider.NONUPDATABLE_VIEW_SYNC
-
getVersion
public abstract String getVersion()
Returns the release version of thisSyncProviderinstance.- Returns:
- a
Stringdetailing the release version of theSyncProviderimplementation
-
getVendor
public abstract String getVendor()
Returns the vendor name of thisSyncProviderinstance- Returns:
- a
Stringdetailing the vendor name of thisSyncProviderimplementation
-
-