1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en"> |
1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en"> |
2 <html> |
2 <html> |
3 <head> |
3 <head> |
4 |
4 |
5 <meta http-equiv="Content-Type" |
5 <meta http-equiv="Content-Type" |
6 content="text/html; charset=iso-8859-1"> |
6 content="text/html; charset=iso-8859-1"> |
7 |
7 |
8 <meta name="GENERATOR" |
8 <meta name="GENERATOR" |
9 content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]"> |
9 content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]"> |
10 <!-- |
10 <!-- |
11 Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
11 Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
12 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
12 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
13 |
13 |
14 This code is free software; you can redistribute it and/or modify it |
14 This code is free software; you can redistribute it and/or modify it |
15 under the terms of the GNU General Public License version 2 only, as |
15 under the terms of the GNU General Public License version 2 only, as |
16 published by the Free Software Foundation. Oracle designates this |
16 published by the Free Software Foundation. Oracle designates this |
30 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
30 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
31 or visit www.oracle.com if you need additional information or have any |
31 or visit www.oracle.com if you need additional information or have any |
32 questions. |
32 questions. |
33 --> |
33 --> |
34 <title>javax.sql.rowset.spi</title> |
34 <title>javax.sql.rowset.spi</title> |
35 |
35 |
36 </head> |
36 </head> |
37 <body bgcolor="#ffffff"> |
37 <body bgcolor="#ffffff"> |
38 |
38 |
39 The standard classes and interfaces that a third party vendor has to |
39 The standard classes and interfaces that a third party vendor has to |
40 use in its implementation of a synchronization provider. These classes and |
40 use in its implementation of a synchronization provider. These classes and |
44 Doing this helps make developers aware of the implementation. To make it possible |
44 Doing this helps make developers aware of the implementation. To make it possible |
45 for a <code>RowSet</code> object to use an implementation, the vendor must register |
45 for a <code>RowSet</code> object to use an implementation, the vendor must register |
46 it with the <code>SyncFactory</code> singleton. (See the class comment for |
46 it with the <code>SyncFactory</code> singleton. (See the class comment for |
47 <code>SyncProvider</code> for a full explanation of the registration process and |
47 <code>SyncProvider</code> for a full explanation of the registration process and |
48 the naming convention to be used.) |
48 the naming convention to be used.) |
49 <P> |
49 |
50 <h2>Table of Contents</h2> |
50 <h2>Table of Contents</h2> |
51 <ul> |
51 <ul> |
52 <li><a href="#pkgspec">1.0 Package Specification</a> |
52 <li><a href="#pkgspec">1.0 Package Specification</a> |
53 <li><a href="#arch">2.0 Service Provider Architecture</a> |
53 <li><a href="#arch">2.0 Service Provider Architecture</a> |
54 <li><a href="#impl">3.0 Implementer's Guide</a> |
54 <li><a href="#impl">3.0 Implementer's Guide</a> |
55 <li><a href="#resolving">4.0 Resolving Synchronization Conflicts</a> |
55 <li><a href="#resolving">4.0 Resolving Synchronization Conflicts</a> |
56 <li><a href="#relspec">5.0 Related Specifications</a> |
56 <li><a href="#relspec">5.0 Related Specifications</a> |
57 <li><a href="#reldocs">6.0 Related Documentation</a> |
57 <li><a href="#reldocs">6.0 Related Documentation</a> |
58 </ul> |
58 </ul> |
59 |
59 |
60 <h3><a name="pkgspec">1.0 Package Specification</h3> |
60 <h3><a name="pkgspec">1.0 Package Specification</a></h3> |
61 <P> |
61 <P> |
62 The following classes and interfaces make up the <code>javax.sql.rowset.spi</code> |
62 The following classes and interfaces make up the <code>javax.sql.rowset.spi</code> |
63 package: |
63 package: |
64 <UL> |
64 <UL> |
65 <LI><code>SyncFactory</code> |
65 <LI><code>SyncFactory</code> |
153 assuming that there will be few conflicts among users |
153 assuming that there will be few conflicts among users |
154 who are accessing the same data in a database. It avoids |
154 who are accessing the same data in a database. It avoids |
155 using locks; rather, it checks to see if there is a conflict |
155 using locks; rather, it checks to see if there is a conflict |
156 before trying to synchronize the <code>RowSet</code> object and the |
156 before trying to synchronize the <code>RowSet</code> object and the |
157 data source. If there is a conflict, it does nothing, meaning that |
157 data source. If there is a conflict, it does nothing, meaning that |
158 changes to the <code>RowSet</code> object are not persisted to the data |
158 changes to the <code>RowSet</code> object are not persisted to the data |
159 source. |
159 source. |
160 <LI><B><tt>RIXMLProvider</tt></B> <BR> |
160 <LI><B><tt>RIXMLProvider</tt></B> <BR> |
161 A synchronization provider that can be used with a |
161 A synchronization provider that can be used with a |
162 <code>WebRowSet</code> object, which is a rowset that can be written |
162 <code>WebRowSet</code> object, which is a rowset that can be written |
163 in XML format or read from XML format. The |
163 in XML format or read from XML format. The |
199 Vendors may develop a <tt>SyncProvider</tt> implementation with any one of the possible |
199 Vendors may develop a <tt>SyncProvider</tt> implementation with any one of the possible |
200 levels of synchronization, thus giving <code>RowSet</code> objects a choice of |
200 levels of synchronization, thus giving <code>RowSet</code> objects a choice of |
201 synchronization mechanisms. A vendor can make its implementation available by |
201 synchronization mechanisms. A vendor can make its implementation available by |
202 registering the fully qualified class name with Oracle Corporation at |
202 registering the fully qualified class name with Oracle Corporation at |
203 <code>jdbc@sun.com</code>. This process is discussed in further detail below. |
203 <code>jdbc@sun.com</code>. This process is discussed in further detail below. |
204 <P> |
204 |
205 |
205 <h3><a name="arch">2.0 Service Provider Interface Architecture</a></h3> |
206 <a name="arch"><h3>2.0 Service Provider Interface Architecture</h3> |
|
207 <ul> |
|
208 <b>2.1 Overview</b> |
206 <b>2.1 Overview</b> |
209 <p> |
207 <p> |
210 The Service Provider Interface provides a pluggable mechanism by which |
208 The Service Provider Interface provides a pluggable mechanism by which |
211 <code>SyncProvider</code> implementations can be registered and then generated when |
209 <code>SyncProvider</code> implementations can be registered and then generated when |
212 required. The lazy reference mechanism employed by the <code>SyncFactory</code> limits |
210 required. The lazy reference mechanism employed by the <code>SyncFactory</code> limits |
227 <ul> |
225 <ul> |
228 <li><b>System properties</b> - Properties set at the command line. These |
226 <li><b>System properties</b> - Properties set at the command line. These |
229 properties are set at run time and apply system-wide per invocation of the Java |
227 properties are set at run time and apply system-wide per invocation of the Java |
230 application. See the section <a href="#reldocs">"Related Documentation"</a> |
228 application. See the section <a href="#reldocs">"Related Documentation"</a> |
231 further related information. |
229 further related information. |
232 <p> |
230 |
233 <li><b>Property Files</b> - Properties specified in a standard property file. |
231 <li><b>Property Files</b> - Properties specified in a standard property file. |
234 This can be specified using a System Property or by modifying a standard |
232 This can be specified using a System Property or by modifying a standard |
235 property file located in the platform run-time. The |
233 property file located in the platform run-time. The |
236 reference implementation of this technology includes a standard property |
234 reference implementation of this technology includes a standard property |
237 file than can be edited to add additional <code>SyncProvider</code> objects. |
235 file than can be edited to add additional <code>SyncProvider</code> objects. |
238 <p> |
236 |
239 <li><b>JNDI Context</b> - Available providers can be registered on a JNDI |
237 <li><b>JNDI Context</b> - Available providers can be registered on a JNDI |
240 context. The <tt>SyncFactory</tt> will attempt to load <tt>SyncProvider</tt> |
238 context. The <tt>SyncFactory</tt> will attempt to load <tt>SyncProvider</tt> |
241 objects bound to the context and register them with the factory. This |
239 objects bound to the context and register them with the factory. This |
242 context must be supplied to the <code>SyncFactory</code> for the mechanism to |
240 context must be supplied to the <code>SyncFactory</code> for the mechanism to |
243 function correctly. |
241 function correctly. |
256 reconfigured at runtime with an alternative <code>SyncProvider</code> object. |
254 reconfigured at runtime with an alternative <code>SyncProvider</code> object. |
257 <ul> |
255 <ul> |
258 <li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code> |
256 <li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code> |
259 contains <i>no</i> reference to the provider, a <code>SyncFactoryException</code> is |
257 contains <i>no</i> reference to the provider, a <code>SyncFactoryException</code> is |
260 thrown. |
258 thrown. |
261 <p> |
259 |
262 <li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code> |
260 <li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code> |
263 contains a reference to the provider, the requested provider is supplied. |
261 contains a reference to the provider, the requested provider is supplied. |
264 <p> |
262 |
265 <li> If no <code>SyncProvider</code> object is specified, the reference |
263 <li> If no <code>SyncProvider</code> object is specified, the reference |
266 implementation provider <code>RIOptimisticProvider</code> is supplied. |
264 implementation provider <code>RIOptimisticProvider</code> is supplied. |
267 </ul> |
265 </ul> |
268 <p> |
266 <p> |
269 These policies are explored in more detail in the <a href="SyncFactory.html"> |
267 These policies are explored in more detail in the <a href="SyncFactory.html"> |
270 <code>SyncFactory</code></a> class. |
268 <code>SyncFactory</code></a> class. |
271 </ul> |
269 |
272 |
270 <h3><a name="impl">3.0 SyncProvider Implementer's Guide</a></h3> |
273 <li><a name="impl"><h3>3.0 SyncProvider Implementer's Guide</h3> |
271 |
274 <ul> |
|
275 <b>3.1 Requirements</b> |
272 <b>3.1 Requirements</b> |
276 <p> |
273 <p> |
277 A compliant <code>SyncProvider</code> implementation that is fully pluggable |
274 A compliant <code>SyncProvider</code> implementation that is fully pluggable |
278 into the <code>SyncFactory</code> <b>must</b> extend and implement all |
275 into the <code>SyncFactory</code> <b>must</b> extend and implement all |
279 abstract methods in the <a href="SyncProvider.html"><code>SyncProvider</code></a> |
276 abstract methods in the <a href="SyncProvider.html"><code>SyncProvider</code></a> |
298 provided. A <code>SyncProvider</code> implementation returning this grade will simply |
295 provided. A <code>SyncProvider</code> implementation returning this grade will simply |
299 attempt to write any data that has changed in the <code>RowSet</code> object to the |
296 attempt to write any data that has changed in the <code>RowSet</code> object to the |
300 underlying data source, overwriting whatever is there. No attempt is made to compare |
297 underlying data source, overwriting whatever is there. No attempt is made to compare |
301 original values with current values to see if there is a conflict. The |
298 original values with current values to see if there is a conflict. The |
302 <code>RIXMLProvider</code> is implemented with this grade. |
299 <code>RIXMLProvider</code> is implemented with this grade. |
303 <p> |
300 |
304 <li><b>GRADE_CHECK_MODIFIED_AT_COMMIT</b> - A low grade of optimistic synchronization. |
301 <li><b>GRADE_CHECK_MODIFIED_AT_COMMIT</b> - A low grade of optimistic synchronization. |
305 A <code>SyncProvider</code> implementation returning this grade |
302 A <code>SyncProvider</code> implementation returning this grade |
306 will check for conflicts in rows that have changed between the last synchronization |
303 will check for conflicts in rows that have changed between the last synchronization |
307 and the current synchronization under way. Any changes in the originating data source |
304 and the current synchronization under way. Any changes in the originating data source |
308 that have been modified will not be reflected in the disconnected <code>RowSet</code> |
305 that have been modified will not be reflected in the disconnected <code>RowSet</code> |
309 object. If there are no conflicts, changes in the <code>RowSet</code> object will be |
306 object. If there are no conflicts, changes in the <code>RowSet</code> object will be |
310 written to the data source. If there are conflicts, no changes are written. |
307 written to the data source. If there are conflicts, no changes are written. |
311 The <code>RIOptimisticProvider</code> implementation uses this grade. |
308 The <code>RIOptimisticProvider</code> implementation uses this grade. |
312 <p> |
309 |
313 <li><b>GRADE_CHECK_ALL_AT_COMMIT</b> - A high grade of optimistic synchronization. |
310 <li><b>GRADE_CHECK_ALL_AT_COMMIT</b> - A high grade of optimistic synchronization. |
314 A <code>SyncProvider</code> implementation returning this grade |
311 A <code>SyncProvider</code> implementation returning this grade |
315 will check all rows, including rows that have not changed in the disconnected |
312 will check all rows, including rows that have not changed in the disconnected |
316 <code>RowSet</code> object. In this way, any changes to rows in the underlying |
313 <code>RowSet</code> object. In this way, any changes to rows in the underlying |
317 data source will be reflected in the disconnected <code>RowSet</code> object |
314 data source will be reflected in the disconnected <code>RowSet</code> object |
318 when the synchronization finishes successfully. |
315 when the synchronization finishes successfully. |
319 <p> |
316 |
320 <li><b>GRADE_LOCK_WHEN_MODIFIED</b> - A pessimistic grade of synchronization. |
317 <li><b>GRADE_LOCK_WHEN_MODIFIED</b> - A pessimistic grade of synchronization. |
321 <code>SyncProvider</code> implementations returning this grade will lock |
318 <code>SyncProvider</code> implementations returning this grade will lock |
322 the row in the originating data source that corresponds to the row being changed |
319 the row in the originating data source that corresponds to the row being changed |
323 in the <code>RowSet</code> object to reduce the possibility of other |
320 in the <code>RowSet</code> object to reduce the possibility of other |
324 processes modifying the same data in the data source. |
321 processes modifying the same data in the data source. |
325 <p> |
322 |
326 <li><b>GRADE_LOCK_WHEN_LOADED</b> - A higher pessimistic synchronization grade. |
323 <li><b>GRADE_LOCK_WHEN_LOADED</b> - A higher pessimistic synchronization grade. |
327 A <code>SyncProvider</code> implementation returning this grade will lock |
324 A <code>SyncProvider</code> implementation returning this grade will lock |
328 the entire view and/or table affected by the original query used to |
325 the entire view and/or table affected by the original query used to |
329 populate a <code>RowSet</code> object. |
326 populate a <code>RowSet</code> object. |
330 </ul> |
327 </ul> |
345 to have a fine-grained control over the degree of locking. |
342 to have a fine-grained control over the degree of locking. |
346 <ul> |
343 <ul> |
347 <li><b>DATASOURCE_NO_LOCK</b> - No locks remain on the originating data source. |
344 <li><b>DATASOURCE_NO_LOCK</b> - No locks remain on the originating data source. |
348 This is the default lock setting for all <code>SyncProvider</code> implementations |
345 This is the default lock setting for all <code>SyncProvider</code> implementations |
349 unless otherwise directed by a <code>RowSet</code> object. |
346 unless otherwise directed by a <code>RowSet</code> object. |
350 <p> |
347 |
351 <li><b>DATASOURCE_ROW_LOCK</b> - A lock is placed on the rows that are touched by |
348 <li><b>DATASOURCE_ROW_LOCK</b> - A lock is placed on the rows that are touched by |
352 the original SQL query used to populate the <code>RowSet</code> object. |
349 the original SQL query used to populate the <code>RowSet</code> object. |
353 <p> |
350 |
354 <li><b>DATASOURCE_TABLE_LOCK</b> - A lock is placed on all tables that are touched |
351 <li><b>DATASOURCE_TABLE_LOCK</b> - A lock is placed on all tables that are touched |
355 by the query that was used to populate the <code>RowSet</code> object. |
352 by the query that was used to populate the <code>RowSet</code> object. |
356 <p> |
353 |
357 <li><b>DATASOURCE_DB_LOCK</b> |
354 <li><b>DATASOURCE_DB_LOCK</b> |
358 A lock is placed on the entire data source that is used by the <code>RowSet</code> |
355 A lock is placed on the entire data source that is used by the <code>RowSet</code> |
359 object. |
356 object. |
360 </ul> |
357 </ul> |
361 <p> |
358 <p> |
367 <ul> |
364 <ul> |
368 <li><b>UPDATABLE_VIEW_SYNC</b> |
365 <li><b>UPDATABLE_VIEW_SYNC</b> |
369 Indicates that a <code>SyncProvider</code> implementation supports synchronization |
366 Indicates that a <code>SyncProvider</code> implementation supports synchronization |
370 to the table or tables from which the SQL <code>VIEW</code> used to populate a |
367 to the table or tables from which the SQL <code>VIEW</code> used to populate a |
371 a <code>RowSet</code> object is derived. |
368 a <code>RowSet</code> object is derived. |
372 <p> |
369 |
373 <li><b>NONUPDATABLE_VIEW_SYNC</b> |
370 <li><b>NONUPDATABLE_VIEW_SYNC</b> |
374 Indicates that a <code>SyncProvider</code> implementation does <b>not</b> support |
371 Indicates that a <code>SyncProvider</code> implementation does <b>not</b> support |
375 synchronization to the table or tables from which the SQL <code>VIEW</code> |
372 synchronization to the table or tables from which the SQL <code>VIEW</code> |
376 used to populate a <code>RowSet</code> object is derived. |
373 used to populate a <code>RowSet</code> object is derived. |
377 </ul> |
374 </ul> |
379 <b>3.5 Usage of <code>SyncProvider</code> Grading and Locking</b> |
376 <b>3.5 Usage of <code>SyncProvider</code> Grading and Locking</b> |
380 <p> |
377 <p> |
381 In the example below, the reference <tt>CachedRowSetImpl</tt> implementation |
378 In the example below, the reference <tt>CachedRowSetImpl</tt> implementation |
382 reconfigures its current <tt>SyncProvider</tt> object by calling the |
379 reconfigures its current <tt>SyncProvider</tt> object by calling the |
383 <tt>setSyncProvider</tt> method.<br> |
380 <tt>setSyncProvider</tt> method.<br> |
384 |
381 |
385 <PRE> |
382 <PRE> |
386 CachedRowSetImpl crs = new CachedRowSetImpl(); |
383 CachedRowSetImpl crs = new CachedRowSetImpl(); |
387 crs.setSyncProvider("com.foo.bar.HASyncProvider"); |
384 crs.setSyncProvider("com.foo.bar.HASyncProvider"); |
388 </PRE> |
385 </PRE> |
389 An application can retrieve the <tt>SyncProvider</tt> object currently in use |
386 An application can retrieve the <tt>SyncProvider</tt> object currently in use |
437 |
434 |
438 </PRE> |
435 </PRE> |
439 It is also possible using the static utility method in the |
436 It is also possible using the static utility method in the |
440 <code>SyncFactory</code> class to determine the list of <code>SyncProvider</code> |
437 <code>SyncFactory</code> class to determine the list of <code>SyncProvider</code> |
441 implementations currently registered with the <code>SyncFactory</code>. |
438 implementations currently registered with the <code>SyncFactory</code>. |
442 |
439 |
443 <pre> |
440 <pre> |
444 Enumeration e = SyncFactory.getRegisteredProviders(); |
441 Enumeration e = SyncFactory.getRegisteredProviders(); |
445 </pre> |
442 </pre> |
446 |
443 |
447 </ul> |
444 |
448 |
445 <h3><a name="resolving">4.0 Resolving Synchronization Conflicts</a></h3> |
449 <h3><a name="resolving">4.0 Resolving Synchronization Conflicts</h3> |
|
450 |
446 |
451 The interface <code>SyncResolver</code> provides a way for an application to |
447 The interface <code>SyncResolver</code> provides a way for an application to |
452 decide manually what to do when a conflict occurs. When the <code>CachedRowSet</code> |
448 decide manually what to do when a conflict occurs. When the <code>CachedRowSet</code> |
453 method <code>acceptChanges</code> finishes and has detected one or more conflicts, |
449 method <code>acceptChanges</code> finishes and has detected one or more conflicts, |
454 it throws a <code>SyncProviderException</code> object. An application can |
450 it throws a <code>SyncProviderException</code> object. An application can |
489 decides that a value in the <code>RowSet</code> object should be the one to |
485 decides that a value in the <code>RowSet</code> object should be the one to |
490 persist, the application or user can overwrite the data source value with it. |
486 persist, the application or user can overwrite the data source value with it. |
491 <P> |
487 <P> |
492 The comment for the <code>SyncResolver</code> interface has more detail. |
488 The comment for the <code>SyncResolver</code> interface has more detail. |
493 |
489 |
494 <a name="relspec"><h3>5.0 Related Specifications</h3> |
490 <h3><a name="relspec">5.0 Related Specifications</a></h3> |
495 <ul> |
491 <ul> |
496 <li><a href="http://java.sun.com/products/jndi">JNDI 1.3</a> |
492 <li><a href="http://docs.oracle.com/javase/jndi/tutorial/index.html">JNDI</a> |
497 <li><a href="{@docRoot}/../technotes/guides/logging/index.html">Java Logging |
493 <li><a href="{@docRoot}/../technotes/guides/logging/index.html">Java Logging |
498 APIs</a> |
494 APIs</a> |
499 </ul> |
495 </ul> |
500 <a name="reldocs"><h3>6.0 Related Documentation</h3> |
496 <h3><a name="reldocs">6.0 Related Documentation</a></h3> |
501 <ul> |
497 <ul> |
502 <li><a href="{@docRoot}/../technotes/tools/index.html#basic">System |
498 <li><a href="{@docRoot}/../technotes/tools/index.html#basic">System |
503 properties</a> |
499 properties</a> |
504 <li>Resource Files |
500 <li>Resource Files |
505 <li><a href="http://java.sun.com/tutorial/jdbc">DataSource for JDBC |
501 <li><a href="http://docs.oracle.com/javase/tutorial/jdbc/">DataSource for JDBC |
506 Connections</a> |
502 Connections</a> |
507 </ul> |
503 </ul> |
508 |
504 |
509 </body> |
505 </body> |
510 </html> |
506 </html> |