6843995: RowSet 1.1 updates
Reviewed-by: darcy, valeriep
This commit is contained in:
parent
a239e8e462
commit
96eebc523f
69
jdk/src/share/classes/com/sun/rowset/RowSetFactoryImpl.java
Normal file
69
jdk/src/share/classes/com/sun/rowset/RowSetFactoryImpl.java
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.rowset;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import javax.sql.rowset.CachedRowSet;
|
||||
import javax.sql.rowset.FilteredRowSet;
|
||||
import javax.sql.rowset.JdbcRowSet;
|
||||
import javax.sql.rowset.JoinRowSet;
|
||||
import javax.sql.rowset.WebRowSet;
|
||||
import javax.sql.rowset.RowSetFactory;
|
||||
|
||||
/**
|
||||
* This is the implementation specific class for the
|
||||
* <code>javax.sql.rowset.spi.RowSetFactory</code>. This is the platform
|
||||
* default implementation for the Java SE platform.
|
||||
*
|
||||
* @author Lance Andersen
|
||||
*
|
||||
*
|
||||
* @version 1.7
|
||||
*/
|
||||
public final class RowSetFactoryImpl implements RowSetFactory {
|
||||
|
||||
public CachedRowSet createCachedRowSet() throws SQLException {
|
||||
return new com.sun.rowset.CachedRowSetImpl();
|
||||
}
|
||||
|
||||
public FilteredRowSet createFilteredRowSet() throws SQLException {
|
||||
return new com.sun.rowset.FilteredRowSetImpl();
|
||||
}
|
||||
|
||||
|
||||
public JdbcRowSet createJdbcRowSet() throws SQLException {
|
||||
return new com.sun.rowset.JdbcRowSetImpl();
|
||||
}
|
||||
|
||||
public JoinRowSet createJoinRowSet() throws SQLException {
|
||||
return new com.sun.rowset.JoinRowSetImpl();
|
||||
}
|
||||
|
||||
public WebRowSet createWebRowSet() throws SQLException {
|
||||
return new com.sun.rowset.WebRowSetImpl();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -644,10 +644,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* of <code>execute</code> that takes a <code>ResultSet</code> object.
|
||||
*
|
||||
* @param data the <code>ResultSet</code> object containing the data
|
||||
* to be read into this <code>CachedRowSet</code> object
|
||||
* to be read into this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if a null <code>ResultSet</code> object is supplied
|
||||
* or this <code>CachedRowSet</code> object cannot
|
||||
* retrieve the associated <code>ResultSetMetaData</code> object
|
||||
* or this <code>CachedRowSet</code> object cannot
|
||||
* retrieve the associated <code>ResultSetMetaData</code> object
|
||||
* @see #execute
|
||||
* @see java.sql.ResultSet
|
||||
* @see java.sql.ResultSetMetaData
|
||||
@ -674,10 +674,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* to commit outstanding updates, those updates are lost.
|
||||
*
|
||||
* @param conn a standard JDBC <code>Connection</code> object with valid
|
||||
* properties
|
||||
* properties
|
||||
* @throws SQLException if an invalid <code>Connection</code> object is supplied
|
||||
* or an error occurs in establishing the connection to the
|
||||
* data source
|
||||
* or an error occurs in establishing the connection to the
|
||||
* data source
|
||||
* @see #populate
|
||||
* @see java.sql.Connection
|
||||
*/
|
||||
@ -736,8 +736,8 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
*
|
||||
* @throws SQLException if the cursor is on the insert row
|
||||
* @throws SyncProviderException if the underlying
|
||||
* synchronization provider's writer fails to write the updates
|
||||
* back to the data source
|
||||
* synchronization provider's writer fails to write the updates
|
||||
* back to the data source
|
||||
* @see #acceptChanges(java.sql.Connection)
|
||||
* @see javax.sql.RowSetWriter
|
||||
* @see javax.sql.rowset.spi.SyncFactory
|
||||
@ -807,8 +807,8 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param con a standard JDBC <code>Connection</code> object
|
||||
* @throws SQLException if the cursor is on the insert row
|
||||
* @throws SyncProviderException if the underlying
|
||||
* synchronization provider's writer fails to write the updates
|
||||
* back to the data source
|
||||
* synchronization provider's writer fails to write the updates
|
||||
* back to the data source
|
||||
* @see #acceptChanges()
|
||||
* @see javax.sql.RowSetWriter
|
||||
* @see javax.sql.rowset.spi.SyncFactory
|
||||
@ -867,7 +867,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* the rowset's Java VM resources.
|
||||
*
|
||||
* @throws SQLException if an error occurs flushing the contents of this
|
||||
* <code>CachedRowSet</code> object
|
||||
* <code>CachedRowSet</code> object
|
||||
* @see javax.sql.RowSetListener#rowSetChanged
|
||||
* @see java.sql.ResultSet#close
|
||||
*/
|
||||
@ -948,9 +948,9 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
*
|
||||
* @param idx an <code>int</code> identifying the column to be checked for updates
|
||||
* @return <code>true</code> if the designated column has been visibly updated;
|
||||
* <code>false</code> otherwise
|
||||
* <code>false</code> otherwise
|
||||
* @throws SQLException if the cursor is on the insert row, before the first row,
|
||||
* or after the last row
|
||||
* or after the last row
|
||||
* @see java.sql.DatabaseMetaData#updatesAreDetected
|
||||
*/
|
||||
public boolean columnUpdated(int idx) throws SQLException;
|
||||
@ -963,9 +963,9 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param columnName a <code>String</code> object giving the name of the
|
||||
* column to be checked for updates
|
||||
* @return <code>true</code> if the column has been visibly updated;
|
||||
* <code>false</code> otherwise
|
||||
* <code>false</code> otherwise
|
||||
* @throws SQLException if the cursor is on the insert row, before the first row,
|
||||
* or after the last row
|
||||
* or after the last row
|
||||
* @see java.sql.DatabaseMetaData#updatesAreDetected
|
||||
*/
|
||||
public boolean columnUpdated(String columnName) throws SQLException;
|
||||
@ -1003,7 +1003,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* <P>
|
||||
*
|
||||
* @return a <code>Collection</code> object that contains the values in
|
||||
* each row in this <code>CachedRowSet</code> object
|
||||
* each row in this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if an error occurs generating the collection
|
||||
* @see #toCollection(int)
|
||||
* @see #toCollection(String)
|
||||
@ -1030,10 +1030,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param column an <code>int</code> indicating the column whose values
|
||||
* are to be represented in a <code>Collection</code> object
|
||||
* @return a <code>Collection</code> object that contains the values
|
||||
* stored in the specified column of this <code>CachedRowSet</code>
|
||||
* object
|
||||
* stored in the specified column of this <code>CachedRowSet</code>
|
||||
* object
|
||||
* @throws SQLException if an error occurs generating the collection or
|
||||
* an invalid column id is provided
|
||||
* an invalid column id is provided
|
||||
* @see #toCollection
|
||||
* @see #toCollection(String)
|
||||
*/
|
||||
@ -1059,10 +1059,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param column a <code>String</code> object giving the name of the
|
||||
* column whose values are to be represented in a collection
|
||||
* @return a <code>Collection</code> object that contains the values
|
||||
* stored in the specified column of this <code>CachedRowSet</code>
|
||||
* object
|
||||
* stored in the specified column of this <code>CachedRowSet</code>
|
||||
* object
|
||||
* @throws SQLException if an error occurs generating the collection or
|
||||
* an invalid column id is provided
|
||||
* an invalid column id is provided
|
||||
* @see #toCollection
|
||||
* @see #toCollection(int)
|
||||
*/
|
||||
@ -1100,7 +1100,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @return the <code>SyncProvider</code> object that was set when the rowset
|
||||
* was instantiated, or if none was was set, the default provider
|
||||
* @throws SQLException if an error occurs while returning the
|
||||
* <code>SyncProvider</code> object
|
||||
* <code>SyncProvider</code> object
|
||||
* @see #setSyncProvider
|
||||
*/
|
||||
public SyncProvider getSyncProvider() throws SQLException;
|
||||
@ -1127,7 +1127,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param provider a <code>String</code> object giving the fully qualified class
|
||||
* name of a <code>SyncProvider</code> implementation
|
||||
* @throws SQLException if an error occurs while attempting to reset the
|
||||
* <code>SyncProvider</code> implementation
|
||||
* <code>SyncProvider</code> implementation
|
||||
* @see #getSyncProvider
|
||||
*/
|
||||
public void setSyncProvider(String provider) throws SQLException;
|
||||
@ -1152,9 +1152,9 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* object to the rowset.
|
||||
*
|
||||
* @param md a <code>RowSetMetaData</code> object containing
|
||||
* metadata about the columns in this <code>CachedRowSet</code> object
|
||||
* metadata about the columns in this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if invalid metadata is supplied to the
|
||||
* rowset
|
||||
* rowset
|
||||
*/
|
||||
public void setMetaData(RowSetMetaData md) throws SQLException;
|
||||
|
||||
@ -1183,7 +1183,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @return a <code>ResultSet</code> object that contains the original value for
|
||||
* this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if an error occurs producing the
|
||||
* <code>ResultSet</code> object
|
||||
* <code>ResultSet</code> object
|
||||
*/
|
||||
public ResultSet getOriginal() throws SQLException;
|
||||
|
||||
@ -1217,7 +1217,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* A call to <code>setOriginalRow</code> is irreversible.
|
||||
*
|
||||
* @throws SQLException if there is no current row or an error is
|
||||
* encountered resetting the contents of the original row
|
||||
* encountered resetting the contents of the original row
|
||||
* @see #getOriginalRow
|
||||
*/
|
||||
public void setOriginalRow() throws SQLException;
|
||||
@ -1326,7 +1326,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* as this <code>CachedRowSet</code> object and that has a cursor over
|
||||
* the same data
|
||||
* @throws SQLException if an error occurs or cloning is not
|
||||
* supported in the underlying platform
|
||||
* supported in the underlying platform
|
||||
* @see javax.sql.RowSetEvent
|
||||
* @see javax.sql.RowSetListener
|
||||
*/
|
||||
@ -1344,10 +1344,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* established must be maintained.
|
||||
*
|
||||
* @return a new <code>RowSet</code> object that is a deep copy
|
||||
* of this <code>CachedRowSet</code> object and is
|
||||
* completely independent of this <code>CachedRowSet</code> object
|
||||
* of this <code>CachedRowSet</code> object and is
|
||||
* completely independent of this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if an error occurs in generating the copy of
|
||||
* the of this <code>CachedRowSet</code> object
|
||||
* the of this <code>CachedRowSet</code> object
|
||||
* @see #createShared
|
||||
* @see #createCopySchema
|
||||
* @see #createCopyNoConstraints
|
||||
@ -1396,10 +1396,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* in the copy.
|
||||
*
|
||||
* @return a new <code>CachedRowSet</code> object that is a deep copy
|
||||
* of this <code>CachedRowSet</code> object and is
|
||||
* completely independent of this <code>CachedRowSet</code> object
|
||||
* of this <code>CachedRowSet</code> object and is
|
||||
* completely independent of this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if an error occurs in generating the copy of
|
||||
* the of this <code>CachedRowSet</code> object
|
||||
* the of this <code>CachedRowSet</code> object
|
||||
* @see #createCopy
|
||||
* @see #createShared
|
||||
* @see #createCopySchema
|
||||
@ -1445,7 +1445,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @return <code>true</code> if deleted rows are visible;
|
||||
* <code>false</code> otherwise
|
||||
* @throws SQLException if a rowset implementation is unable to
|
||||
* to determine whether rows marked for deletion are visible
|
||||
* to determine whether rows marked for deletion are visible
|
||||
* @see #setShowDeleted
|
||||
*/
|
||||
public boolean getShowDeleted() throws SQLException;
|
||||
@ -1467,7 +1467,7 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param b <code>true</code> if deleted rows should be shown;
|
||||
* <code>false</code> otherwise
|
||||
* @exception SQLException if a rowset implementation is unable to
|
||||
* to reset whether deleted rows should be visible
|
||||
* to reset whether deleted rows should be visible
|
||||
* @see #getShowDeleted
|
||||
*/
|
||||
public void setShowDeleted(boolean b) throws SQLException;
|
||||
@ -1523,9 +1523,12 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* set to false, the changes will <b>not</b> be committed until one of the
|
||||
* <code>CachedRowSet</code> interface transaction methods is called.
|
||||
*
|
||||
* @deprecated Because this field is final (it is part of an interface),
|
||||
* its value cannot be changed.
|
||||
* @see #commit
|
||||
* @see #rollback
|
||||
*/
|
||||
@Deprecated
|
||||
public static final boolean COMMIT_ON_ACCEPT_CHANGES = true;
|
||||
|
||||
/**
|
||||
@ -1562,10 +1565,10 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
* @param startRow the position in the <code>ResultSet</code> from where to start
|
||||
* populating the records in this <code>CachedRowSet</code>
|
||||
* @param rs the <code>ResultSet</code> object containing the data
|
||||
* to be read into this <code>CachedRowSet</code> object
|
||||
* to be read into this <code>CachedRowSet</code> object
|
||||
* @throws SQLException if a null <code>ResultSet</code> object is supplied
|
||||
* or this <code>CachedRowSet</code> object cannot
|
||||
* retrieve the associated <code>ResultSetMetaData</code> object
|
||||
* or this <code>CachedRowSet</code> object cannot
|
||||
* retrieve the associated <code>ResultSetMetaData</code> object
|
||||
* @see #execute
|
||||
* @see #populate(ResultSet)
|
||||
* @see java.sql.ResultSet
|
||||
@ -1620,3 +1623,4 @@ public interface CachedRowSet extends RowSet, Joinable {
|
||||
public boolean previousPage() throws SQLException;
|
||||
|
||||
}
|
||||
|
||||
|
99
jdk/src/share/classes/javax/sql/rowset/RowSetFactory.java
Normal file
99
jdk/src/share/classes/javax/sql/rowset/RowSetFactory.java
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sql.rowset;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* An interface that defines the implementation of a factory that is used
|
||||
* to obtain different types of {@code RowSet} implementations.
|
||||
*
|
||||
* @author Lance Andersen
|
||||
* @since 1.7
|
||||
*/
|
||||
public interface RowSetFactory{
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a CachedRowSet.</p>
|
||||
*
|
||||
* @return A new instance of a CachedRowSet.
|
||||
*
|
||||
* @throws SQLException if a CachedRowSet cannot
|
||||
* be created.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public CachedRowSet createCachedRowSet() throws SQLException;
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a FilteredRowSet.</p>
|
||||
*
|
||||
* @return A new instance of a FilteredRowSet.
|
||||
*
|
||||
* @throws SQLException if a FilteredRowSet cannot
|
||||
* be created.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public FilteredRowSet createFilteredRowSet() throws SQLException;
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a JdbcRowSet.</p>
|
||||
*
|
||||
* @return A new instance of a JdbcRowSet.
|
||||
*
|
||||
* @throws SQLException if a JdbcRowSet cannot
|
||||
* be created.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public JdbcRowSet createJdbcRowSet() throws SQLException;
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a JoinRowSet.</p>
|
||||
*
|
||||
* @return A new instance of a JoinRowSet.
|
||||
*
|
||||
* @throws SQLException if a JoinRowSet cannot
|
||||
* be created.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public JoinRowSet createJoinRowSet() throws SQLException;
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a WebRowSet.</p>
|
||||
*
|
||||
* @return A new instance of a WebRowSet.
|
||||
*
|
||||
* @throws SQLException if a WebRowSet cannot
|
||||
* be created.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public WebRowSet createWebRowSet() throws SQLException;
|
||||
|
||||
}
|
305
jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java
Normal file
305
jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java
Normal file
@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sql.rowset;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ServiceLoader;
|
||||
import javax.sql.rowset.RowSetFactory;
|
||||
|
||||
/**
|
||||
* A factory API that enables applications to obtain a
|
||||
* {@code RowSetFactory} implementation that can be used to create different
|
||||
* types of {@code RowSet} implementations.
|
||||
* <p>
|
||||
* Example:
|
||||
* </p>
|
||||
* <pre>
|
||||
* RowSetFactory aFactory = RowSetProvider.newFactory();
|
||||
* CachedRowSet crs = aFactory.createCachedRowSet();
|
||||
* ...
|
||||
* RowSetFactory rsf = RowSetProvider.newFactory("com.sun.rowset.RowSetFactoryImpl", null);
|
||||
* WebRowSet wrs = rsf.createWebRowSet();
|
||||
* </pre>
|
||||
*<p>
|
||||
* Tracing of this class may be enabled by setting the System property
|
||||
* {@code javax.sql.rowset.RowSetFactory.debug} to any value but {@code false}.
|
||||
* </p>
|
||||
*
|
||||
* @author Lance Andersen
|
||||
* @since 1.7
|
||||
*/
|
||||
public class RowSetProvider {
|
||||
|
||||
private static final String ROWSET_DEBUG_PROPERTY = "javax.sql.rowset.RowSetProvider.debug";
|
||||
private static final String ROWSET_FACTORY_IMPL = "com.sun.rowset.RowSetFactoryImpl";
|
||||
private static final String ROWSET_FACTORY_NAME = "javax.sql.rowset.RowSetFactory";
|
||||
/**
|
||||
* Internal debug flag.
|
||||
*/
|
||||
private static boolean debug = true;
|
||||
|
||||
|
||||
static {
|
||||
// Check to see if the debug property is set
|
||||
String val = getSystemProperty(ROWSET_DEBUG_PROPERTY);
|
||||
// Allow simply setting the prop to turn on debug
|
||||
debug = val != null && !"false".equals(val);
|
||||
}
|
||||
|
||||
|
||||
protected RowSetProvider () {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a <code>RowSetFactory</code>
|
||||
* implementation. This method uses the following
|
||||
* look up order to determine
|
||||
* the <code>RowSetFactory</code> implementation class to load:</p>
|
||||
* <ul>
|
||||
* <li>
|
||||
* The System property {@code javax.sql.rowset.RowsetFactory}. For example:
|
||||
* <ul>
|
||||
* <li>
|
||||
* -Djavax.sql.rowset.RowsetFactory=com.sun.rowset.RowSetFactoryImpl
|
||||
* </li>
|
||||
* </ul>
|
||||
* <li>
|
||||
* The ServiceLocator API. The ServiceLocator API will look
|
||||
* for a classname in the file
|
||||
* {@code META-INF/services/javax.sql.rowset.RowSetFactory}
|
||||
* in jars available to the runtime. For example, to have the the RowSetFactory
|
||||
* implementation {@code com.sun.rowset.RowSetFactoryImpl } loaded, the
|
||||
* entry in {@code META-INF/services/javax.sql.rowset.RowSetFactory} would be:
|
||||
* <ul>
|
||||
* <li>
|
||||
* {@code com.sun.rowset.RowSetFactoryImpl }
|
||||
* </li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>
|
||||
* Platform default <code>RowSetFactory</code> instance.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Once an application has obtained a reference to a {@code RowSetFactory},
|
||||
* it can use the factory to obtain RowSet instances.</p>
|
||||
*
|
||||
* @return New instance of a <code>RowSetFactory</code>
|
||||
*
|
||||
* @throws SQLException if the default factory class cannot be loaded,
|
||||
* instantiated. The cause will be set to actual Exception
|
||||
*
|
||||
* @see ServiceLoader
|
||||
* @since 1.7
|
||||
*/
|
||||
public static RowSetFactory newFactory()
|
||||
throws SQLException {
|
||||
// Use the system property first
|
||||
RowSetFactory factory = null;
|
||||
String factoryClassName = null;
|
||||
try {
|
||||
trace("Checking for Rowset System Property...");
|
||||
factoryClassName = getSystemProperty(ROWSET_FACTORY_NAME);
|
||||
if (factoryClassName != null) {
|
||||
trace("Found system property, value=" + factoryClassName);
|
||||
factory = (RowSetFactory) getFactoryClass(factoryClassName, null, true).newInstance();
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new SQLException(
|
||||
"RowSetFactory: " + factoryClassName + " not found", e);
|
||||
} catch (Exception e) {
|
||||
throw new SQLException(
|
||||
"RowSetFactory: " + factoryClassName + " could not be instantiated: " + e,
|
||||
e);
|
||||
}
|
||||
|
||||
// Check to see if we found the RowSetFactory via a System property
|
||||
if (factory == null) {
|
||||
// If the RowSetFactory is not found via a System Property, now
|
||||
// look it up via the ServiceLoader API and if not found, use the
|
||||
// Java SE default.
|
||||
factory = loadViaServiceLoader();
|
||||
factory =
|
||||
factory == null ? newFactory(ROWSET_FACTORY_IMPL, null) : factory;
|
||||
}
|
||||
return (factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates a new instance of a <code>RowSetFactory</code> from the
|
||||
* specified factory class name.
|
||||
* This function is useful when there are multiple providers in the classpath.
|
||||
* It gives more control to the application as it can specify which provider
|
||||
* should be loaded.</p>
|
||||
*
|
||||
* <p>Once an application has obtained a reference to a <code>RowSetFactory</code>
|
||||
* it can use the factory to obtain RowSet instances.</p>
|
||||
*
|
||||
* @param factoryClassName fully qualified factory class name that
|
||||
* provides an implementation of <code>javax.sql.rowset.RowSetFactory</code>.
|
||||
*
|
||||
* @param cl <code>ClassLoader</code> used to load the factory
|
||||
* class. If <code>null</code> current <code>Thread</code>'s context
|
||||
* classLoader is used to load the factory class.
|
||||
*
|
||||
* @return New instance of a <code>RowSetFactory</code>
|
||||
*
|
||||
* @throws SQLException if <code>factoryClassName</code> is
|
||||
* <code>null</code>, or the factory class cannot be loaded, instantiated.
|
||||
*
|
||||
* @see #newFactory()
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static RowSetFactory newFactory(String factoryClassName, ClassLoader cl)
|
||||
throws SQLException {
|
||||
|
||||
trace("***In newInstance()");
|
||||
try {
|
||||
Class providerClass = getFactoryClass(factoryClassName, cl, false);
|
||||
RowSetFactory instance = (RowSetFactory) providerClass.newInstance();
|
||||
if (debug) {
|
||||
trace("Created new instance of " + providerClass +
|
||||
" using ClassLoader: " + cl);
|
||||
}
|
||||
return instance;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new SQLException(
|
||||
"Provider " + factoryClassName + " not found", x);
|
||||
} catch (Exception x) {
|
||||
throw new SQLException(
|
||||
"Provider " + factoryClassName + " could not be instantiated: " + x,
|
||||
x);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the class loader to be used.
|
||||
* @return The ClassLoader to use.
|
||||
*
|
||||
*/
|
||||
static private ClassLoader getContextClassLoader() throws SecurityException {
|
||||
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
|
||||
|
||||
public Object run() {
|
||||
ClassLoader cl = null;
|
||||
|
||||
cl = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
if (cl == null) {
|
||||
cl = ClassLoader.getSystemClassLoader();
|
||||
}
|
||||
|
||||
return cl;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load a class using the class loader supplied. If that fails
|
||||
* and fall back is enabled, the current (i.e. bootstrap) class loader is
|
||||
* tried.
|
||||
*
|
||||
* If the class loader supplied is <code>null</code>, first try using the
|
||||
* context class loader followed by the current class loader.
|
||||
* @return The class which was loaded
|
||||
*/
|
||||
static private Class getFactoryClass(String factoryClassName, ClassLoader cl,
|
||||
boolean doFallback) throws ClassNotFoundException {
|
||||
try {
|
||||
if (cl == null) {
|
||||
cl = getContextClassLoader();
|
||||
if (cl == null) {
|
||||
throw new ClassNotFoundException();
|
||||
} else {
|
||||
return cl.loadClass(factoryClassName);
|
||||
}
|
||||
} else {
|
||||
return cl.loadClass(factoryClassName);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (doFallback) {
|
||||
// Use current class loader
|
||||
return Class.forName(factoryClassName, true, RowSetFactory.class.getClassLoader());
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the ServiceLoader mechanism to load the default RowSetFactory
|
||||
* @return default RowSetFactory Implementation
|
||||
*/
|
||||
static private RowSetFactory loadViaServiceLoader() {
|
||||
RowSetFactory theFactory = null;
|
||||
trace("***in loadViaServiceLoader()");
|
||||
for (RowSetFactory factory : ServiceLoader.load(javax.sql.rowset.RowSetFactory.class)) {
|
||||
trace(" Loading done by the java.util.ServiceLoader :" + factory.getClass().getName());
|
||||
theFactory = factory;
|
||||
break;
|
||||
}
|
||||
return theFactory;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested System Property. If a {@code SecurityException}
|
||||
* occurs, just return NULL
|
||||
* @param propName - System property to retreive
|
||||
* @return The System property value or NULL if the property does not exist
|
||||
* or a {@code SecurityException} occurs.
|
||||
*/
|
||||
static private String getSystemProperty(final String propName) {
|
||||
String property = null;
|
||||
try {
|
||||
property = (String) AccessController.doPrivileged(new PrivilegedAction() {
|
||||
|
||||
public Object run() {
|
||||
return System.getProperty(propName);
|
||||
}
|
||||
});
|
||||
} catch (SecurityException se) {
|
||||
if (debug) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug routine which will output tracing if the System Property
|
||||
* -Djavax.sql.rowset.RowSetFactory.debug is set
|
||||
* @param msg - The debug message to display
|
||||
*/
|
||||
private static void trace(String msg) {
|
||||
if (debug) {
|
||||
System.err.println("###RowSets: " + msg);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<!--
|
||||
Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
@ -78,7 +78,7 @@ object provides a fully updatable and scrollable tabular
|
||||
data structure as defined in the JDBC 3.0 specification.
|
||||
<p>
|
||||
<li><a href="CachedRowSet.html">
|
||||
<b><code>CachedRowSet</code><sup><font size=-2>TM></font></sup</b></a>
|
||||
<b><code>CachedRowSet</code>™</b></a>
|
||||
- A <tt>CachedRowSet</tt> object is a JavaBeans<sup><font size=-2>TM</font></sup>
|
||||
component that is scrollable, updatable, serializable, and generally disconnected from
|
||||
the source of its data. A <tt>CachedRowSet</tt> object
|
||||
@ -148,7 +148,12 @@ href="spi/package-summary.html">javax.sql.rowset.spi</a> package for guidelines
|
||||
on <a href="spi/SyncProvider.html"><code>SyncProvider</code></a> implementations.
|
||||
<p>
|
||||
<ul>
|
||||
<li><b>3.1 Role of the <code>BaseRowSet</code> Class</b>
|
||||
<li><b>3.1 Constructor</b>
|
||||
<p>
|
||||
All <code>RowSet</code> implementations <strong>must</strong> provide a
|
||||
no-argument constructor.
|
||||
</li>
|
||||
<li><b>3.2 Role of the <code>BaseRowSet</code> Class</b>
|
||||
<p>
|
||||
A compliant JDBC <code>RowSet</code> implementation <b>must</b> implement one or more
|
||||
standard interfaces specified in this package and and <b>may</b> extend the
|
||||
@ -215,7 +220,7 @@ by compliant implementations.<br>
|
||||
</table>
|
||||
</blockquote>
|
||||
<p>
|
||||
<li><b>3.2 Connected RowSet Requirements</b>
|
||||
<li><b>3.3 Connected RowSet Requirements</b>
|
||||
<p>
|
||||
The <code>JdbcRowSet</code> describes a <code>RowSet</code> object that <b>must</b> always
|
||||
be connected to the originating data source. Implementations of the <code>JdbcRowSet</code>
|
||||
@ -229,7 +234,7 @@ supply their needs by virtue of the presence of an underlying updatable and scro
|
||||
<p>
|
||||
|
||||
<li>
|
||||
<b>3.3 Disconnected RowSet Requirements</b>
|
||||
<b>3.4 Disconnected RowSet Requirements</b>
|
||||
<p>
|
||||
A disconnected <code>RowSet</code> object, such as a <code>CachedRowSet</code> object,
|
||||
<b>should</b> delegate
|
||||
@ -244,7 +249,7 @@ synchronization is required. A disconnected <code>RowSet</code> object should
|
||||
therefore ensure that no
|
||||
extraneous references remain on the <code>Connection</code> object.
|
||||
<p>
|
||||
<li><b>3.4 Role of RowSetMetaDataImpl</b>
|
||||
<li><b>3.5 Role of RowSetMetaDataImpl</b>
|
||||
<p>
|
||||
The <code>RowsetMetaDataImpl</code> class is a utility class that provides an implementation of the
|
||||
<a href="../RowSetMetaData.html">RowSetMetaData</a> interface, supplying standard setter
|
||||
@ -252,7 +257,7 @@ method implementations for metadata for both connected and disconnected
|
||||
<code>RowSet</code> objects. All implementations are free to use this standard
|
||||
implementation but are not required to do so.
|
||||
<p>
|
||||
<li><b>3.5 RowSetWarning Class</b>
|
||||
<li><b>3.6 RowSetWarning Class</b>
|
||||
<p>
|
||||
The <code>RowSetWarning</code> class provides warnings that can be set
|
||||
on <code>RowSet</code> implementations.
|
||||
@ -270,7 +275,7 @@ on it, and so on until there are no more warnings.
|
||||
|
||||
|
||||
<P>
|
||||
<li><b>3.6 The Joinable Interface</b>
|
||||
<li><b>3.7 The Joinable Interface</b>
|
||||
<P>
|
||||
The <code>Joinable</code> interface provides both connected and disconnected
|
||||
<code>RowSet</code> objects with the capability to be added to a
|
||||
@ -278,7 +283,14 @@ The <code>Joinable</code> interface provides both connected and disconnected
|
||||
A <code>RowSet</code> object that has implemented the <code>Joinable</code>
|
||||
interface can set a match column, retrieve a match column, or unset a match column.
|
||||
A <code>JoinRowSet</code> object can then use the <code>RowSet</code> object's
|
||||
match column as a basis for adding the <code>RowSet</code> object.
|
||||
match column as a basis for adding the <code>RowSet</code> object.
|
||||
</li>
|
||||
|
||||
<li><b>3.8 The RowSetFactory Interface</b>
|
||||
<p>
|
||||
A <code>RowSetFactory</code> implementation <strong>must</strong>
|
||||
be provided.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3><a name="relspec">4.0 Related Specifications</a></h3>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,6 @@
|
||||
|
||||
package javax.sql.rowset.spi;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import java.util.Properties;
|
||||
import java.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.*;
|
||||
import java.util.*;
|
||||
|
||||
@ -216,68 +209,64 @@ public class SyncFactory {
|
||||
* Having a private constructor guarantees that no more than
|
||||
* one <code>SyncProvider</code> object can exist at a time.
|
||||
*/
|
||||
private SyncFactory() {};
|
||||
private SyncFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The standard property-id for a synchronization provider implementation
|
||||
* name.
|
||||
*/
|
||||
public static String ROWSET_SYNC_PROVIDER =
|
||||
"rowset.provider.classname";
|
||||
|
||||
public static final String ROWSET_SYNC_PROVIDER =
|
||||
"rowset.provider.classname";
|
||||
/**
|
||||
* The standard property-id for a synchronization provider implementation
|
||||
* vendor name.
|
||||
*/
|
||||
public static String ROWSET_SYNC_VENDOR =
|
||||
"rowset.provider.vendor";
|
||||
|
||||
public static final String ROWSET_SYNC_VENDOR =
|
||||
"rowset.provider.vendor";
|
||||
/**
|
||||
* The standard property-id for a synchronization provider implementation
|
||||
* version tag.
|
||||
*/
|
||||
public static String ROWSET_SYNC_PROVIDER_VERSION =
|
||||
"rowset.provider.version";
|
||||
|
||||
public static final String ROWSET_SYNC_PROVIDER_VERSION =
|
||||
"rowset.provider.version";
|
||||
/**
|
||||
* The standard resource file name.
|
||||
*/
|
||||
private static String ROWSET_PROPERTIES = "rowset.properties";
|
||||
|
||||
/**
|
||||
* The RI Optimistic Provider.
|
||||
*/
|
||||
private static String default_provider =
|
||||
"com.sun.rowset.providers.RIOptimisticProvider";
|
||||
|
||||
"com.sun.rowset.providers.RIOptimisticProvider";
|
||||
/**
|
||||
* Permission required to invoke setJNDIContext and setLogger
|
||||
*/
|
||||
private static final SQLPermission SET_SYNCFACTORY_PERMISSION =
|
||||
new SQLPermission("setSyncFactory");
|
||||
/**
|
||||
* The initial JNDI context where <code>SyncProvider</code> implementations can
|
||||
* be stored and from which they can be invoked.
|
||||
*/
|
||||
private static Context ic;
|
||||
|
||||
/**
|
||||
* The <code>Logger</code> object to be used by the <code>SyncFactory</code>.
|
||||
*/
|
||||
private static Logger rsLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static Level rsLevel;
|
||||
|
||||
/**
|
||||
* The registry of available <code>SyncProvider</code> implementations.
|
||||
* See section 2.0 of the class comment for <code>SyncFactory</code> for an
|
||||
* explanation of how a provider can be added to this registry.
|
||||
*/
|
||||
private static Hashtable implementations;
|
||||
|
||||
/**
|
||||
* Internal sync object used to maintain the SPI as a singleton
|
||||
*/
|
||||
private static Object logSync = new Object();
|
||||
|
||||
/**
|
||||
* Internal PrintWriter field for logging facility
|
||||
*/
|
||||
@ -311,7 +300,7 @@ public class SyncFactory {
|
||||
* @see #setJNDIContext
|
||||
*/
|
||||
public static synchronized void registerProvider(String providerID)
|
||||
throws SyncFactoryException {
|
||||
throws SyncFactoryException {
|
||||
|
||||
ProviderImpl impl = new ProviderImpl();
|
||||
impl.setClassname(providerID);
|
||||
@ -325,29 +314,29 @@ public class SyncFactory {
|
||||
*
|
||||
* @return the <code>SyncFactory</code> instance
|
||||
*/
|
||||
public static SyncFactory getSyncFactory(){
|
||||
public static SyncFactory getSyncFactory() {
|
||||
|
||||
// This method uses the Singleton Design Pattern
|
||||
// with Double-Checked Locking Pattern for
|
||||
// 1. Creating single instance of the SyncFactory
|
||||
// 2. Make the class thread safe, so that at one time
|
||||
// only one thread enters the synchronized block
|
||||
// to instantiate.
|
||||
// This method uses the Singleton Design Pattern
|
||||
// with Double-Checked Locking Pattern for
|
||||
// 1. Creating single instance of the SyncFactory
|
||||
// 2. Make the class thread safe, so that at one time
|
||||
// only one thread enters the synchronized block
|
||||
// to instantiate.
|
||||
|
||||
// if syncFactory object is already there
|
||||
// don't go into synchronized block and return
|
||||
// that object.
|
||||
// else go into synchronized block
|
||||
// if syncFactory object is already there
|
||||
// don't go into synchronized block and return
|
||||
// that object.
|
||||
// else go into synchronized block
|
||||
|
||||
if(syncFactory == null){
|
||||
synchronized(SyncFactory.class) {
|
||||
if(syncFactory == null){
|
||||
if (syncFactory == null) {
|
||||
synchronized (SyncFactory.class) {
|
||||
if (syncFactory == null) {
|
||||
syncFactory = new SyncFactory();
|
||||
} //end if
|
||||
} //end synchronized block
|
||||
} //end if
|
||||
return syncFactory;
|
||||
}
|
||||
} //end synchronized block
|
||||
} //end if
|
||||
return syncFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the designated currently registered synchronization provider from the
|
||||
@ -358,13 +347,12 @@ public class SyncFactory {
|
||||
* unregister a SyncProvider implementation that was not registered.
|
||||
*/
|
||||
public static synchronized void unregisterProvider(String providerID)
|
||||
throws SyncFactoryException {
|
||||
throws SyncFactoryException {
|
||||
initMapIfNecessary();
|
||||
if (implementations.containsKey(providerID)) {
|
||||
implementations.remove(providerID);
|
||||
}
|
||||
}
|
||||
|
||||
private static String colon = ":";
|
||||
private static String strFileSep = "/";
|
||||
|
||||
@ -395,7 +383,7 @@ public class SyncFactory {
|
||||
* Dependent on application
|
||||
*/
|
||||
String strRowsetProperties = System.getProperty("rowset.properties");
|
||||
if ( strRowsetProperties != null) {
|
||||
if (strRowsetProperties != null) {
|
||||
// Load user's implementation of SyncProvider
|
||||
// here. -Drowset.properties=/abc/def/pqr.txt
|
||||
ROWSET_PROPERTIES = strRowsetProperties;
|
||||
@ -407,8 +395,8 @@ public class SyncFactory {
|
||||
* Always available
|
||||
*/
|
||||
ROWSET_PROPERTIES = "javax" + strFileSep + "sql" +
|
||||
strFileSep + "rowset" + strFileSep +
|
||||
"rowset.properties";
|
||||
strFileSep + "rowset" + strFileSep +
|
||||
"rowset.properties";
|
||||
// properties.load(
|
||||
// ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES));
|
||||
|
||||
@ -417,7 +405,7 @@ public class SyncFactory {
|
||||
properties.load(cl.getResourceAsStream(ROWSET_PROPERTIES));
|
||||
parseProperties(properties);
|
||||
|
||||
// removed else, has properties should sum together
|
||||
// removed else, has properties should sum together
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new SyncFactoryException("Cannot locate properties file: " + e);
|
||||
@ -447,18 +435,15 @@ public class SyncFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal boolean switch that indicates whether a JNDI
|
||||
* context has been established or not.
|
||||
*/
|
||||
private static boolean jndiCtxEstablished = false;
|
||||
|
||||
/**
|
||||
* The internal debug switch.
|
||||
*/
|
||||
private static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Internal registry count for the number of providers contained in the
|
||||
* registry.
|
||||
@ -475,9 +460,9 @@ public class SyncFactory {
|
||||
String key = null;
|
||||
String[] propertyNames = null;
|
||||
|
||||
for (Enumeration e = p.propertyNames(); e.hasMoreElements() ;) {
|
||||
for (Enumeration e = p.propertyNames(); e.hasMoreElements();) {
|
||||
|
||||
String str = (String)e.nextElement();
|
||||
String str = (String) e.nextElement();
|
||||
|
||||
int w = str.length();
|
||||
|
||||
@ -491,7 +476,7 @@ public class SyncFactory {
|
||||
propertyNames = getPropertyNames(false);
|
||||
} else {
|
||||
// property index has been set.
|
||||
propertyNames = getPropertyNames(true, str.substring(w-1));
|
||||
propertyNames = getPropertyNames(true, str.substring(w - 1));
|
||||
}
|
||||
|
||||
key = p.getProperty(propertyNames[0]);
|
||||
@ -515,17 +500,17 @@ public class SyncFactory {
|
||||
* overloaded property names that contain indexes.
|
||||
*/
|
||||
private static String[] getPropertyNames(boolean append,
|
||||
String propertyIndex) {
|
||||
String propertyIndex) {
|
||||
String dot = ".";
|
||||
String[] propertyNames =
|
||||
new String[] {SyncFactory.ROWSET_SYNC_PROVIDER,
|
||||
SyncFactory.ROWSET_SYNC_VENDOR,
|
||||
SyncFactory.ROWSET_SYNC_PROVIDER_VERSION};
|
||||
new String[]{SyncFactory.ROWSET_SYNC_PROVIDER,
|
||||
SyncFactory.ROWSET_SYNC_VENDOR,
|
||||
SyncFactory.ROWSET_SYNC_PROVIDER_VERSION};
|
||||
if (append) {
|
||||
for (int i = 0; i < propertyNames.length; i++) {
|
||||
propertyNames[i] = propertyNames[i] +
|
||||
dot +
|
||||
propertyIndex;
|
||||
dot +
|
||||
propertyIndex;
|
||||
}
|
||||
return propertyNames;
|
||||
} else {
|
||||
@ -549,15 +534,21 @@ public class SyncFactory {
|
||||
*
|
||||
* @param providerID the unique identifier of the provider
|
||||
* @return a <code>SyncProvider</code> implementation
|
||||
* @throws SyncFactoryException If the SyncProvider cannot be found or
|
||||
* @throws SyncFactoryException If the SyncProvider cannot be found,
|
||||
* the providerID is {@code null}, or
|
||||
* some error was encountered when trying to invoke this provider.
|
||||
*/
|
||||
public static SyncProvider getInstance(String providerID)
|
||||
throws SyncFactoryException {
|
||||
throws SyncFactoryException {
|
||||
|
||||
if(providerID == null) {
|
||||
throw new SyncFactoryException("The providerID cannot be null");
|
||||
}
|
||||
|
||||
initMapIfNecessary(); // populate HashTable
|
||||
initJNDIContext(); // check JNDI context for any additional bindings
|
||||
|
||||
ProviderImpl impl = (ProviderImpl)implementations.get(providerID);
|
||||
ProviderImpl impl = (ProviderImpl) implementations.get(providerID);
|
||||
|
||||
if (impl == null) {
|
||||
// Requested SyncProvider is unavailable. Return default provider.
|
||||
@ -575,11 +566,10 @@ public class SyncFactory {
|
||||
* this SyncFactory and try to laod the SyncProvider class from
|
||||
* there.
|
||||
**/
|
||||
|
||||
c = Class.forName(providerID, true, cl);
|
||||
|
||||
if (c != null) {
|
||||
return (SyncProvider)c.newInstance();
|
||||
return (SyncProvider) c.newInstance();
|
||||
} else {
|
||||
return new com.sun.rowset.providers.RIOptimisticProvider();
|
||||
}
|
||||
@ -592,6 +582,7 @@ public class SyncFactory {
|
||||
throw new SyncFactoryException("ClassNotFoundException: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Enumeration of currently registered synchronization
|
||||
* providers. A <code>RowSet</code> implementation may use any provider in
|
||||
@ -605,7 +596,7 @@ public class SyncFactory {
|
||||
* providers that are registered with this Factory
|
||||
*/
|
||||
public static Enumeration<SyncProvider> getRegisteredProviders()
|
||||
throws SyncFactoryException {
|
||||
throws SyncFactoryException {
|
||||
initMapIfNecessary();
|
||||
// return a collection of classnames
|
||||
// of type SyncProvider
|
||||
@ -618,10 +609,26 @@ public class SyncFactory {
|
||||
* <code>SyncProvider</code> implementations can log their events to
|
||||
* this object and the application can retrieve a handle to this
|
||||
* object using the <code>getLogger</code> method.
|
||||
* <p>
|
||||
* This method checks to see that there is an {@code SQLPermission}
|
||||
* object which grants the permission {@code setSyncFactory}
|
||||
* before allowing the method to succeed. If a
|
||||
* {@code SecurityManager} exists and its
|
||||
* {@code checkPermission} method denies calling {@code setLogger},
|
||||
* this method throws a
|
||||
* {@code java.lang.SecurityException}.
|
||||
*
|
||||
* @param logger A Logger object instance
|
||||
* @throws java.lang.SecurityException if a security manager exists and its
|
||||
* {@code checkPermission} method denies calling {@code setLogger}
|
||||
* @see SecurityManager#checkPermission
|
||||
*/
|
||||
public static void setLogger(Logger logger) {
|
||||
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
sec.checkPermission(SET_SYNCFACTORY_PERMISSION);
|
||||
}
|
||||
rsLogger = logger;
|
||||
}
|
||||
|
||||
@ -631,14 +638,28 @@ public class SyncFactory {
|
||||
* <code>SyncProvider</code> implementations can log their events
|
||||
* to this object and the application can retrieve a handle to this
|
||||
* object using the <code>getLogger</code> method.
|
||||
* <p>
|
||||
* This method checks to see that there is an {@code SQLPermission}
|
||||
* object which grants the permission {@code setSyncFactory}
|
||||
* before allowing the method to succeed. If a
|
||||
* {@code SecurityManager} exists and its
|
||||
* {@code checkPermission} method denies calling {@code setLogger},
|
||||
* this method throws a
|
||||
* {@code java.lang.SecurityException}.
|
||||
*
|
||||
* @param logger a Logger object instance
|
||||
* @param level a Level object instance indicating the degree of logging
|
||||
* required
|
||||
* @throws java.lang.SecurityException if a security manager exists and its
|
||||
* {@code checkPermission} method denies calling {@code setLogger}
|
||||
* @see SecurityManager#checkPermission
|
||||
*/
|
||||
public static void setLogger(Logger logger, Level level) {
|
||||
// singleton
|
||||
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
sec.checkPermission(SET_SYNCFACTORY_PERMISSION);
|
||||
}
|
||||
rsLogger = logger;
|
||||
rsLogger.setLevel(level);
|
||||
}
|
||||
@ -651,27 +672,42 @@ public class SyncFactory {
|
||||
*/
|
||||
public static Logger getLogger() throws SyncFactoryException {
|
||||
// only one logger per session
|
||||
if(rsLogger == null){
|
||||
throw new SyncFactoryException("(SyncFactory) : No logger has been set");
|
||||
if (rsLogger == null) {
|
||||
throw new SyncFactoryException("(SyncFactory) : No logger has been set");
|
||||
}
|
||||
return rsLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial JNDI context from which SyncProvider implementations
|
||||
* can be retrieved from a JNDI namespace
|
||||
*
|
||||
* @param ctx a valid JNDI context
|
||||
* @throws SyncFactoryException if the supplied JNDI context is null
|
||||
*/
|
||||
/**
|
||||
* Sets the initial JNDI context from which SyncProvider implementations
|
||||
* can be retrieved from a JNDI namespace
|
||||
* <p>
|
||||
* This method checks to see that there is an {@code SQLPermission}
|
||||
* object which grants the permission {@code setSyncFactory}
|
||||
* before allowing the method to succeed. If a
|
||||
* {@code SecurityManager} exists and its
|
||||
* {@code checkPermission} method denies calling {@code setJNDIContext},
|
||||
* this method throws a
|
||||
* {@code java.lang.SecurityException}.
|
||||
*
|
||||
* @param ctx a valid JNDI context
|
||||
* @throws SyncFactoryException if the supplied JNDI context is null
|
||||
* @throws java.lang.SecurityException if a security manager exists and its
|
||||
* {@code checkPermission} method denies calling {@code setJNDIContext}
|
||||
* @see SecurityManager#checkPermission
|
||||
*/
|
||||
public static void setJNDIContext(javax.naming.Context ctx)
|
||||
throws SyncFactoryException {
|
||||
throws SyncFactoryException {
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
sec.checkPermission(SET_SYNCFACTORY_PERMISSION);
|
||||
}
|
||||
if (ctx == null) {
|
||||
throw new SyncFactoryException("Invalid JNDI context supplied");
|
||||
}
|
||||
ic = ctx;
|
||||
jndiCtxEstablished = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls JNDI context intialization.
|
||||
@ -689,7 +725,7 @@ public class SyncFactory {
|
||||
throw new SyncFactoryException("SPI: NamingException: " + e.getExplanation());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SyncFactoryException("SPI: Exception: " + e.getMessage());
|
||||
throw new SyncFactoryException("SPI: Exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -720,7 +756,7 @@ public class SyncFactory {
|
||||
* bindings have been enumerated.
|
||||
*/
|
||||
private static void enumerateBindings(NamingEnumeration bindings,
|
||||
Properties properties) throws NamingException {
|
||||
Properties properties) throws NamingException {
|
||||
|
||||
boolean syncProviderObj = false; // move to parameters ?
|
||||
|
||||
@ -729,21 +765,21 @@ public class SyncFactory {
|
||||
Object elementObj = null;
|
||||
String element = null;
|
||||
while (bindings.hasMore()) {
|
||||
bd = (Binding)bindings.next();
|
||||
bd = (Binding) bindings.next();
|
||||
element = bd.getName();
|
||||
elementObj = bd.getObject();
|
||||
|
||||
if (!(ic.lookup(element) instanceof Context)) {
|
||||
// skip directories/sub-contexts
|
||||
if (ic.lookup(element) instanceof SyncProvider) {
|
||||
// skip directories/sub-contexts
|
||||
if (ic.lookup(element) instanceof SyncProvider) {
|
||||
syncProviderObj = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (syncProviderObj) {
|
||||
SyncProvider sync = (SyncProvider)elementObj;
|
||||
SyncProvider sync = (SyncProvider) elementObj;
|
||||
properties.put(SyncFactory.ROWSET_SYNC_PROVIDER,
|
||||
sync.getProviderID());
|
||||
sync.getProviderID());
|
||||
syncProviderObj = false; // reset
|
||||
}
|
||||
|
||||
@ -756,142 +792,136 @@ public class SyncFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal class that defines the lazy reference construct for each registered
|
||||
* SyncProvider implementation.
|
||||
/**
|
||||
* Internal class that defines the lazy reference construct for each registered
|
||||
* SyncProvider implementation.
|
||||
*/
|
||||
class ProviderImpl extends SyncProvider {
|
||||
|
||||
private String className = null;
|
||||
private String vendorName = null;
|
||||
private String ver = null;
|
||||
private int index;
|
||||
|
||||
public void setClassname(String classname) {
|
||||
className = classname;
|
||||
}
|
||||
|
||||
public String getClassname() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setVendor(String vendor) {
|
||||
vendorName = vendor;
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
return vendorName;
|
||||
}
|
||||
|
||||
public void setVersion(String providerVer) {
|
||||
ver = providerVer;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return ver;
|
||||
}
|
||||
|
||||
public void setIndex(int i) {
|
||||
index = i;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public int getDataSourceLock() throws SyncProviderException {
|
||||
|
||||
int dsLock = 0;
|
||||
try {
|
||||
dsLock = SyncFactory.getInstance(className).getDataSourceLock();
|
||||
} catch (SyncFactoryException sfEx) {
|
||||
|
||||
throw new SyncProviderException(sfEx.getMessage());
|
||||
}
|
||||
|
||||
return dsLock;
|
||||
}
|
||||
|
||||
public int getProviderGrade() {
|
||||
|
||||
int grade = 0;
|
||||
|
||||
try {
|
||||
grade = SyncFactory.getInstance(className).getProviderGrade();
|
||||
} catch (SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
return grade;
|
||||
}
|
||||
|
||||
public String getProviderID() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/*
|
||||
public javax.sql.RowSetInternal getRowSetInternal() {
|
||||
try
|
||||
{
|
||||
return SyncFactory.getInstance(className).getRowSetInternal();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
}
|
||||
*/
|
||||
class ProviderImpl extends SyncProvider {
|
||||
private String className = null;
|
||||
private String vendorName = null;
|
||||
private String ver = null;
|
||||
private int index;
|
||||
public javax.sql.RowSetReader getRowSetReader() {
|
||||
|
||||
public void setClassname(String classname) {
|
||||
className = classname;
|
||||
RowSetReader rsReader = null;
|
||||
|
||||
try {
|
||||
rsReader = SyncFactory.getInstance(className).getRowSetReader();
|
||||
} catch (SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
public String getClassname() {
|
||||
return className;
|
||||
}
|
||||
return rsReader;
|
||||
|
||||
public void setVendor(String vendor) {
|
||||
vendorName = vendor;
|
||||
}
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
return vendorName;
|
||||
}
|
||||
|
||||
public void setVersion(String providerVer) {
|
||||
ver = providerVer;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return ver;
|
||||
}
|
||||
|
||||
public void setIndex(int i) {
|
||||
index = i;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public int getDataSourceLock() throws SyncProviderException {
|
||||
|
||||
int dsLock = 0;
|
||||
try
|
||||
{
|
||||
dsLock = SyncFactory.getInstance(className).getDataSourceLock();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
|
||||
throw new SyncProviderException(sfEx.getMessage());
|
||||
}
|
||||
|
||||
return dsLock;
|
||||
}
|
||||
|
||||
public int getProviderGrade() {
|
||||
|
||||
int grade = 0;
|
||||
|
||||
try
|
||||
{
|
||||
grade = SyncFactory.getInstance(className).getProviderGrade();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
return grade;
|
||||
}
|
||||
|
||||
public String getProviderID() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/*
|
||||
public javax.sql.RowSetInternal getRowSetInternal() {
|
||||
try
|
||||
{
|
||||
return SyncFactory.getInstance(className).getRowSetInternal();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public javax.sql.RowSetReader getRowSetReader() {
|
||||
|
||||
RowSetReader rsReader = null;;
|
||||
|
||||
try
|
||||
{
|
||||
rsReader = SyncFactory.getInstance(className).getRowSetReader();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
return rsReader;
|
||||
|
||||
}
|
||||
|
||||
public javax.sql.RowSetWriter getRowSetWriter() {
|
||||
public javax.sql.RowSetWriter getRowSetWriter() {
|
||||
|
||||
RowSetWriter rsWriter = null;
|
||||
try
|
||||
{
|
||||
rsWriter = SyncFactory.getInstance(className).getRowSetWriter();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
return rsWriter;
|
||||
}
|
||||
public void setDataSourceLock(int param)
|
||||
throws SyncProviderException {
|
||||
|
||||
try
|
||||
{
|
||||
SyncFactory.getInstance(className).setDataSourceLock(param);
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
|
||||
throw new SyncProviderException(sfEx.getMessage());
|
||||
}
|
||||
try {
|
||||
rsWriter = SyncFactory.getInstance(className).getRowSetWriter();
|
||||
} catch (SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
public int supportsUpdatableView() {
|
||||
return rsWriter;
|
||||
}
|
||||
|
||||
public void setDataSourceLock(int param)
|
||||
throws SyncProviderException {
|
||||
|
||||
try {
|
||||
SyncFactory.getInstance(className).setDataSourceLock(param);
|
||||
} catch (SyncFactoryException sfEx) {
|
||||
|
||||
throw new SyncProviderException(sfEx.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public int supportsUpdatableView() {
|
||||
|
||||
int view = 0;
|
||||
|
||||
try
|
||||
{
|
||||
view = SyncFactory.getInstance(className).supportsUpdatableView();
|
||||
} catch(SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
try {
|
||||
view = SyncFactory.getInstance(className).supportsUpdatableView();
|
||||
} catch (SyncFactoryException sfEx) {
|
||||
//
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -344,7 +344,7 @@ public abstract class SyncProvider {
|
||||
* source without checking the validity of any data.
|
||||
*
|
||||
*/
|
||||
public static int GRADE_NONE = 1;
|
||||
public static final int GRADE_NONE = 1;
|
||||
|
||||
/**
|
||||
* Indicates a low level optimistic synchronization grade with
|
||||
@ -354,7 +354,7 @@ public abstract class SyncProvider {
|
||||
* returning this grade will check only rows that have changed.
|
||||
*
|
||||
*/
|
||||
public static int GRADE_CHECK_MODIFIED_AT_COMMIT = 2;
|
||||
public static final int GRADE_CHECK_MODIFIED_AT_COMMIT = 2;
|
||||
|
||||
/**
|
||||
* Indicates a high level optimistic synchronization grade with
|
||||
@ -364,7 +364,7 @@ public abstract class SyncProvider {
|
||||
* returning this grade will check all rows, including rows that have not
|
||||
* changed.
|
||||
*/
|
||||
public static int GRADE_CHECK_ALL_AT_COMMIT = 3;
|
||||
public static final int GRADE_CHECK_ALL_AT_COMMIT = 3;
|
||||
|
||||
/**
|
||||
* Indicates a pessimistic synchronization grade with
|
||||
@ -374,7 +374,7 @@ public abstract class SyncProvider {
|
||||
* implementation returning this grade will lock the row in the originating
|
||||
* data source.
|
||||
*/
|
||||
public static int GRADE_LOCK_WHEN_MODIFIED = 4;
|
||||
public static final int GRADE_LOCK_WHEN_MODIFIED = 4;
|
||||
|
||||
/**
|
||||
* Indicates the most pessimistic synchronization grade with
|
||||
@ -384,47 +384,47 @@ public abstract class SyncProvider {
|
||||
* table affected by the original statement used to populate a
|
||||
* <code>RowSet</code> object.
|
||||
*/
|
||||
public static int GRADE_LOCK_WHEN_LOADED = 5;
|
||||
public static final int GRADE_LOCK_WHEN_LOADED = 5;
|
||||
|
||||
/**
|
||||
* Indicates that no locks remain on the originating data source. This is the default
|
||||
* lock setting for all <code>SyncProvider</code> implementations unless
|
||||
* otherwise directed by a <code>RowSet</code> object.
|
||||
*/
|
||||
public static int DATASOURCE_NO_LOCK = 1;
|
||||
public static final int DATASOURCE_NO_LOCK = 1;
|
||||
|
||||
/**
|
||||
* Indicates that a lock is placed on the rows that are touched by the original
|
||||
* SQL statement used to populate the <code>RowSet</code> object
|
||||
* that is using this <code>SyncProvider</code> object.
|
||||
*/
|
||||
public static int DATASOURCE_ROW_LOCK = 2;
|
||||
public static final int DATASOURCE_ROW_LOCK = 2;
|
||||
|
||||
/**
|
||||
* Indicates that a lock is placed on all tables that are touched by the original
|
||||
* SQL statement used to populate the <code>RowSet</code> object
|
||||
* that is using this <code>SyncProvider</code> object.
|
||||
*/
|
||||
public static int DATASOURCE_TABLE_LOCK = 3;
|
||||
public static final int DATASOURCE_TABLE_LOCK = 3;
|
||||
|
||||
/**
|
||||
* Indicates that a lock is placed on the entire data source that is the source of
|
||||
* data for the <code>RowSet</code> object
|
||||
* that is using this <code>SyncProvider</code> object.
|
||||
*/
|
||||
public static int DATASOURCE_DB_LOCK = 4;
|
||||
public static final int DATASOURCE_DB_LOCK = 4;
|
||||
|
||||
/**
|
||||
* Indicates that a <code>SyncProvider</code> implementation
|
||||
* supports synchronization between a <code>RowSet</code> object and
|
||||
* the SQL <code>VIEW</code> used to populate it.
|
||||
*/
|
||||
public static int UPDATABLE_VIEW_SYNC = 5;
|
||||
public static final int UPDATABLE_VIEW_SYNC = 5;
|
||||
|
||||
/**
|
||||
* Indicates that a <code>SyncProvider</code> implementation
|
||||
* does <B>not</B> support synchronization between a <code>RowSet</code>
|
||||
* object and the SQL <code>VIEW</code> used to populate it.
|
||||
*/
|
||||
public static int NONUPDATABLE_VIEW_SYNC = 6;
|
||||
public static final int NONUPDATABLE_VIEW_SYNC = 6;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user