author | alanb |
Mon, 10 Jun 2013 12:58:32 +0100 | |
changeset 18156 | edb590d448c5 |
parent 14176 | 9864fbbedb87 |
child 18564 | f9db68ff2cbb |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14176 | 2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.sql.rowset.spi; |
|
27 |
||
28 |
import java.util.logging.*; |
|
29 |
import java.util.*; |
|
30 |
||
31 |
import java.sql.*; |
|
32 |
import javax.sql.*; |
|
33 |
||
34 |
import java.io.FileInputStream; |
|
8405
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
35 |
import java.io.InputStream; |
2 | 36 |
import java.io.IOException; |
37 |
import java.io.FileNotFoundException; |
|
38 |
||
39 |
import javax.naming.*; |
|
40 |
||
41 |
/** |
|
42 |
* The Service Provider Interface (SPI) mechanism that generates <code>SyncProvider</code> |
|
43 |
* instances to be used by disconnected <code>RowSet</code> objects. |
|
44 |
* The <code>SyncProvider</code> instances in turn provide the |
|
45 |
* <code>javax.sql.RowSetReader</code> object the <code>RowSet</code> object |
|
46 |
* needs to populate itself with data and the |
|
47 |
* <code>javax.sql.RowSetWriter</code> object it needs to |
|
48 |
* propagate changes to its |
|
49 |
* data back to the underlying data source. |
|
50 |
* <P> |
|
51 |
* Because the methods in the <code>SyncFactory</code> class are all static, |
|
52 |
* there is only one <code>SyncFactory</code> object |
|
53 |
* per Java VM at any one time. This ensures that there is a single source from which a |
|
54 |
* <code>RowSet</code> implementation can obtain its <code>SyncProvider</code> |
|
55 |
* implementation. |
|
56 |
* <p> |
|
57 |
* <h3>1.0 Overview</h3> |
|
58 |
* The <code>SyncFactory</code> class provides an internal registry of available |
|
59 |
* synchronization provider implementations (<code>SyncProvider</code> objects). |
|
60 |
* This registry may be queried to determine which |
|
61 |
* synchronization providers are available. |
|
62 |
* The following line of code gets an enumeration of the providers currently registered. |
|
63 |
* <PRE> |
|
64 |
* java.util.Enumeration e = SyncFactory.getRegisteredProviders(); |
|
65 |
* </PRE> |
|
66 |
* All standard <code>RowSet</code> implementations must provide at least two providers: |
|
67 |
* <UL> |
|
68 |
* <LI>an optimistic provider for use with a <code>CachedRowSet</code> implementation |
|
69 |
* or an implementation derived from it |
|
70 |
* <LI>an XML provider, which is used for reading and writing XML, such as with |
|
71 |
* <code>WebRowSet</code> objects |
|
72 |
* </UL> |
|
73 |
* Note that the JDBC RowSet Implementations include the <code>SyncProvider</code> |
|
74 |
* implemtations <code>RIOptimisticProvider</code> and <code>RIXmlProvider</code>, |
|
75 |
* which satisfy this requirement. |
|
76 |
* <P> |
|
77 |
* The <code>SyncFactory</code> class provides accessor methods to assist |
|
78 |
* applications in determining which synchronization providers are currently |
|
79 |
* registered with the <code>SyncFactory</code>. |
|
80 |
* <p> |
|
81 |
* Other methods let <code>RowSet</code> persistence providers be |
|
82 |
* registered or de-registered with the factory mechanism. This |
|
83 |
* allows additional synchronization provider implementations to be made |
|
84 |
* available to <code>RowSet</code> objects at run time. |
|
85 |
* <p> |
|
86 |
* Applications can apply a degree of filtering to determine the level of |
|
87 |
* synchronization that a <code>SyncProvider</code> implementation offers. |
|
88 |
* The following criteria determine whether a provider is |
|
89 |
* made available to a <code>RowSet</code> object: |
|
90 |
* <ol> |
|
91 |
* <li>If a particular provider is specified by a <code>RowSet</code> object, and |
|
92 |
* the <code>SyncFactory</code> does not contain a reference to this provider, |
|
93 |
* a <code>SyncFactoryException</code> is thrown stating that the synchronization |
|
94 |
* provider could not be found. |
|
95 |
* <p> |
|
96 |
* <li>If a <code>RowSet</code> implementation is instantiated with a specified |
|
97 |
* provider and the specified provider has been properly registered, the |
|
98 |
* requested provider is supplied. Otherwise a <code>SyncFactoryException</code> |
|
99 |
* is thrown. |
|
100 |
* <p> |
|
101 |
* <li>If a <code>RowSet</code> object does not specify a |
|
102 |
* <code>SyncProvider</code> implementation and no additional |
|
103 |
* <code>SyncProvider</code> implementations are available, the reference |
|
104 |
* implementation providers are supplied. |
|
105 |
* </ol> |
|
106 |
* <h3>2.0 Registering <code>SyncProvider</code> Implementations</h3> |
|
107 |
* <p> |
|
108 |
* Both vendors and developers can register <code>SyncProvider</code> |
|
109 |
* implementations using one of the following mechanisms. |
|
110 |
* <ul> |
|
111 |
* <LI><B>Using the command line</B><BR> |
|
112 |
* The name of the provider is supplied on the command line, which will add |
|
113 |
* the provider to the system properties. |
|
114 |
* For example: |
|
115 |
* <PRE> |
|
116 |
* -Drowset.provider.classname=com.fred.providers.HighAvailabilityProvider |
|
117 |
* </PRE> |
|
118 |
* <li><b>Using the Standard Properties File</b><BR> |
|
119 |
* The reference implementation is targeted |
|
120 |
* to ship with J2SE 1.5, which will include an additional resource file |
|
121 |
* that may be edited by hand. Here is an example of the properties file |
|
122 |
* included in the reference implementation: |
|
123 |
* <PRE> |
|
124 |
* #Default JDBC RowSet sync providers listing |
|
125 |
* # |
|
126 |
* |
|
127 |
* # Optimistic synchronization provider |
|
128 |
* rowset.provider.classname.0=com.sun.rowset.providers.RIOptimisticProvider |
|
6671
c5fbc05d7347
6984044: RowSet source needs to rebrand vendor references
lancea
parents:
6529
diff
changeset
|
129 |
* rowset.provider.vendor.0=Oracle Corporation |
2 | 130 |
* rowset.provider.version.0=1.0 |
131 |
* |
|
132 |
* # XML Provider using standard XML schema |
|
133 |
* rowset.provider.classname.1=com.sun.rowset.providers.RIXMLProvider |
|
6671
c5fbc05d7347
6984044: RowSet source needs to rebrand vendor references
lancea
parents:
6529
diff
changeset
|
134 |
* rowset.provider.vendor.1=Oracle Corporation |
2 | 135 |
* rowset.provider.version.1=1.0 |
136 |
* </PRE> |
|
137 |
* The <code>SyncFactory</code> checks this file and registers the |
|
138 |
* <code>SyncProvider</code> implementations that it contains. A |
|
139 |
* developer or vendor can add other implementations to this file. |
|
140 |
* For example, here is a possible addition: |
|
141 |
* <PRE> |
|
142 |
* rowset.provider.classname.2=com.fred.providers.HighAvailabilityProvider |
|
143 |
* rowset.provider.vendor.2=Fred, Inc. |
|
144 |
* rowset.provider.version.2=1.0 |
|
145 |
* </PRE> |
|
146 |
* <p> |
|
147 |
* <li><b>Using a JNDI Context</b><BR> |
|
148 |
* Available providers can be registered on a JNDI |
|
149 |
* context, and the <code>SyncFactory</code> will attempt to load |
|
150 |
* <code>SyncProvider</code> implementations from that JNDI context. |
|
151 |
* For example, the following code fragment registers a provider implementation |
|
152 |
* on a JNDI context. This is something a deployer would normally do. In this |
|
153 |
* example, <code>MyProvider</code> is being registered on a CosNaming |
|
154 |
* namespace, which is the namespace used by J2EE resources. |
|
155 |
* <PRE> |
|
156 |
* import javax.naming.*; |
|
157 |
* |
|
158 |
* Hashtable svrEnv = new Hashtable(); |
|
159 |
* srvEnv.put(Context.INITIAL_CONTEXT_FACTORY, "CosNaming"); |
|
160 |
* |
|
161 |
* Context ctx = new InitialContext(svrEnv); |
|
162 |
* com.fred.providers.MyProvider = new MyProvider(); |
|
163 |
* ctx.rebind("providers/MyProvider", syncProvider); |
|
164 |
* </PRE> |
|
165 |
* </ul> |
|
166 |
* Next, an application will register the JNDI context with the |
|
167 |
* <code>SyncFactory</code> instance. This allows the <code>SyncFactory</code> |
|
168 |
* to browse within the JNDI context looking for <code>SyncProvider</code> |
|
169 |
* implementations. |
|
170 |
* <PRE> |
|
171 |
* Hashtable appEnv = new Hashtable(); |
|
172 |
* appEnv.put(Context.INITIAL_CONTEXT_FACTORY, "CosNaming"); |
|
173 |
* appEnv.put(Context.PROVIDER_URL, "iiop://hostname/providers"); |
|
174 |
* Context ctx = new InitialContext(appEnv); |
|
175 |
* |
|
176 |
* SyncFactory.registerJNDIContext(ctx); |
|
177 |
* </PRE> |
|
178 |
* If a <code>RowSet</code> object attempts to obtain a <code>MyProvider</code> |
|
179 |
* object, the <code>SyncFactory</code> will try to locate it. First it searches |
|
180 |
* for it in the system properties, then it looks in the resource files, and |
|
181 |
* finally it checks the JNDI context that has been set. The <code>SyncFactory</code> |
|
182 |
* instance verifies that the requested provider is a valid extension of the |
|
183 |
* <code>SyncProvider</code> abstract class and then gives it to the |
|
184 |
* <code>RowSet</code> object. In the following code fragment, a new |
|
185 |
* <code>CachedRowSet</code> object is created and initialized with |
|
186 |
* <i>env</i>, which contains the binding to <code>MyProvider</code>. |
|
187 |
* <PRE> |
|
188 |
* Hashtable env = new Hashtable(); |
|
189 |
* env.put(SyncFactory.ROWSET_SYNC_PROVIDER, "com.fred.providers.MyProvider"); |
|
190 |
* CachedRowSet crs = new com.sun.rowset.CachedRowSetImpl(env); |
|
191 |
* </PRE> |
|
192 |
* Further details on these mechanisms are available in the |
|
193 |
* <code>javax.sql.rowset.spi</code> package specification. |
|
194 |
* |
|
195 |
* @author Jonathan Bruce |
|
196 |
* @see javax.sql.rowset.spi.SyncProvider |
|
197 |
* @see javax.sql.rowset.spi.SyncFactoryException |
|
198 |
*/ |
|
199 |
public class SyncFactory { |
|
200 |
||
201 |
/** |
|
202 |
* Creates a new <code>SyncFactory</code> object, which is the singleton |
|
203 |
* instance. |
|
204 |
* Having a private constructor guarantees that no more than |
|
205 |
* one <code>SyncProvider</code> object can exist at a time. |
|
206 |
*/ |
|
6529 | 207 |
private SyncFactory() { |
208 |
} |
|
2 | 209 |
|
210 |
/** |
|
211 |
* The standard property-id for a synchronization provider implementation |
|
212 |
* name. |
|
213 |
*/ |
|
6529 | 214 |
public static final String ROWSET_SYNC_PROVIDER = |
215 |
"rowset.provider.classname"; |
|
2 | 216 |
/** |
217 |
* The standard property-id for a synchronization provider implementation |
|
218 |
* vendor name. |
|
219 |
*/ |
|
6529 | 220 |
public static final String ROWSET_SYNC_VENDOR = |
221 |
"rowset.provider.vendor"; |
|
2 | 222 |
/** |
223 |
* The standard property-id for a synchronization provider implementation |
|
224 |
* version tag. |
|
225 |
*/ |
|
6529 | 226 |
public static final String ROWSET_SYNC_PROVIDER_VERSION = |
227 |
"rowset.provider.version"; |
|
2 | 228 |
/** |
229 |
* The standard resource file name. |
|
230 |
*/ |
|
231 |
private static String ROWSET_PROPERTIES = "rowset.properties"; |
|
14176 | 232 |
|
6529 | 233 |
/** |
234 |
* Permission required to invoke setJNDIContext and setLogger |
|
235 |
*/ |
|
236 |
private static final SQLPermission SET_SYNCFACTORY_PERMISSION = |
|
237 |
new SQLPermission("setSyncFactory"); |
|
2 | 238 |
/** |
239 |
* The initial JNDI context where <code>SyncProvider</code> implementations can |
|
240 |
* be stored and from which they can be invoked. |
|
241 |
*/ |
|
242 |
private static Context ic; |
|
243 |
/** |
|
244 |
* The <code>Logger</code> object to be used by the <code>SyncFactory</code>. |
|
245 |
*/ |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
246 |
private static volatile Logger rsLogger; |
14176 | 247 |
|
2 | 248 |
/** |
249 |
* The registry of available <code>SyncProvider</code> implementations. |
|
250 |
* See section 2.0 of the class comment for <code>SyncFactory</code> for an |
|
251 |
* explanation of how a provider can be added to this registry. |
|
252 |
*/ |
|
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
9035
diff
changeset
|
253 |
private static Hashtable<String, SyncProvider> implementations; |
2 | 254 |
|
255 |
/** |
|
256 |
* Adds the the given synchronization provider to the factory register. Guidelines |
|
257 |
* are provided in the <code>SyncProvider</code> specification for the |
|
258 |
* required naming conventions for <code>SyncProvider</code> |
|
259 |
* implementations. |
|
260 |
* <p> |
|
261 |
* Synchronization providers bound to a JNDI context can be |
|
262 |
* registered by binding a SyncProvider instance to a JNDI namespace. |
|
263 |
* <ul> |
|
264 |
* <pre> |
|
265 |
* SyncProvider p = new MySyncProvider(); |
|
266 |
* InitialContext ic = new InitialContext(); |
|
267 |
* ic.bind ("jdbc/rowset/MySyncProvider", p); |
|
268 |
* </pre> |
|
269 |
* </ul> |
|
270 |
* Furthermore, an initial JNDI context should be set with the |
|
271 |
* <code>SyncFactory</code> using the <code>setJNDIContext</code> method. |
|
272 |
* The <code>SyncFactory</code> leverages this context to search for |
|
273 |
* available <code>SyncProvider</code> objects bound to the JNDI |
|
274 |
* context and its child nodes. |
|
275 |
* |
|
276 |
* @param providerID A <code>String</code> object with the unique ID of the |
|
277 |
* synchronization provider being registered |
|
278 |
* @throws SyncFactoryException if an attempt is made to supply an empty |
|
279 |
* or null provider name |
|
280 |
* @see #setJNDIContext |
|
281 |
*/ |
|
282 |
public static synchronized void registerProvider(String providerID) |
|
6529 | 283 |
throws SyncFactoryException { |
2 | 284 |
|
285 |
ProviderImpl impl = new ProviderImpl(); |
|
286 |
impl.setClassname(providerID); |
|
287 |
initMapIfNecessary(); |
|
288 |
implementations.put(providerID, impl); |
|
289 |
||
290 |
} |
|
291 |
||
292 |
/** |
|
293 |
* Returns the <code>SyncFactory</code> singleton. |
|
294 |
* |
|
295 |
* @return the <code>SyncFactory</code> instance |
|
296 |
*/ |
|
6529 | 297 |
public static SyncFactory getSyncFactory() { |
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
298 |
/* |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
299 |
* Using Initialization on Demand Holder idiom as |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
300 |
* Effective Java 2nd Edition,ITEM 71, indicates it is more performant |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
301 |
* than the Double-Check Locking idiom. |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
302 |
*/ |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
303 |
return SyncFactoryHolder.factory; |
6529 | 304 |
} |
2 | 305 |
|
306 |
/** |
|
307 |
* Removes the designated currently registered synchronization provider from the |
|
308 |
* Factory SPI register. |
|
309 |
* |
|
310 |
* @param providerID The unique-id of the synchronization provider |
|
311 |
* @throws SyncFactoryException If an attempt is made to |
|
312 |
* unregister a SyncProvider implementation that was not registered. |
|
313 |
*/ |
|
314 |
public static synchronized void unregisterProvider(String providerID) |
|
6529 | 315 |
throws SyncFactoryException { |
2 | 316 |
initMapIfNecessary(); |
317 |
if (implementations.containsKey(providerID)) { |
|
318 |
implementations.remove(providerID); |
|
319 |
} |
|
320 |
} |
|
321 |
private static String colon = ":"; |
|
322 |
private static String strFileSep = "/"; |
|
323 |
||
324 |
private static synchronized void initMapIfNecessary() throws SyncFactoryException { |
|
325 |
||
326 |
// Local implementation class names and keys from Properties |
|
327 |
// file, translate names into Class objects using Class.forName |
|
328 |
// and store mappings |
|
329 |
Properties properties = new Properties(); |
|
330 |
||
331 |
if (implementations == null) { |
|
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
9035
diff
changeset
|
332 |
implementations = new Hashtable<>(); |
2 | 333 |
|
334 |
try { |
|
335 |
||
336 |
// check if user is supplying his Synchronisation Provider |
|
6671
c5fbc05d7347
6984044: RowSet source needs to rebrand vendor references
lancea
parents:
6529
diff
changeset
|
337 |
// Implementation if not using Oracle's implementation. |
2 | 338 |
// properties.load(new FileInputStream(ROWSET_PROPERTIES)); |
339 |
||
340 |
// The rowset.properties needs to be in jdk/jre/lib when |
|
341 |
// integrated with jdk. |
|
342 |
// else it should be picked from -D option from command line. |
|
343 |
||
344 |
// -Drowset.properties will add to standard properties. Similar |
|
345 |
// keys will over-write |
|
346 |
||
347 |
/* |
|
348 |
* Dependent on application |
|
349 |
*/ |
|
350 |
String strRowsetProperties = System.getProperty("rowset.properties"); |
|
6529 | 351 |
if (strRowsetProperties != null) { |
2 | 352 |
// Load user's implementation of SyncProvider |
353 |
// here. -Drowset.properties=/abc/def/pqr.txt |
|
354 |
ROWSET_PROPERTIES = strRowsetProperties; |
|
8405
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
355 |
try (FileInputStream fis = new FileInputStream(ROWSET_PROPERTIES)) { |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
356 |
properties.load(fis); |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
357 |
} |
2 | 358 |
parseProperties(properties); |
359 |
} |
|
360 |
||
361 |
/* |
|
362 |
* Always available |
|
363 |
*/ |
|
364 |
ROWSET_PROPERTIES = "javax" + strFileSep + "sql" + |
|
6529 | 365 |
strFileSep + "rowset" + strFileSep + |
366 |
"rowset.properties"; |
|
2 | 367 |
|
368 |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
|
369 |
||
8405
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
370 |
try (InputStream stream = |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
371 |
(cl == null) ? ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES) |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
372 |
: cl.getResourceAsStream(ROWSET_PROPERTIES)) { |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
373 |
if (stream == null) { |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
374 |
throw new SyncFactoryException( |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
375 |
"Resource " + ROWSET_PROPERTIES + " not found"); |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
376 |
} |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
377 |
properties.load(stream); |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
378 |
} |
bafd7b441d80
7018385: update javax.sql classes to use try-with-resources
smarks
parents:
7184
diff
changeset
|
379 |
|
2 | 380 |
parseProperties(properties); |
381 |
||
6529 | 382 |
// removed else, has properties should sum together |
2 | 383 |
|
384 |
} catch (FileNotFoundException e) { |
|
385 |
throw new SyncFactoryException("Cannot locate properties file: " + e); |
|
386 |
} catch (IOException e) { |
|
387 |
throw new SyncFactoryException("IOException: " + e); |
|
388 |
} |
|
389 |
||
390 |
/* |
|
391 |
* Now deal with -Drowset.provider.classname |
|
392 |
* load additional properties from -D command line |
|
393 |
*/ |
|
394 |
properties.clear(); |
|
395 |
String providerImpls = System.getProperty(ROWSET_SYNC_PROVIDER); |
|
396 |
||
397 |
if (providerImpls != null) { |
|
398 |
int i = 0; |
|
399 |
if (providerImpls.indexOf(colon) > 0) { |
|
400 |
StringTokenizer tokenizer = new StringTokenizer(providerImpls, colon); |
|
401 |
while (tokenizer.hasMoreElements()) { |
|
402 |
properties.put(ROWSET_SYNC_PROVIDER + "." + i, tokenizer.nextToken()); |
|
403 |
i++; |
|
404 |
} |
|
405 |
} else { |
|
406 |
properties.put(ROWSET_SYNC_PROVIDER, providerImpls); |
|
407 |
} |
|
408 |
parseProperties(properties); |
|
409 |
} |
|
410 |
} |
|
411 |
} |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
412 |
|
2 | 413 |
/** |
414 |
* The internal debug switch. |
|
415 |
*/ |
|
416 |
private static boolean debug = false; |
|
417 |
/** |
|
418 |
* Internal registry count for the number of providers contained in the |
|
419 |
* registry. |
|
420 |
*/ |
|
421 |
private static int providerImplIndex = 0; |
|
422 |
||
423 |
/** |
|
424 |
* Internal handler for all standard property parsing. Parses standard |
|
425 |
* ROWSET properties and stores lazy references into the the internal registry. |
|
426 |
*/ |
|
427 |
private static void parseProperties(Properties p) { |
|
428 |
||
429 |
ProviderImpl impl = null; |
|
430 |
String key = null; |
|
431 |
String[] propertyNames = null; |
|
432 |
||
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
9035
diff
changeset
|
433 |
for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();) { |
2 | 434 |
|
6529 | 435 |
String str = (String) e.nextElement(); |
2 | 436 |
|
437 |
int w = str.length(); |
|
438 |
||
439 |
if (str.startsWith(SyncFactory.ROWSET_SYNC_PROVIDER)) { |
|
440 |
||
441 |
impl = new ProviderImpl(); |
|
442 |
impl.setIndex(providerImplIndex++); |
|
443 |
||
444 |
if (w == (SyncFactory.ROWSET_SYNC_PROVIDER).length()) { |
|
445 |
// no property index has been set. |
|
446 |
propertyNames = getPropertyNames(false); |
|
447 |
} else { |
|
448 |
// property index has been set. |
|
6529 | 449 |
propertyNames = getPropertyNames(true, str.substring(w - 1)); |
2 | 450 |
} |
451 |
||
452 |
key = p.getProperty(propertyNames[0]); |
|
453 |
impl.setClassname(key); |
|
454 |
impl.setVendor(p.getProperty(propertyNames[1])); |
|
455 |
impl.setVersion(p.getProperty(propertyNames[2])); |
|
456 |
implementations.put(key, impl); |
|
457 |
} |
|
458 |
} |
|
459 |
} |
|
460 |
||
461 |
/** |
|
462 |
* Used by the parseProperties methods to disassemble each property tuple. |
|
463 |
*/ |
|
464 |
private static String[] getPropertyNames(boolean append) { |
|
465 |
return getPropertyNames(append, null); |
|
466 |
} |
|
467 |
||
468 |
/** |
|
469 |
* Disassembles each property and its associated value. Also handles |
|
470 |
* overloaded property names that contain indexes. |
|
471 |
*/ |
|
472 |
private static String[] getPropertyNames(boolean append, |
|
6529 | 473 |
String propertyIndex) { |
2 | 474 |
String dot = "."; |
475 |
String[] propertyNames = |
|
6529 | 476 |
new String[]{SyncFactory.ROWSET_SYNC_PROVIDER, |
477 |
SyncFactory.ROWSET_SYNC_VENDOR, |
|
478 |
SyncFactory.ROWSET_SYNC_PROVIDER_VERSION}; |
|
2 | 479 |
if (append) { |
480 |
for (int i = 0; i < propertyNames.length; i++) { |
|
481 |
propertyNames[i] = propertyNames[i] + |
|
6529 | 482 |
dot + |
483 |
propertyIndex; |
|
2 | 484 |
} |
485 |
return propertyNames; |
|
486 |
} else { |
|
487 |
return propertyNames; |
|
488 |
} |
|
489 |
} |
|
490 |
||
491 |
/** |
|
492 |
* Internal debug method that outputs the registry contents. |
|
493 |
*/ |
|
494 |
private static void showImpl(ProviderImpl impl) { |
|
495 |
System.out.println("Provider implementation:"); |
|
496 |
System.out.println("Classname: " + impl.getClassname()); |
|
497 |
System.out.println("Vendor: " + impl.getVendor()); |
|
498 |
System.out.println("Version: " + impl.getVersion()); |
|
499 |
System.out.println("Impl index: " + impl.getIndex()); |
|
500 |
} |
|
501 |
||
502 |
/** |
|
503 |
* Returns the <code>SyncProvider</code> instance identified by <i>providerID</i>. |
|
504 |
* |
|
505 |
* @param providerID the unique identifier of the provider |
|
506 |
* @return a <code>SyncProvider</code> implementation |
|
6529 | 507 |
* @throws SyncFactoryException If the SyncProvider cannot be found, |
508 |
* the providerID is {@code null}, or |
|
2 | 509 |
* some error was encountered when trying to invoke this provider. |
510 |
*/ |
|
511 |
public static SyncProvider getInstance(String providerID) |
|
6529 | 512 |
throws SyncFactoryException { |
513 |
||
514 |
if(providerID == null) { |
|
515 |
throw new SyncFactoryException("The providerID cannot be null"); |
|
516 |
} |
|
517 |
||
2 | 518 |
initMapIfNecessary(); // populate HashTable |
519 |
initJNDIContext(); // check JNDI context for any additional bindings |
|
520 |
||
6529 | 521 |
ProviderImpl impl = (ProviderImpl) implementations.get(providerID); |
2 | 522 |
|
523 |
if (impl == null) { |
|
524 |
// Requested SyncProvider is unavailable. Return default provider. |
|
525 |
return new com.sun.rowset.providers.RIOptimisticProvider(); |
|
526 |
} |
|
527 |
||
528 |
// Attempt to invoke classname from registered SyncProvider list |
|
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
9035
diff
changeset
|
529 |
Class<?> c = null; |
2 | 530 |
try { |
531 |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
|
532 |
||
533 |
/** |
|
534 |
* The SyncProvider implementation of the user will be in |
|
535 |
* the classpath. We need to find the ClassLoader which loads |
|
536 |
* this SyncFactory and try to laod the SyncProvider class from |
|
537 |
* there. |
|
538 |
**/ |
|
539 |
c = Class.forName(providerID, true, cl); |
|
540 |
||
541 |
if (c != null) { |
|
6529 | 542 |
return (SyncProvider) c.newInstance(); |
2 | 543 |
} else { |
544 |
return new com.sun.rowset.providers.RIOptimisticProvider(); |
|
545 |
} |
|
546 |
||
547 |
} catch (IllegalAccessException e) { |
|
548 |
throw new SyncFactoryException("IllegalAccessException: " + e.getMessage()); |
|
549 |
} catch (InstantiationException e) { |
|
550 |
throw new SyncFactoryException("InstantiationException: " + e.getMessage()); |
|
551 |
} catch (ClassNotFoundException e) { |
|
552 |
throw new SyncFactoryException("ClassNotFoundException: " + e.getMessage()); |
|
553 |
} |
|
554 |
} |
|
6529 | 555 |
|
2 | 556 |
/** |
557 |
* Returns an Enumeration of currently registered synchronization |
|
558 |
* providers. A <code>RowSet</code> implementation may use any provider in |
|
559 |
* the enumeration as its <code>SyncProvider</code> object. |
|
560 |
* <p> |
|
561 |
* At a minimum, the reference synchronization provider allowing |
|
562 |
* RowSet content data to be stored using a JDBC driver should be |
|
563 |
* possible. |
|
564 |
* |
|
565 |
* @return Enumeration A enumeration of available synchronization |
|
566 |
* providers that are registered with this Factory |
|
567 |
*/ |
|
568 |
public static Enumeration<SyncProvider> getRegisteredProviders() |
|
6529 | 569 |
throws SyncFactoryException { |
2 | 570 |
initMapIfNecessary(); |
571 |
// return a collection of classnames |
|
572 |
// of type SyncProvider |
|
573 |
return implementations.elements(); |
|
574 |
} |
|
575 |
||
576 |
/** |
|
577 |
* Sets the logging object to be used by the <code>SyncProvider</code> |
|
578 |
* implementation provided by the <code>SyncFactory</code>. All |
|
579 |
* <code>SyncProvider</code> implementations can log their events to |
|
580 |
* this object and the application can retrieve a handle to this |
|
581 |
* object using the <code>getLogger</code> method. |
|
6529 | 582 |
* <p> |
583 |
* This method checks to see that there is an {@code SQLPermission} |
|
584 |
* object which grants the permission {@code setSyncFactory} |
|
585 |
* before allowing the method to succeed. If a |
|
586 |
* {@code SecurityManager} exists and its |
|
587 |
* {@code checkPermission} method denies calling {@code setLogger}, |
|
588 |
* this method throws a |
|
589 |
* {@code java.lang.SecurityException}. |
|
2 | 590 |
* |
591 |
* @param logger A Logger object instance |
|
6529 | 592 |
* @throws java.lang.SecurityException if a security manager exists and its |
593 |
* {@code checkPermission} method denies calling {@code setLogger} |
|
7184
70b4f13c6f5d
6999086: Clarify that SyncFactory.setLogger can throw an NullPointerException
lancea
parents:
7182
diff
changeset
|
594 |
* @throws NullPointerException if the logger is null |
6529 | 595 |
* @see SecurityManager#checkPermission |
2 | 596 |
*/ |
597 |
public static void setLogger(Logger logger) { |
|
6529 | 598 |
|
599 |
SecurityManager sec = System.getSecurityManager(); |
|
600 |
if (sec != null) { |
|
601 |
sec.checkPermission(SET_SYNCFACTORY_PERMISSION); |
|
602 |
} |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
603 |
|
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
604 |
if(logger == null){ |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
605 |
throw new NullPointerException("You must provide a Logger"); |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
606 |
} |
2 | 607 |
rsLogger = logger; |
608 |
} |
|
609 |
||
610 |
/** |
|
611 |
* Sets the logging object that is used by <code>SyncProvider</code> |
|
612 |
* implementations provided by the <code>SyncFactory</code> SPI. All |
|
613 |
* <code>SyncProvider</code> implementations can log their events |
|
614 |
* to this object and the application can retrieve a handle to this |
|
615 |
* object using the <code>getLogger</code> method. |
|
6529 | 616 |
* <p> |
617 |
* This method checks to see that there is an {@code SQLPermission} |
|
618 |
* object which grants the permission {@code setSyncFactory} |
|
619 |
* before allowing the method to succeed. If a |
|
620 |
* {@code SecurityManager} exists and its |
|
621 |
* {@code checkPermission} method denies calling {@code setLogger}, |
|
622 |
* this method throws a |
|
623 |
* {@code java.lang.SecurityException}. |
|
2 | 624 |
* |
625 |
* @param logger a Logger object instance |
|
626 |
* @param level a Level object instance indicating the degree of logging |
|
627 |
* required |
|
6529 | 628 |
* @throws java.lang.SecurityException if a security manager exists and its |
629 |
* {@code checkPermission} method denies calling {@code setLogger} |
|
7184
70b4f13c6f5d
6999086: Clarify that SyncFactory.setLogger can throw an NullPointerException
lancea
parents:
7182
diff
changeset
|
630 |
* @throws NullPointerException if the logger is null |
6529 | 631 |
* @see SecurityManager#checkPermission |
6846
2cfd1dfb014b
6988310: SyncFactory.setLogger(Logger,Level) requires unspecified security permission
lancea
parents:
6671
diff
changeset
|
632 |
* @see LoggingPermission |
2 | 633 |
*/ |
634 |
public static void setLogger(Logger logger, Level level) { |
|
635 |
// singleton |
|
6529 | 636 |
SecurityManager sec = System.getSecurityManager(); |
637 |
if (sec != null) { |
|
638 |
sec.checkPermission(SET_SYNCFACTORY_PERMISSION); |
|
639 |
} |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
640 |
|
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
641 |
if(logger == null){ |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
642 |
throw new NullPointerException("You must provide a Logger"); |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
643 |
} |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
644 |
logger.setLevel(level); |
2 | 645 |
rsLogger = logger; |
646 |
} |
|
647 |
||
648 |
/** |
|
649 |
* Returns the logging object for applications to retrieve |
|
650 |
* synchronization events posted by SyncProvider implementations. |
|
651 |
* |
|
652 |
* @throws SyncFactoryException if no logging object has been set. |
|
653 |
*/ |
|
654 |
public static Logger getLogger() throws SyncFactoryException { |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
655 |
|
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
656 |
Logger result = rsLogger; |
2 | 657 |
// only one logger per session |
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
658 |
if (result == null) { |
6529 | 659 |
throw new SyncFactoryException("(SyncFactory) : No logger has been set"); |
2 | 660 |
} |
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
661 |
|
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
662 |
return result; |
2 | 663 |
} |
664 |
||
6529 | 665 |
/** |
666 |
* Sets the initial JNDI context from which SyncProvider implementations |
|
667 |
* can be retrieved from a JNDI namespace |
|
668 |
* <p> |
|
669 |
* This method checks to see that there is an {@code SQLPermission} |
|
670 |
* object which grants the permission {@code setSyncFactory} |
|
671 |
* before allowing the method to succeed. If a |
|
672 |
* {@code SecurityManager} exists and its |
|
673 |
* {@code checkPermission} method denies calling {@code setJNDIContext}, |
|
674 |
* this method throws a |
|
675 |
* {@code java.lang.SecurityException}. |
|
676 |
* |
|
677 |
* @param ctx a valid JNDI context |
|
678 |
* @throws SyncFactoryException if the supplied JNDI context is null |
|
679 |
* @throws java.lang.SecurityException if a security manager exists and its |
|
680 |
* {@code checkPermission} method denies calling {@code setJNDIContext} |
|
681 |
* @see SecurityManager#checkPermission |
|
682 |
*/ |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
683 |
public static synchronized void setJNDIContext(javax.naming.Context ctx) |
6529 | 684 |
throws SyncFactoryException { |
685 |
SecurityManager sec = System.getSecurityManager(); |
|
686 |
if (sec != null) { |
|
687 |
sec.checkPermission(SET_SYNCFACTORY_PERMISSION); |
|
688 |
} |
|
2 | 689 |
if (ctx == null) { |
690 |
throw new SyncFactoryException("Invalid JNDI context supplied"); |
|
691 |
} |
|
692 |
ic = ctx; |
|
6529 | 693 |
} |
2 | 694 |
|
695 |
/** |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
696 |
* Controls JNDI context initialization. |
2 | 697 |
* |
698 |
* @throws SyncFactoryException if an error occurs parsing the JNDI context |
|
699 |
*/ |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
700 |
private static synchronized void initJNDIContext() throws SyncFactoryException { |
2 | 701 |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
702 |
if ((ic != null) && (lazyJNDICtxRefresh == false)) { |
2 | 703 |
try { |
704 |
parseProperties(parseJNDIContext()); |
|
705 |
lazyJNDICtxRefresh = true; // touch JNDI namespace once. |
|
706 |
} catch (NamingException e) { |
|
707 |
e.printStackTrace(); |
|
708 |
throw new SyncFactoryException("SPI: NamingException: " + e.getExplanation()); |
|
709 |
} catch (Exception e) { |
|
710 |
e.printStackTrace(); |
|
6529 | 711 |
throw new SyncFactoryException("SPI: Exception: " + e.getMessage()); |
2 | 712 |
} |
713 |
} |
|
714 |
} |
|
715 |
/** |
|
716 |
* Internal switch indicating whether the JNDI namespace should be re-read. |
|
717 |
*/ |
|
718 |
private static boolean lazyJNDICtxRefresh = false; |
|
719 |
||
720 |
/** |
|
721 |
* Parses the set JNDI Context and passes bindings to the enumerateBindings |
|
722 |
* method when complete. |
|
723 |
*/ |
|
724 |
private static Properties parseJNDIContext() throws NamingException { |
|
725 |
||
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
9035
diff
changeset
|
726 |
NamingEnumeration<?> bindings = ic.listBindings(""); |
2 | 727 |
Properties properties = new Properties(); |
728 |
||
729 |
// Hunt one level below context for available SyncProvider objects |
|
730 |
enumerateBindings(bindings, properties); |
|
731 |
||
732 |
return properties; |
|
733 |
} |
|
734 |
||
735 |
/** |
|
736 |
* Scans each binding on JNDI context and determines if any binding is an |
|
737 |
* instance of SyncProvider, if so, add this to the registry and continue to |
|
738 |
* scan the current context using a re-entrant call to this method until all |
|
739 |
* bindings have been enumerated. |
|
740 |
*/ |
|
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
9035
diff
changeset
|
741 |
private static void enumerateBindings(NamingEnumeration<?> bindings, |
6529 | 742 |
Properties properties) throws NamingException { |
2 | 743 |
|
744 |
boolean syncProviderObj = false; // move to parameters ? |
|
745 |
||
746 |
try { |
|
747 |
Binding bd = null; |
|
748 |
Object elementObj = null; |
|
749 |
String element = null; |
|
750 |
while (bindings.hasMore()) { |
|
6529 | 751 |
bd = (Binding) bindings.next(); |
2 | 752 |
element = bd.getName(); |
753 |
elementObj = bd.getObject(); |
|
754 |
||
755 |
if (!(ic.lookup(element) instanceof Context)) { |
|
6529 | 756 |
// skip directories/sub-contexts |
757 |
if (ic.lookup(element) instanceof SyncProvider) { |
|
2 | 758 |
syncProviderObj = true; |
6529 | 759 |
} |
2 | 760 |
} |
761 |
||
762 |
if (syncProviderObj) { |
|
6529 | 763 |
SyncProvider sync = (SyncProvider) elementObj; |
2 | 764 |
properties.put(SyncFactory.ROWSET_SYNC_PROVIDER, |
6529 | 765 |
sync.getProviderID()); |
2 | 766 |
syncProviderObj = false; // reset |
767 |
} |
|
768 |
||
769 |
} |
|
770 |
} catch (javax.naming.NotContextException e) { |
|
771 |
bindings.next(); |
|
772 |
// Re-entrant call into method |
|
773 |
enumerateBindings(bindings, properties); |
|
774 |
} |
|
775 |
} |
|
7182
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
776 |
|
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
777 |
/** |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
778 |
* Lazy initialization Holder class used by {@code getSyncFactory} |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
779 |
*/ |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
780 |
private static class SyncFactoryHolder { |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
781 |
static final SyncFactory factory = new SyncFactory(); |
f3e89472692d
6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents:
6846
diff
changeset
|
782 |
} |
2 | 783 |
} |
784 |
||
6529 | 785 |
/** |
786 |
* Internal class that defines the lazy reference construct for each registered |
|
787 |
* SyncProvider implementation. |
|
788 |
*/ |
|
789 |
class ProviderImpl extends SyncProvider { |
|
790 |
||
791 |
private String className = null; |
|
792 |
private String vendorName = null; |
|
793 |
private String ver = null; |
|
794 |
private int index; |
|
2 | 795 |
|
6529 | 796 |
public void setClassname(String classname) { |
797 |
className = classname; |
|
798 |
} |
|
2 | 799 |
|
6529 | 800 |
public String getClassname() { |
801 |
return className; |
|
802 |
} |
|
2 | 803 |
|
6529 | 804 |
public void setVendor(String vendor) { |
805 |
vendorName = vendor; |
|
806 |
} |
|
2 | 807 |
|
6529 | 808 |
public String getVendor() { |
809 |
return vendorName; |
|
810 |
} |
|
2 | 811 |
|
6529 | 812 |
public void setVersion(String providerVer) { |
813 |
ver = providerVer; |
|
814 |
} |
|
2 | 815 |
|
6529 | 816 |
public String getVersion() { |
817 |
return ver; |
|
818 |
} |
|
2 | 819 |
|
6529 | 820 |
public void setIndex(int i) { |
821 |
index = i; |
|
822 |
} |
|
2 | 823 |
|
6529 | 824 |
public int getIndex() { |
825 |
return index; |
|
826 |
} |
|
2 | 827 |
|
6529 | 828 |
public int getDataSourceLock() throws SyncProviderException { |
2 | 829 |
|
6529 | 830 |
int dsLock = 0; |
831 |
try { |
|
832 |
dsLock = SyncFactory.getInstance(className).getDataSourceLock(); |
|
833 |
} catch (SyncFactoryException sfEx) { |
|
2 | 834 |
|
6529 | 835 |
throw new SyncProviderException(sfEx.getMessage()); |
2 | 836 |
} |
837 |
||
6529 | 838 |
return dsLock; |
839 |
} |
|
2 | 840 |
|
6529 | 841 |
public int getProviderGrade() { |
2 | 842 |
|
6529 | 843 |
int grade = 0; |
2 | 844 |
|
6529 | 845 |
try { |
846 |
grade = SyncFactory.getInstance(className).getProviderGrade(); |
|
847 |
} catch (SyncFactoryException sfEx) { |
|
848 |
// |
|
2 | 849 |
} |
850 |
||
6529 | 851 |
return grade; |
852 |
} |
|
853 |
||
854 |
public String getProviderID() { |
|
855 |
return className; |
|
856 |
} |
|
2 | 857 |
|
6529 | 858 |
/* |
859 |
public javax.sql.RowSetInternal getRowSetInternal() { |
|
860 |
try |
|
861 |
{ |
|
862 |
return SyncFactory.getInstance(className).getRowSetInternal(); |
|
863 |
} catch(SyncFactoryException sfEx) { |
|
864 |
// |
|
865 |
} |
|
866 |
} |
|
867 |
*/ |
|
868 |
public javax.sql.RowSetReader getRowSetReader() { |
|
2 | 869 |
|
6529 | 870 |
RowSetReader rsReader = null; |
2 | 871 |
|
6529 | 872 |
try { |
873 |
rsReader = SyncFactory.getInstance(className).getRowSetReader(); |
|
874 |
} catch (SyncFactoryException sfEx) { |
|
875 |
// |
|
2 | 876 |
} |
877 |
||
6529 | 878 |
return rsReader; |
879 |
||
880 |
} |
|
881 |
||
882 |
public javax.sql.RowSetWriter getRowSetWriter() { |
|
2 | 883 |
|
884 |
RowSetWriter rsWriter = null; |
|
6529 | 885 |
try { |
886 |
rsWriter = SyncFactory.getInstance(className).getRowSetWriter(); |
|
887 |
} catch (SyncFactoryException sfEx) { |
|
888 |
// |
|
2 | 889 |
} |
890 |
||
6529 | 891 |
return rsWriter; |
892 |
} |
|
893 |
||
894 |
public void setDataSourceLock(int param) |
|
895 |
throws SyncProviderException { |
|
896 |
||
897 |
try { |
|
898 |
SyncFactory.getInstance(className).setDataSourceLock(param); |
|
899 |
} catch (SyncFactoryException sfEx) { |
|
900 |
||
901 |
throw new SyncProviderException(sfEx.getMessage()); |
|
902 |
} |
|
903 |
} |
|
904 |
||
905 |
public int supportsUpdatableView() { |
|
2 | 906 |
|
907 |
int view = 0; |
|
908 |
||
6529 | 909 |
try { |
910 |
view = SyncFactory.getInstance(className).supportsUpdatableView(); |
|
911 |
} catch (SyncFactoryException sfEx) { |
|
912 |
// |
|
913 |
} |
|
2 | 914 |
|
6529 | 915 |
return view; |
2 | 916 |
} |
6529 | 917 |
} |