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.
SyncProvider
implementations, the following should be noted:
SyncProvider
implementation
is its fully qualified class name.
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.
RowSet
Object Gets Its ProviderRowset
object may get access to a
SyncProvider
object in one of the following two ways:
CachedRowSet crs = new CachedRowSet( "com.fred.providers.HighAvailabilitySyncProvider");
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
.
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
.
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
.
SyncProvider
ConstantsSyncProvider
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.
SyncProvider
object
SyncProvider
object can
perform updates to an SQL VIEW
SyncProvider
object.RowSet
object
that is using this SyncProvider
object.SyncProvider
implementations unless
otherwise directed by a RowSet
object.RowSet
object
that is using this SyncProvider
object.RowSet
object
that is using this SyncProvider
object.SyncProvider
implementation
returning this grade will check all rows, including rows that have not
changed.SyncProvider
implementation
returning this grade will check only rows that have changed.SyncProvider
implementation returning this grade will lock the entire view and/or
table affected by the original statement used to populate a
RowSet
object.SyncProvider
implementation returning this grade will lock the row in the originating
data source.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.SyncProvider
implementation
does not support synchronization between a RowSet
object and the SQL VIEW
used to populate it.SyncProvider
implementation
supports synchronization between a RowSet
object and
the SQL VIEW
used to populate it.
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y) consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
SyncProvider
implementation.RowSet
object can expect from
this SyncProvider
object.SyncProvider
object.javax.sql.RowSetReader
object, which can be used to
populate a RowSet
object with data.javax.sql.RowSetWriter
object, which can be
used to write a RowSet
object's data back to the
underlying data source.SyncProvider
instanceSyncProvider
instance.java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
wait
methods.
The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
synchronized
statement
that synchronizes on the object.
Class,
by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
wait
methods.
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
SyncProvider
to adjust its behavior by increasing or
decreasing the level of optimism it provides for a successful
synchronization.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.toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
either through a call to the notify
method or the
notifyAll
method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.The current thread must own this object's monitor.
This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).
If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.
Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
This method is similar to the wait
method of one
argument, but it allows finer control over the amount of time to
wait for a notification before giving up. The amount of real time,
measured in nanoseconds, is given by:
1000000*timeout+nanos
In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:
notify
method
or the notifyAll
method.
timeout
milliseconds plus nanos
nanoseconds arguments, has
elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout, nanos); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.