Java Doc for SyncProvider.java in  » 6.0-JDK-Core » sql » javax » sql » rowset » spi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sql » javax.sql.rowset.spi 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.sql.rowset.spi.SyncProvider

SyncProvider
abstract public class SyncProvider (Code)
The synchronization mechanism that provides reader/writer capabilities for disconnected RowSet objects. A SyncProvider implementation is a class that extends the SyncProvider abstract class.

A SyncProvider implementation is identified by a unique ID, which is its fully qualified class name. This name must be registered with the SyncFactory SPI, thus making the implementation available to all RowSet implementations. The factory mechanism in the reference implementation uses this name to instantiate the implementation, which can then provide a RowSet object with its reader (a javax.sql.RowSetReader object) and its writer (a javax.sql.RowSetWriter object).

The Jdbc RowSet Implementations specification provides two reference implementations of the SyncProvider abstract class: RIOptimisticProvider and RIXMLProvider. The RIOptimisticProvider can set any RowSet implementation with a RowSetReader object and a RowSetWriter object. However, only the RIXMLProvider implementation can set an XmlReader object and an XmlWriter object. A WebRowSet object uses the XmlReader object to read data in XML format to populate itself with that data. It uses the XmlWriter object to write itself to a stream or java.io.Writer object in XML format.

1.0 Naming Convention for Implementations

As a guide to naming SyncProvider implementations, the following should be noted:
  • The name for a SyncProvider implementation is its fully qualified class name.
  • It is recommended that vendors supply a SyncProvider implementation in a package named providers.

For instance, if a vendor named Fred, Inc. offered a SyncProvider implementation, 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.HighAvailabilityProvider 
 

The following line of code uses the fully qualified name to register this implementation with the SyncFactory static instance.

 SyncFactory.registerProvider(
 "com.fred.providers.HighAvailabilityProvider");
 

The default SyncProvider object provided with the reference implementation uses the following name:

 com.sun.rowset.providers.RIOptimisticProvider 
 

A vendor can register a SyncProvider implementation class name with Sun Microsystems, Inc. by sending email to jdbc@sun.com. Sun will maintain a database listing the available SyncProvider implementations for use with compliant RowSet implementations. 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 SyncProvider implementation.

2.0 How a RowSet Object Gets Its Provider

A disconnected Rowset object may get access to a SyncProvider object in one of the following two ways:
  • Using a constructor
     CachedRowSet crs = new CachedRowSet(
     "com.fred.providers.HighAvailabilitySyncProvider"); 
     
  • Using the setSyncProvider method
     CachedRowSet crs = new CachedRowSet(); 
     crs.setSyncProvider("com.fred.providers.HighAvailabilitySyncProvider"); 
     

By default, the reference implementations of the RowSet synchronization providers are always available to the Java platform. If no other pluggable synchronization providers have been correctly registered, the SyncFactory will automatically generate an instance of the default SyncProvider reference implementation. Thus, in the preceding code fragment, if no implementation named com.fred.providers.HighAvailabilitySyncProvider has been registered with the SyncFactory instance, crs will be assigned the default provider in the reference implementation, which is com.sun.rowset.providers.RIOptimisticProvider.

3.0 Violations and Synchronization Issues

If an update between a disconnected RowSet object and a data source violates the original query or the underlying data source constraints, this will result in undefined behavior for all disconnected RowSet implementations and their designated SyncProvider implementations. Not defining the behavior when such violations occur offers greater flexibility for a SyncProvider implementation to determine its own best course of action.

A SyncProvider implementation 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 the SyncProvider implementation, all SyncProvider objects must throw a SyncProviderException.

4.0 Updatable SQL VIEWs

It is possible for any disconnected or connected RowSet object to be populated from an SQL query that is formulated originally from an SQL VIEW. 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. The SyncProvider class provides two constants to indicate whether an implementation supports updating an SQL VIEW.
  • NONUPDATABLE_VIEW_SYNC - Indicates that a SyncProvider implementation does not support synchronization with an SQL VIEW as the underlying source of data for the RowSet object.
  • UPDATABLE_VIEW_SYNC - Indicates that a SyncProvider implementation supports synchronization with an SQL VIEW as the underlying source of data.

The default is for a RowSet object not to be updatable if it was populated with data from an SQL VIEW.

5.0 SyncProvider Constants

The SyncProvider class provides three sets of constants that are used as return values or parameters for SyncProvider methods. SyncProvider objects may be implemented to perform synchronization between a RowSet object and its underlying data source with varying degrees of of care. The first group of constants indicate how synchronization is handled. For example, GRADE_NONE indicates that a SyncProvider object will not take any care to see what data is valid and will simply write the RowSet data to the data source. GRADE_MODIFIED_AT_COMMIT indicates 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.
  1. Constants to indicate the synchronization grade of a SyncProvider object
    • SyncProvider.GRADE_NONE
    • SyncProvider.GRADE_MODIFIED_AT_COMMIT
    • SyncProvider.GRADE_CHECK_ALL_AT_COMMIT
    • SyncProvider.GRADE_LOCK_WHEN_MODIFIED
    • SyncProvider.GRADE_LOCK_WHEN_LOADED
  2. 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
  3. Constants to indicate whether a SyncProvider object can perform updates to an SQL VIEW
    These constants are explained in the preceding section (4.0).
    • SyncProvider.UPDATABLE_VIEW_SYNC
    • SyncProvider.NONUPDATABLE_VIEW_SYNC

author:
   Jonathan Bruce
See Also:   javax.sql.rowset.spi.SyncFactory
See Also:   javax.sql.rowset.spi.SyncFactoryException


Field Summary
public static  intDATASOURCE_DB_LOCK
     Indicates that a lock is placed on the entire data source that is the source of data for the RowSet object that is using this SyncProvider object.
public static  intDATASOURCE_NO_LOCK
     Indicates that no locks remain on the originating data source.
public static  intDATASOURCE_ROW_LOCK
     Indicates that a lock is placed on the rows that are touched by the original SQL statement used to populate the RowSet object that is using this SyncProvider object.
public static  intDATASOURCE_TABLE_LOCK
     Indicates that a lock is placed on all tables that are touched by the original SQL statement used to populate the RowSet object that is using this SyncProvider object.
public static  intGRADE_CHECK_ALL_AT_COMMIT
     Indicates a high level optimistic synchronization grade with respect to the originating data source.
public static  intGRADE_CHECK_MODIFIED_AT_COMMIT
     Indicates a low level optimistic synchronization grade with respect to the originating data source.
public static  intGRADE_LOCK_WHEN_LOADED
     Indicates the most pessimistic synchronization grade with respect to the originating data source.
public static  intGRADE_LOCK_WHEN_MODIFIED
     Indicates a pessimistic synchronization grade with respect to the originating data source.
public static  intGRADE_NONE
     Indicates that no synchronization with the originating data source is provided.
public static  intNONUPDATABLE_VIEW_SYNC
     Indicates that a SyncProvider implementation does not support synchronization between a RowSet object and the SQL VIEW used to populate it.
public static  intUPDATABLE_VIEW_SYNC
     Indicates that a SyncProvider implementation supports synchronization between a RowSet object and the SQL VIEW used to populate it.

Constructor Summary
public  SyncProvider()
     Creates a default SyncProvider object.

Method Summary
abstract public  intgetDataSourceLock()
     Returns the current data source lock severity level active in this SyncProvider implementation.
abstract public  intgetProviderGrade()
     Returns a constant indicating the grade of synchronization a RowSet object can expect from this SyncProvider object.
abstract public  StringgetProviderID()
     Returns the unique identifier for this SyncProvider object.
abstract public  RowSetReadergetRowSetReader()
     Returns a javax.sql.RowSetReader object, which can be used to populate a RowSet object with data.
abstract public  RowSetWritergetRowSetWriter()
     Returns a javax.sql.RowSetWriter object, which can be used to write a RowSet object's data back to the underlying data source.
abstract public  StringgetVendor()
    
abstract public  StringgetVersion()
     Returns the release version of this SyncProvider instance.
abstract public  voidsetDataSourceLock(int datasource_lock)
     Sets a lock on the underlying data source at the level indicated by datasource_lock.
abstract public  intsupportsUpdatableView()
     Returns whether this SyncProvider implementation can perform synchronization between a RowSet object and the SQL VIEW in the data source from which the RowSet object got its data.

Field Detail
DATASOURCE_DB_LOCK
public static int DATASOURCE_DB_LOCK(Code)
Indicates that a lock is placed on the entire data source that is the source of data for the RowSet object that is using this SyncProvider object.



DATASOURCE_NO_LOCK
public static int DATASOURCE_NO_LOCK(Code)
Indicates that no locks remain on the originating data source. This is the default lock setting for all SyncProvider implementations unless otherwise directed by a RowSet object.



DATASOURCE_ROW_LOCK
public static int DATASOURCE_ROW_LOCK(Code)
Indicates that a lock is placed on the rows that are touched by the original SQL statement used to populate the RowSet object that is using this SyncProvider object.



DATASOURCE_TABLE_LOCK
public static int DATASOURCE_TABLE_LOCK(Code)
Indicates that a lock is placed on all tables that are touched by the original SQL statement used to populate the RowSet object that is using this SyncProvider object.



GRADE_CHECK_ALL_AT_COMMIT
public static int GRADE_CHECK_ALL_AT_COMMIT(Code)
Indicates a high level optimistic synchronization grade with respect to the originating data source. A SyncProvider implementation returning this grade will check all rows, including rows that have not changed.



GRADE_CHECK_MODIFIED_AT_COMMIT
public static int GRADE_CHECK_MODIFIED_AT_COMMIT(Code)
Indicates a low level optimistic synchronization grade with respect to the originating data source. A SyncProvider implementation returning this grade will check only rows that have changed.



GRADE_LOCK_WHEN_LOADED
public static int GRADE_LOCK_WHEN_LOADED(Code)
Indicates the most pessimistic synchronization grade with respect to the originating data source. A SyncProvider implementation returning this grade will lock the entire view and/or table affected by the original statement used to populate a RowSet object.



GRADE_LOCK_WHEN_MODIFIED
public static int GRADE_LOCK_WHEN_MODIFIED(Code)
Indicates a pessimistic synchronization grade with respect to the originating data source. A SyncProvider implementation returning this grade will lock the row in the originating data source.



GRADE_NONE
public static int GRADE_NONE(Code)
Indicates that no synchronization with the originating data source is provided. A SyncProvider implementation returning this grade will simply attempt to write updates in the RowSet object to the underlying data source without checking the validity of any data.



NONUPDATABLE_VIEW_SYNC
public static int NONUPDATABLE_VIEW_SYNC(Code)
Indicates that a SyncProvider implementation does not support synchronization between a RowSet object and the SQL VIEW used to populate it.



UPDATABLE_VIEW_SYNC
public static int UPDATABLE_VIEW_SYNC(Code)
Indicates that a SyncProvider implementation supports synchronization between a RowSet object and the SQL VIEW used to populate it.




Constructor Detail
SyncProvider
public SyncProvider()(Code)
Creates a default SyncProvider object.




Method Detail
getDataSourceLock
abstract public int getDataSourceLock() throws SyncProviderException(Code)
Returns the current data source lock severity level active in this SyncProvider implementation. a constant indicating the current level of data source lockactive in this SyncProvider object;one of the following:
SyncProvider.DATASOURCE_NO_LOCK,SyncProvider.DATASOURCE_ROW_LOCK,SyncProvider.DATASOURCE_TABLE_LOCK,SyncProvider.DATASOURCE_DB_LOCK     

throws:
  SyncProviderExceptiom - if an error occurs determining the datasource locking level.
See Also:   SyncProvider.setDataSourceLock
See Also:   



getProviderGrade
abstract public int getProviderGrade()(Code)
Returns a constant indicating the grade of synchronization a RowSet object can expect from this SyncProvider object. 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



getProviderID
abstract public String getProviderID()(Code)
Returns the unique identifier for this SyncProvider object. a String object with the fully qualified class name ofthis SyncProvider object



getRowSetReader
abstract public RowSetReader getRowSetReader()(Code)
Returns a javax.sql.RowSetReader object, which can be used to populate a RowSet object with data. a javax.sql.RowSetReader object



getRowSetWriter
abstract public RowSetWriter getRowSetWriter()(Code)
Returns a javax.sql.RowSetWriter object, which can be used to write a RowSet object's data back to the underlying data source. a javax.sql.RowSetWriter object



getVendor
abstract public String getVendor()(Code)
Returns the vendor name of this SyncProvider instance a String detailing the vendor name of thisSyncProvider implementation



getVersion
abstract public String getVersion()(Code)
Returns the release version of this SyncProvider instance. a String detailing the release version of the SyncProvider implementation



setDataSourceLock
abstract public void setDataSourceLock(int datasource_lock) throws SyncProviderException(Code)
Sets a lock on the underlying data source at the level indicated by datasource_lock. This should cause the SyncProvider to 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:   SyncProvider.getDataSourceLock



supportsUpdatableView
abstract public int supportsUpdatableView()(Code)
Returns whether this SyncProvider implementation can perform synchronization between a RowSet object and the SQL VIEW in the data source from which the RowSet object got its data. an int saying whether this SyncProviderobject supports updating an SQL VIEW; one of the following: SyncProvider.UPDATABLE_VIEW_SYNC,SyncProvider.NONUPDATABLE_VIEW_SYNC



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.