jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/spi/package.html
author chegar
Mon, 18 Aug 2014 10:59:36 +0100
changeset 25991 e48157b42439
parent 25976 jdk/src/share/classes/javax/sql/rowset/spi/package.html@4de01a56e3ee
parent 25859 jdk/src/share/classes/javax/sql/rowset/spi/package.html@3317bb8137f4
child 32210 958d823579c3
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
<html>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
<head>
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
     4
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
  <meta http-equiv="Content-Type"
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 content="text/html; charset=iso-8859-1">
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
     7
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
  <meta name="GENERATOR"
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
<!--
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
    11
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    16
published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    18
by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
5551
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5506
diff changeset
    30
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5506
diff changeset
    31
or visit www.oracle.com if you need additional information or have any
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5506
diff changeset
    32
questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
-->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  <title>javax.sql.rowset.spi</title>
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
    35
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
</head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  <body bgcolor="#ffffff">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
The standard classes and interfaces that a third party vendor has to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
use in its implementation of a synchronization provider. These classes and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
interfaces are referred to as the Service Provider Interface (SPI). A vendor may 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
have its implementation included on the JDBC web page that lists available
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
<code>SyncProvider</code> implementations by sending email to <code>jdbc@sun.com</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
Doing this helps make developers aware of the implementation. To make it possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
for a <code>RowSet</code> object to use an implementation, the vendor must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
it with the <code>SyncFactory</code> singleton. (See the class comment for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
<code>SyncProvider</code> for a full explanation of the registration process and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
the naming convention to be used.)
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
    49
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
<h2>Table of Contents</h2>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
<li><a href="#pkgspec">1.0 Package Specification</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
<li><a href="#arch">2.0 Service Provider Architecture</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
<li><a href="#impl">3.0 Implementer's Guide</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
<li><a href="#resolving">4.0 Resolving Synchronization Conflicts</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
<li><a href="#relspec">5.0 Related Specifications</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
<li><a href="#reldocs">6.0 Related Documentation</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
    60
<h3><a name="pkgspec">1.0 Package Specification</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
The following classes and interfaces make up the <code>javax.sql.rowset.spi</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
package:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
<UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  <LI><code>SyncFactory</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  <LI><code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  <LI><code>SyncFactoryException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  <LI><code>SyncProviderException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  <LI><code>SyncResolver</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  <LI><code>XmlReader</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  <LI><code>XmlWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  <LI><code>TransactionalWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
</UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
The following interfaces, in the <code>javax.sql</code> package, are also part of the SPI:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
<UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  <LI><code>RowSetReader</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  <LI><code>RowSetWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
</UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
A <code>SyncProvider</code> implementation provides a disconnected <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
object with the mechanisms for reading data into it and for writing data that has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
modified in it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
back to the underlying data source.  A <i>reader</i>, a <code>RowSetReader</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
<code>XMLReader</code> object, reads data into a <code>RowSet</code> object when the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
<code>CachedRowSet</code> methods <code>execute</code> or <code>populate</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
are called.  A <i>writer</i>, a <code>RowSetWriter</code> or <code>XMLWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
object, writes changes back to the underlying data source when the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
<code>CachedRowSet</code> method <code>acceptChanges</code> is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
The process of writing changes in a <code>RowSet</code> object to its data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
is known as <i>synchronization</i>.  The <code>SyncProvider</code> implementation that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
<code>RowSet</code> object is using determines the level of synchronization that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
<code>RowSet</code> object's writer uses. The various levels of synchronization are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
referred to as <i>grades</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
The lower grades of synchronization are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
known as <i>optimistic</i> concurrency levels because they optimistically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
assume that there will be no conflicts or very few conflicts.  A conflict exists when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
the same data modified in the <code>RowSet</code> object has also been modified 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
in the data source. Using the optimistic concurrency model means that if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
is a conflict, modifications to either the data source or the <code>RowSet</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
object will be lost.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
Higher grades of synchronization are called <i>pessimistic</i> because they assume
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
that others will be accessing the data source and making modifications.  These
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
grades set varying levels of locks to increase the chances that no conflicts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
The lowest level of synchronization is simply writing any changes made to the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
<code>RowSet</code> object to its underlying data source.  The writer does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
nothing to check for conflicts. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
If there is a conflict and the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
source values are overwritten, the changes other parties have made by to the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
source are lost. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
The <code>RIXMLProvider</code> implementation uses the lowest level 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
of synchronization and just writes <code>RowSet</code> changes to the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
This is true because  typically XML data sources do not enable transaction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
techniques for maintaining the integrity of data. However, specific standards 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
groups have considered offering XML-based synchronization.  For details, see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
<PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     <a href="http://www.syncml.org">http://www.syncml.org</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
<P>
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24197
diff changeset
   125
For the next level up, the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
writer checks to see if there are any conflicts, and if there are, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
it does not write anything to the data source.  The problem with this concurrency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
level is that if another party has modified the corresponding data in the data source 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
since the <code>RowSet</code> object got its data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
the changes made to the <code>RowSet</code> object are lost. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
<code>RIOptimisticProvider</code> implementation uses this level of synchronization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
At higher levels of synchronization, referred to as pessimistic concurrency,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
the writer take steps to avoid conflicts by setting locks. Setting locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
can vary from setting a lock on a single row to setting a lock on a table 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
or the entire data source. The level of synchronization is therefore a tradeoff 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
between the ability of users to access the data source concurrently and the  ability
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
of the writer to keep the data in the <code>RowSet</code> object and its data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
synchronized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
It is a requirement that all disconnected <code>RowSet</code> objects 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
(<code>CachedRowSet</code>, <code>FilteredRowSet</code>, <code>JoinRowSet</code>, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
and <code>WebRowSet</code> objects) obtain their <code>SyncProvider</code> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
from the <code>SyncFactory</code> mechanism.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
The reference implementation (RI) provides two synchronization providers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
	<UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
       <LI><b><tt>RIOptimisticProvider</tt></b> <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
           The default provider that the <code>SyncFactory</code> instance will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
           supply to a disconnected <code>RowSet</code> object when no provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
           implementation is specified.<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
           This synchronization provider uses an optimistic concurrency model,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
           assuming that there will be few conflicts among users 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
           who are accessing the same data in a database.  It avoids
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
           using locks; rather, it checks to see if there is a conflict
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
           before trying to synchronize the <code>RowSet</code> object and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
           data source. If there is a conflict, it does nothing, meaning that
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   158
           changes to the <code>RowSet</code> object are not persisted to the data
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
           source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
       <LI><B><tt>RIXMLProvider</tt></B> <BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            A synchronization provider that can be used with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            <code>WebRowSet</code> object, which is a rowset that can be written 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            in XML format or read from XML format. The 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            <code>RIXMLProvider</code> implementation does no checking at all for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            conflicts and simply writes any updated data in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            <code>WebRowSet</code> object to the underlying data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            <code>WebRowSet</code> objects use this provider when they are 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            dealing with XML data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
	</UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
These <code>SyncProvider</code> implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
are bundled with the reference implementation, which makes them always available to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
<code>RowSet</code> implementations. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
<code>SyncProvider</code> implementations make themselves available by being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
registered with the <code>SyncFactory</code> singleton.  When a <code>RowSet</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
object requests a provider, by specifying it in the constructor or as an argument to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
<code>CachedRowSet</code> method <code>setSyncProvider</code>, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
the <code>SyncFactory</code> singleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
checks to see if the requested provider has been registered with it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
If it has, the <code>SyncFactory</code> creates an instance of it and passes it to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
requesting <code>RowSet</code> object.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
If the <code>SyncProvider</code> implementation that is specified has not been registered,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
the <code>SyncFactory</code> singleton causes a <code>SyncFactoryException</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
to be thrown.  If no provider is specified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
the <code>SyncFactory</code> singleton will create an instance of the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
provider implementation, <code>RIOptimisticProvider</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
and pass it to the requesting <code>RowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
If a <code>WebRowSet</code> object does not specify a provider in its constructor, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
<code>SyncFactory</code> will give it an instance of <code>RIOptimisticProvider</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
However, the constructor for <code>WebRowSet</code> is implemented to set the provider 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
to the <code>RIXMLProvider</code>, which reads and writes a <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
in XML format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
See the <a href="SyncProvider.html">SyncProvider</a> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
Vendors may develop a <tt>SyncProvider</tt> implementation with any one of the possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
levels of synchronization, thus giving <code>RowSet</code> objects a choice of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
synchronization mechanisms.  A vendor can make its implementation available by 
6671
c5fbc05d7347 6984044: RowSet source needs to rebrand vendor references
lancea
parents: 5551
diff changeset
   202
registering the fully qualified class name with Oracle Corporation at
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
<code>jdbc@sun.com</code>. This process is discussed in further detail below. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   205
<h3><a name="arch">2.0 Service Provider Interface Architecture</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
<b>2.1 Overview</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
The Service Provider Interface provides a pluggable mechanism by which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
<code>SyncProvider</code> implementations can be registered and then generated when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
required. The lazy reference mechanism employed by the <code>SyncFactory</code> limits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
unnecessary resource consumption by not creating an instance until it is 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
required by a disconnected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
<code>RowSet</code> object. The <code>SyncFactory</code> class also provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
a standard API to configure logging options and streams that <b>may</b> be provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
by a particular <code>SyncProvider</code> implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
<b>2.2 Registering with the <code>SyncFactory</code></b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
A third party <code>SyncProvider</code> implementation must be registered with the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
<code>SyncFactory</code> in order for a disconnected <code>RowSet</code> object 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
to obtain it and thereby use its <code>javax.sql.RowSetReader</code> and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
<code>javax.sql.RowSetWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
implementations. The following registration mechanisms are available to all 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
<code>SyncProvider</code> implementations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
<li><b>System properties</b> - Properties set at the command line. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
properties are set at run time and apply system-wide per invocation of the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
application. See the section <a href="#reldocs">"Related Documentation"</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
further related information.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   230
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
<li><b>Property Files</b> - Properties specified in a standard property file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
This can be specified using a System Property or by modifying a standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
property file located in the platform run-time. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
reference implementation of this technology includes a standard property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
file than can be edited to add additional <code>SyncProvider</code> objects.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   236
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
<li><b>JNDI Context</b> - Available providers can be registered on a JNDI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
context. The <tt>SyncFactory</tt> will attempt to load <tt>SyncProvider</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
objects bound to the context and register them with the factory. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
context must be supplied to the <code>SyncFactory</code> for the mechanism to 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
function correctly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
Details on how to specify the system properties or properties in a property file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
and how to configure the JNDI Context are explained in detail in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
<a href="SyncFactory.html"><code>SyncFactory</code></a> class description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
<b>2.3 SyncFactory Provider Instance Generation Policies</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
The <code>SyncFactory</code> generates a requested <code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
object if the provider has been correctly registered.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
following policies are adhered to when either a disconnected <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
is instantiated with a specified <code>SyncProvider</code> implementation or is 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
reconfigured at runtime with an alternative <code>SyncProvider</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
<li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
contains <i>no</i> reference to the provider, a <code>SyncFactoryException</code> is 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
thrown.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   259
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
<li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
contains a reference to the provider, the requested provider is supplied.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   262
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
<li> If no <code>SyncProvider</code> object is specified, the reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
implementation provider <code>RIOptimisticProvider</code> is supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
These policies are explored in more detail in the <a href="SyncFactory.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
<code>SyncFactory</code></a> class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   270
<h3><a name="impl">3.0 SyncProvider Implementer's Guide</a></h3>
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   271
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
<b>3.1 Requirements</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
A compliant <code>SyncProvider</code> implementation that is fully pluggable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
into the <code>SyncFactory</code> <b>must</b> extend and implement all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
abstract methods in the <a href="SyncProvider.html"><code>SyncProvider</code></a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
class. In addition, an implementation <b>must</b> determine the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
grade, locking and updatable view capabilities defined in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
<code>SyncProvider</code> class definition. One or more of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
<code>SyncProvider</code> description criteria <b>must</b> be supported. It
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
is expected that vendor implementations will offer a range of grade, locking, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
updatable view capabilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
Furthermore, the <code>SyncProvider</code> naming convention <b>must</b> be followed as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
detailed in the <a href="SyncProvider.html"><code>SyncProvider</code></a> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
<b>3.2 Grades</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
JSR 114 defines a set of grades to describe the quality of synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
a <code>SyncProvider</code> object can offer a disconnected <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
object. These grades are listed from the lowest quality of service to the highest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
<li><b>GRADE_NONE</b> - No synchronization with the originating data source is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
provided. A <code>SyncProvider</code> implementation returning this grade will simply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
attempt to write any data that has changed in the <code>RowSet</code> object to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
underlying data source, overwriting whatever is there. No attempt is made to compare 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
original values with current values to see if there is a conflict. The 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
<code>RIXMLProvider</code> is implemented with this grade.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   300
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
<li><b>GRADE_CHECK_MODIFIED_AT_COMMIT</b> - A low grade of optimistic synchronization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
A <code>SyncProvider</code> implementation returning this grade
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
will check for conflicts in rows that have changed between the last synchronization 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
and the current synchronization under way. Any changes in the originating data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
that have been modified will not be reflected in the disconnected <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
object. If there are no conflicts, changes in the <code>RowSet</code> object will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
written to the data source. If there are conflicts, no changes are written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
The <code>RIOptimisticProvider</code> implementation uses this grade.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   309
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
<li><b>GRADE_CHECK_ALL_AT_COMMIT</b> - A high grade of optimistic synchronization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
A <code>SyncProvider</code> implementation   returning this grade
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
will check all rows, including rows that have not changed in the disconnected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
<code>RowSet</code> object. In this way, any changes to rows in the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
data source will be reflected in the disconnected <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
when the synchronization finishes successfully.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   316
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
<li><b>GRADE_LOCK_WHEN_MODIFIED</b> - A pessimistic grade of synchronization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
<code>SyncProvider</code> implementations returning this grade will lock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
the row in the originating  data source that corresponds to the row being changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
in the <code>RowSet</code> object to reduce the possibility of other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
processes modifying the same data in the data source.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   322
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
<li><b>GRADE_LOCK_WHEN_LOADED</b> - A higher pessimistic synchronization grade.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
A <code>SyncProvider</code> implementation returning this grade will lock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
the entire view and/or  table affected by the original query used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
populate a <code>RowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
<b>3.3 Locks</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
JSR 114 defines a set of constants that specify whether any locks have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
placed on a <code>RowSet</code> object's underlying data source and, if so,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
on which constructs the locks are placed.  These locks will remain on the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
source while the <code>RowSet</code> object is disconnected from the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
These constants <b>should</b> be considered complementary to the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
grade constants. The default setting for the majority of grade settings requires
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
that no data source locks remain when a <code>RowSet</code> object is disconnected 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
from its data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
The grades <code>GRADE_LOCK_WHEN_MODIFIED</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
<code>GRADE_LOCK_WHEN_LOADED</code> allow a disconnected <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
to have a fine-grained control over the degree of locking.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
<li><b>DATASOURCE_NO_LOCK</b> - No locks remain on the originating data source. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
This is the default lock setting for all <code>SyncProvider</code> implementations 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
unless otherwise directed by a <code>RowSet</code> object.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   347
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
<li><b>DATASOURCE_ROW_LOCK</b> - A lock is placed on the rows that are touched by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
the original SQL query used to populate the <code>RowSet</code> object.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   350
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
<li><b>DATASOURCE_TABLE_LOCK</b> - A lock is placed on all tables that are touched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
by the query that was used to populate the <code>RowSet</code> object.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   353
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
<li><b>DATASOURCE_DB_LOCK</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
A lock is placed on the entire data source that is used by the <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
<b>3.4 Updatable Views</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
A <code>RowSet</code> object may be populated with data from an SQL <code>VIEW</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
The following constants indicate whether a <code>SyncProvider</code> object can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
update data in the table or tables from which the <code>VIEW</code> was derived.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
<li><b>UPDATABLE_VIEW_SYNC</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
Indicates that a <code>SyncProvider</code> implementation  supports synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
to the table or tables from which the SQL <code>VIEW</code> used to populate  a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
a <code>RowSet</code> object is derived.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   369
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
<li><b>NONUPDATABLE_VIEW_SYNC</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
Indicates that a <code>SyncProvider</code> implementation  does <b>not</b> support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
synchronization to the table or tables from which the SQL <code>VIEW</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
used to populate  a <code>RowSet</code> object is derived.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
<b>3.5 Usage of <code>SyncProvider</code> Grading and Locking</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
In the example below, the reference <tt>CachedRowSetImpl</tt> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
reconfigures its current <tt>SyncProvider</tt> object by calling the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
<tt>setSyncProvider</tt> method.<br>
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   381
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
<PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    CachedRowSetImpl crs = new CachedRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    crs.setSyncProvider("com.foo.bar.HASyncProvider");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    An application can retrieve the <tt>SyncProvider</tt> object currently in use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
by a disconnected <code>RowSet</code> object. It can also retrieve the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
grade of synchronization with which the provider was implemented and the degree of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
locking currently in use.  In addition, an application has the flexibility to set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
the degree of locking to be used, which can increase the possibilities for successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
synchronization.  These operation are shown in the following code fragment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
<PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    SyncProvider sync = crs.getSyncProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    switch (sync.getProviderGrade()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    case: SyncProvider.GRADE_CHECK_ALL_AT_COMMIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
         //A high grade of optimistic synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    case: SyncProvider.GRADE_CHECK_MODIFIED_AT_COMMIT 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
         //A low grade of optimistic synchronization 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    case: SyncProvider.GRADE_LOCK_WHEN_LOADED 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
         // A pessimistic synchronization grade 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    case: SyncProvider.GRADE_LOCK_WHEN_MODIFIED 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
         // A pessimistic synchronization grade 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    case: SyncProvider.GRADE_NONE 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
      // No synchronization with the originating data source provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   412
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    switch (sync.getDataSourcLock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
      case: SyncProvider.DATASOURCE_DB_LOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
       // A lock is placed on the entire datasource that is used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
       // <code>RowSet</code> object 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
       break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
      case: SyncProvider.DATASOURCE_NO_LOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
       // No locks remain on the  originating data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
      case: SyncProvider.DATASOURCE_ROW_LOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
       // A lock is placed on the rows that are  touched by the original 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
       // SQL statement used to populate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
       // the RowSet object that is using the SyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
       break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
      case: DATASOURCE_TABLE_LOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
       // A lock is placed on  all tables that are touched by the original 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
       // SQL statement used to populated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
       // the RowSet object that is using the SyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
       break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    It is also possible using the static utility method in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
<code>SyncFactory</code> class to determine the list of <code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
implementations currently registered with the <code>SyncFactory</code>.
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   439
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
<pre>
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   441
       Enumeration e = SyncFactory.getRegisteredProviders();
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   442
</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   445
<h3><a name="resolving">4.0 Resolving Synchronization Conflicts</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
The interface <code>SyncResolver</code> provides a way for an application to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
decide manually what to do when a conflict occurs. When the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
method <code>acceptChanges</code> finishes and has detected one or more conflicts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
it throws a <code>SyncProviderException</code> object.  An application can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
catch the exception and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
have it retrieve a <code>SyncResolver</code> object by calling the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
<code>SyncProviderException.getSyncResolver()</code>. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
A <code>SyncResolver</code> object, which is a special kind of 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
<code>CachedRowSet</code> object or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
a <code>JdbcRowSet</code> object that has implemented the <code>SyncResolver</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
interface,  examines the conflicts row by row. It is a duplicate of the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
<code>RowSet</code> object being synchronized except that it contains only the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
from the data source this is causing a conflict. All of the other column values are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
set to <code>null</code>. To navigate from one conflict value to another, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
<code>SyncResolver</code> object provides the methods <code>nextConflict</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
<code>previousConflict</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
The <code>SyncResolver</code> interface also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
provides methods for doing the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
<UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
 <LI>finding out whether the conflict involved an update, a delete, or an insert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
 <LI>getting the value in the data source that caused the conflict
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
 <LI>setting the value that should be in the data source if it needs to be changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     or setting the value that should be in the <code>RowSet</code> object if it needs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     to be changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
</UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
When the <code>CachedRowSet</code> method <code>acceptChanges</code> is called, it 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
delegates to the <code>RowSet</code> object's  <code>SyncProvider</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
How the writer provided by that <code>SyncProvider</code> object is implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
determines what level (grade) of checking for conflicts will be done.  After all 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
checking for conflicts is completed and one or more conflicts has been found, the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
<code>acceptChanges</code> throws a <code>SyncProviderException</code> object. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
application can catch the exception and use it to obtain a <code>SyncResolver</code> object.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
The application can then use <code>SyncResolver</code> methods to get information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
about each conflict and decide what to do.  If the application logic or the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
decides that a value in the <code>RowSet</code> object should be the one to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
persist, the application or user can overwrite the data source value with it.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
The comment for the <code>SyncResolver</code> interface has more detail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   490
<h3><a name="relspec">5.0 Related Specifications</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
<ul>
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   492
<li><a href="http://docs.oracle.com/javase/jndi/tutorial/index.html">JNDI</a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
<li><a href="{@docRoot}/../technotes/guides/logging/index.html">Java Logging
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
APIs</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
</ul>
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   496
<h3><a name="reldocs">6.0 Related Documentation</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
<li><a href="{@docRoot}/../technotes/tools/index.html#basic">System
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
properties</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
<li>Resource Files
24197
a5c2cff81e25 8039488: Tidy warnings cleanup for javax.sql
yan
parents: 6671
diff changeset
   501
<li><a href="http://docs.oracle.com/javase/tutorial/jdbc/">DataSource for JDBC
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
Connections</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
</body>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
</html>