Fix remaining compiler warnings

Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
This commit is contained in:
Phillip Webb
2013-11-21 18:15:09 -08:00
parent 4de3291dc7
commit 59002f2456
540 changed files with 1943 additions and 1843 deletions

View File

@@ -59,7 +59,7 @@ public class ArgumentTypePreparedStatementSetter implements PreparedStatementSet
for (int i = 0; i < this.args.length; i++) {
Object arg = this.args[i];
if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
Collection entries = (Collection) arg;
Collection<?> entries = (Collection<?>) arg;
for (Object entry : entries) {
if (entry instanceof Object[]) {
Object[] valueArray = ((Object[]) entry);

View File

@@ -371,7 +371,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
protected Connection createConnectionProxy(Connection con) {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new Class<?>[] {ConnectionProxy.class},
new CloseSuppressingInvocationHandler(con));
}

View File

@@ -194,13 +194,13 @@ public class PreparedStatementCreatorFactory {
private final String actualSql;
private final List parameters;
private final List<?> parameters;
public PreparedStatementCreatorImpl(List<?> parameters) {
this(sql, parameters);
}
public PreparedStatementCreatorImpl(String actualSql, List parameters) {
public PreparedStatementCreatorImpl(String actualSql, List<?> parameters) {
this.actualSql = actualSql;
Assert.notNull(parameters, "Parameters List must not be null");
this.parameters = parameters;
@@ -283,7 +283,7 @@ public class PreparedStatementCreatorFactory {
declaredParameter = declaredParameters.get(i);
}
if (in instanceof Collection && declaredParameter.getSqlType() != Types.ARRAY) {
Collection entries = (Collection) in;
Collection<?> entries = (Collection<?>) in;
for (Object entry : entries) {
if (entry instanceof Object[]) {
Object[] valueArray = ((Object[])entry);

View File

@@ -25,11 +25,11 @@ package org.springframework.jdbc.core;
*/
public class ResultSetSupportingSqlParameter extends SqlParameter {
private ResultSetExtractor resultSetExtractor;
private ResultSetExtractor<?> resultSetExtractor;
private RowCallbackHandler rowCallbackHandler;
private RowMapper rowMapper;
private RowMapper<?> rowMapper;
/**
@@ -68,7 +68,7 @@ public class ResultSetSupportingSqlParameter extends SqlParameter {
* @param sqlType SQL type of the parameter according to java.sql.Types
* @param rse ResultSetExtractor to use for parsing the ResultSet
*/
public ResultSetSupportingSqlParameter(String name, int sqlType, ResultSetExtractor rse) {
public ResultSetSupportingSqlParameter(String name, int sqlType, ResultSetExtractor<?> rse) {
super(name, sqlType);
this.resultSetExtractor = rse;
}
@@ -90,7 +90,7 @@ public class ResultSetSupportingSqlParameter extends SqlParameter {
* @param sqlType SQL type of the parameter according to java.sql.Types
* @param rm RowMapper to use for parsing the ResultSet
*/
public ResultSetSupportingSqlParameter(String name, int sqlType, RowMapper rm) {
public ResultSetSupportingSqlParameter(String name, int sqlType, RowMapper<?> rm) {
super(name, sqlType);
this.rowMapper = rm;
}
@@ -107,7 +107,7 @@ public class ResultSetSupportingSqlParameter extends SqlParameter {
/**
* Return the ResultSetExtractor held by this parameter, if any.
*/
public ResultSetExtractor getResultSetExtractor() {
public ResultSetExtractor<?> getResultSetExtractor() {
return this.resultSetExtractor;
}
@@ -121,7 +121,7 @@ public class ResultSetSupportingSqlParameter extends SqlParameter {
/**
* Return the RowMapper held by this parameter, if any.
*/
public RowMapper getRowMapper() {
public RowMapper<?> getRowMapper() {
return this.rowMapper;
}

View File

@@ -121,7 +121,7 @@ public class SingleColumnRowMapper<T> implements RowMapper<T> {
* @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
* @see #getColumnValue(java.sql.ResultSet, int)
*/
protected Object getColumnValue(ResultSet rs, int index, Class requiredType) throws SQLException {
protected Object getColumnValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
if (requiredType != null) {
return JdbcUtils.getResultSetValue(rs, index, requiredType);
}
@@ -164,18 +164,18 @@ public class SingleColumnRowMapper<T> implements RowMapper<T> {
* @see #getColumnValue(java.sql.ResultSet, int, Class)
*/
@SuppressWarnings("unchecked")
protected Object convertValueToRequiredType(Object value, Class requiredType) {
protected Object convertValueToRequiredType(Object value, Class<?> requiredType) {
if (String.class.equals(requiredType)) {
return value.toString();
}
else if (Number.class.isAssignableFrom(requiredType)) {
if (value instanceof Number) {
// Convert original Number to target Number class.
return NumberUtils.convertNumberToTargetClass(((Number) value), requiredType);
return NumberUtils.convertNumberToTargetClass(((Number) value), (Class<Number>) requiredType);
}
else {
// Convert stringified value to target Number class.
return NumberUtils.parseNumber(value.toString(), requiredType);
return NumberUtils.parseNumber(value.toString(),(Class<Number>) requiredType);
}
}
else {

View File

@@ -77,7 +77,7 @@ public class SqlInOutParameter extends SqlOutParameter {
* @param sqlType SQL type of the parameter according to java.sql.Types
* @param rse ResultSetExtractor to use for parsing the ResultSet
*/
public SqlInOutParameter(String name, int sqlType, ResultSetExtractor rse) {
public SqlInOutParameter(String name, int sqlType, ResultSetExtractor<?> rse) {
super(name, sqlType, rse);
}
@@ -97,7 +97,7 @@ public class SqlInOutParameter extends SqlOutParameter {
* @param sqlType SQL type of the parameter according to java.sql.Types
* @param rm RowMapper to use for parsing the ResultSet
*/
public SqlInOutParameter(String name, int sqlType, RowMapper rm) {
public SqlInOutParameter(String name, int sqlType, RowMapper<?> rm) {
super(name, sqlType, rm);
}

View File

@@ -83,7 +83,7 @@ public class SqlOutParameter extends ResultSetSupportingSqlParameter {
* @param sqlType SQL type of the parameter according to java.sql.Types
* @param rse ResultSetExtractor to use for parsing the ResultSet
*/
public SqlOutParameter(String name, int sqlType, ResultSetExtractor rse) {
public SqlOutParameter(String name, int sqlType, ResultSetExtractor<?> rse) {
super(name, sqlType, rse);
}
@@ -103,7 +103,7 @@ public class SqlOutParameter extends ResultSetSupportingSqlParameter {
* @param sqlType SQL type of the parameter according to java.sql.Types
* @param rm RowMapper to use for parsing the ResultSet
*/
public SqlOutParameter(String name, int sqlType, RowMapper rm) {
public SqlOutParameter(String name, int sqlType, RowMapper<?> rm) {
super(name, sqlType, rm);
}

View File

@@ -35,7 +35,7 @@ public class SqlReturnResultSet extends ResultSetSupportingSqlParameter {
* @param name name of the parameter, as used in input and output maps
* @param extractor ResultSetExtractor to use for parsing the {@link java.sql.ResultSet}
*/
public SqlReturnResultSet(String name, ResultSetExtractor extractor) {
public SqlReturnResultSet(String name, ResultSetExtractor<?> extractor) {
super(name, 0, extractor);
}
@@ -53,7 +53,7 @@ public class SqlReturnResultSet extends ResultSetSupportingSqlParameter {
* @param name name of the parameter, as used in input and output maps
* @param mapper RowMapper to use for parsing the {@link java.sql.ResultSet}
*/
public SqlReturnResultSet(String name, RowMapper mapper) {
public SqlReturnResultSet(String name, RowMapper<?> mapper) {
super(name, 0, mapper);
}

View File

@@ -18,6 +18,7 @@ package org.springframework.jdbc.core;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
@@ -133,9 +134,27 @@ public class SqlRowSetResultSetExtractor implements ResultSetExtractor<SqlRowSet
*/
private static class SunCachedRowSetFactory implements CachedRowSetFactory {
private static final Class<?> IMPLEMENTATION_CLASS;
static {
try {
IMPLEMENTATION_CLASS = Class.forName("com.sun.rowset.CachedRowSetImpl");
}
catch (ClassNotFoundException ex) {
throw new IllegalStateException(ex);
}
}
@Override
public CachedRowSet createCachedRowSet() throws SQLException {
return new com.sun.rowset.CachedRowSetImpl();
try {
return (CachedRowSet) IMPLEMENTATION_CLASS.newInstance();
}
catch (InstantiationException ex) {
throw new IllegalStateException(ex);
}
catch (IllegalAccessException ex) {
throw new IllegalStateException(ex);
}
}
}

View File

@@ -60,7 +60,7 @@ public abstract class StatementCreatorUtils {
private static final Log logger = LogFactory.getLog(StatementCreatorUtils.class);
private static Map<Class, Integer> javaTypeToSqlTypeMap = new HashMap<Class, Integer>(32);
private static Map<Class<?>, Integer> javaTypeToSqlTypeMap = new HashMap<Class<?>, Integer>(32);
static {
/* JDBC 3.0 only - not compatible with e.g. MySQL at present
@@ -94,7 +94,7 @@ public abstract class StatementCreatorUtils {
* @param javaType the Java type to translate
* @return the corresponding SQL type, or {@code null} if none found
*/
public static int javaTypeToSqlParameterType(Class javaType) {
public static int javaTypeToSqlParameterType(Class<?> javaType) {
Integer sqlType = javaTypeToSqlTypeMap.get(javaType);
if (sqlType != null) {
return sqlType;
@@ -362,7 +362,7 @@ public abstract class StatementCreatorUtils {
/**
* Check whether the given value can be treated as a String value.
*/
private static boolean isStringValue(Class inValueType) {
private static boolean isStringValue(Class<?> inValueType) {
// Consider any CharSequence (including StringBuffer and StringBuilder) as a String.
return (CharSequence.class.isAssignableFrom(inValueType) ||
StringWriter.class.isAssignableFrom(inValueType));
@@ -372,7 +372,7 @@ public abstract class StatementCreatorUtils {
* Check whether the given value is a {@code java.util.Date}
* (but not one of the JDBC-specific subclasses).
*/
private static boolean isDateValue(Class inValueType) {
private static boolean isDateValue(Class<?> inValueType) {
return (java.util.Date.class.isAssignableFrom(inValueType) &&
!(java.sql.Date.class.isAssignableFrom(inValueType) ||
java.sql.Time.class.isAssignableFrom(inValueType) ||
@@ -399,7 +399,7 @@ public abstract class StatementCreatorUtils {
* @see DisposableSqlTypeValue#cleanup()
* @see org.springframework.jdbc.core.support.SqlLobValue#cleanup()
*/
public static void cleanupParameters(Collection paramValues) {
public static void cleanupParameters(Collection<?> paramValues) {
if (paramValues != null) {
for (Object inValue : paramValues) {
if (inValue instanceof DisposableSqlTypeValue) {

View File

@@ -224,7 +224,7 @@ public class CallMetaDataContext {
* @param rowMapper a RowMapper implementation used to map the data returned in the result set
* @return the appropriate SqlParameter
*/
public SqlParameter createReturnResultSetParameter(String parameterName, RowMapper rowMapper) {
public SqlParameter createReturnResultSetParameter(String parameterName, RowMapper<?> rowMapper) {
if (this.metaDataProvider.isReturnResultSetSupported()) {
return new SqlReturnResultSet(parameterName, rowMapper);
}
@@ -434,7 +434,7 @@ public class CallMetaDataContext {
public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource) {
// For parameter source lookups we need to provide case-insensitive lookup support
// since the database metadata is not necessarily providing case sensitive parameter names.
Map caseInsensitiveParameterNames =
Map<String, String> caseInsensitiveParameterNames =
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
Map<String, String> callParameterNames = new HashMap<String, String>(this.callParameters.size());
@@ -467,7 +467,7 @@ public class CallMetaDataContext {
}
else {
if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
String sourceName = (String) caseInsensitiveParameterNames.get(lowerCaseName);
String sourceName = caseInsensitiveParameterNames.get(lowerCaseName);
matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
}
else {

View File

@@ -107,7 +107,7 @@ public class OracleTableMetaDataProvider extends GenericTableMetaDataProvider {
ReflectionUtils.makeAccessible(getIncludeSynonyms);
originalValueForIncludeSynonyms = (Boolean) getIncludeSynonyms.invoke(con);
setIncludeSynonyms = con.getClass().getMethod("setIncludeSynonyms", new Class[] {boolean.class});
setIncludeSynonyms = con.getClass().getMethod("setIncludeSynonyms", new Class<?>[] {boolean.class});
ReflectionUtils.makeAccessible(setIncludeSynonyms);
setIncludeSynonyms.invoke(con, Boolean.TRUE);
}

View File

@@ -239,7 +239,7 @@ public class TableMetaDataContext {
List<Object> values = new ArrayList<Object>();
// for parameter source lookups we need to provide caseinsensitive lookup support since the
// database metadata is not necessarily providing case sensitive column names
Map caseInsensitiveParameterNames =
Map<String, String> caseInsensitiveParameterNames =
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
for (String column : this.tableColumns) {
if (parameterSource.hasValue(column)) {
@@ -259,7 +259,7 @@ public class TableMetaDataContext {
if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
values.add(
SqlParameterSourceUtils.getTypedValue(parameterSource,
(String) caseInsensitiveParameterNames.get(lowerCaseName)));
caseInsensitiveParameterNames.get(lowerCaseName)));
}
else {
values.add(null);

View File

@@ -99,7 +99,7 @@ public class BeanPropertySqlParameterSource extends AbstractSqlParameterSource {
if (sqlType != TYPE_UNKNOWN) {
return sqlType;
}
Class propType = this.beanWrapper.getPropertyType(paramName);
Class<?> propType = this.beanWrapper.getPropertyType(paramName);
return StatementCreatorUtils.javaTypeToSqlParameterType(propType);
}

View File

@@ -252,10 +252,10 @@ public abstract class NamedParameterUtils {
public static String substituteNamedParameters(ParsedSql parsedSql, SqlParameterSource paramSource) {
String originalSql = parsedSql.getOriginalSql();
StringBuilder actualSql = new StringBuilder();
List paramNames = parsedSql.getParameterNames();
List<String> paramNames = parsedSql.getParameterNames();
int lastIndex = 0;
for (int i = 0; i < paramNames.size(); i++) {
String paramName = (String) paramNames.get(i);
String paramName = paramNames.get(i);
int[] indexes = parsedSql.getParameterIndexes(i);
int startIndex = indexes[0];
int endIndex = indexes[1];
@@ -266,7 +266,7 @@ public abstract class NamedParameterUtils {
value = ((SqlParameterValue) value).getValue();
}
if (value instanceof Collection) {
Iterator entryIter = ((Collection) value).iterator();
Iterator<?> entryIter = ((Collection<?>) value).iterator();
int k = 0;
while (entryIter.hasNext()) {
if (k > 0) {

View File

@@ -35,10 +35,10 @@ public class SqlParameterSourceUtils {
* @param valueMaps array of Maps containing the values to be used
* @return an array of SqlParameterSource
*/
public static SqlParameterSource[] createBatch(Map[] valueMaps) {
public static SqlParameterSource[] createBatch(Map<String, ?>[] valueMaps) {
MapSqlParameterSource[] batch = new MapSqlParameterSource[valueMaps.length];
for (int i = 0; i < valueMaps.length; i++) {
Map valueMap = valueMaps[i];
Map<String, ?> valueMap = valueMaps[i];
batch[i] = new MapSqlParameterSource(valueMap);
}
return batch;
@@ -80,13 +80,13 @@ public class SqlParameterSourceUtils {
}
}
/**
* Create a Map of case insensitive parameter names together with the original name.
* @param parameterSource the source of paramer names
* @return the Map that can be used for case insensitive matching of parameter names
*/
public static Map extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource) {
Map caseInsensitiveParameterNames = new HashMap();
/**
* Create a Map of case insensitive parameter names together with the original name.
* @param parameterSource the source of paramer names
* @return the Map that can be used for case insensitive matching of parameter names
*/
public static Map<String, String> extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource) {
Map<String, String> caseInsensitiveParameterNames = new HashMap<String, String>();
if (parameterSource instanceof BeanPropertySqlParameterSource) {
String[] propertyNames = ((BeanPropertySqlParameterSource)parameterSource).getReadablePropertyNames();
for (int i = 0; i < propertyNames.length; i++) {

View File

@@ -57,7 +57,7 @@ public abstract class AbstractJdbcCall {
private final List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>();
/** List of RefCursor/ResultSet RowMapper objects */
private final Map<String, RowMapper> declaredRowMappers = new LinkedHashMap<String, RowMapper>();
private final Map<String, RowMapper<?>> declaredRowMappers = new LinkedHashMap<String, RowMapper<?>>();
/**
* Has this operation been compiled? Compilation means at
@@ -219,7 +219,7 @@ public abstract class AbstractJdbcCall {
* @param parameterName name of parameter or column
* @param rowMapper the RowMapper implementation to use
*/
public void addDeclaredRowMapper(String parameterName, RowMapper rowMapper) {
public void addDeclaredRowMapper(String parameterName, RowMapper<?> rowMapper) {
this.declaredRowMappers.put(parameterName, rowMapper);
if (logger.isDebugEnabled()) {
logger.debug("Added row mapper for [" + getProcedureName() + "]: " + parameterName);
@@ -279,7 +279,7 @@ public abstract class AbstractJdbcCall {
this.callMetaDataContext.initializeMetaData(getJdbcTemplate().getDataSource());
// iterate over the declared RowMappers and register the corresponding SqlParameter
for (Map.Entry<String, RowMapper> entry : this.declaredRowMappers.entrySet()) {
for (Map.Entry<String, RowMapper<?>> entry : this.declaredRowMappers.entrySet()) {
SqlParameter resultSetParameter =
this.callMetaDataContext.createReturnResultSetParameter(entry.getKey(), entry.getValue());
this.declaredParameters.add(resultSetParameter);

View File

@@ -544,10 +544,10 @@ public abstract class AbstractJdbcInsert {
* @param batch array of Maps with parameter names and values to be used in batch insert
* @return array of number of rows affected
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
protected int[] doExecuteBatch(Map<String, Object>[] batch) {
checkCompiled();
List<Object>[] batchValues = new ArrayList[batch.length];
List[] batchValues = new ArrayList[batch.length];
int i = 0;
for (Map<String, Object> args : batch) {
List<Object> values = matchInParameterValuesWithInsertColumns(args);
@@ -561,10 +561,10 @@ public abstract class AbstractJdbcInsert {
* @param batch array of SqlParameterSource with parameter names and values to be used in insert
* @return array of number of rows affected
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
protected int[] doExecuteBatch(SqlParameterSource[] batch) {
checkCompiled();
List<Object>[] batchValues = new ArrayList[batch.length];
List[] batchValues = new ArrayList[batch.length];
int i = 0;
for (SqlParameterSource parameterSource : batch) {
List<Object> values = matchInParameterValuesWithInsertColumns(parameterSource);

View File

@@ -128,7 +128,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
}
@Override
public SimpleJdbcCall returningResultSet(String parameterName, RowMapper rowMapper) {
public SimpleJdbcCall returningResultSet(String parameterName, RowMapper<?> rowMapper) {
addDeclaredRowMapper(parameterName, rowMapper);
return this;
}

View File

@@ -92,7 +92,7 @@ public interface SimpleJdbcCallOperations {
* @param parameterName the name of the returned results and/or the name of the ref cursor parameter
* @param rowMapper the RowMapper implementation that will map the data returned for each row
* */
SimpleJdbcCallOperations returningResultSet(String parameterName, RowMapper rowMapper);
SimpleJdbcCallOperations returningResultSet(String parameterName, RowMapper<?> rowMapper);
/**
* Turn off any processing of parameter meta data information obtained via JDBC.

View File

@@ -53,7 +53,7 @@ import org.springframework.jdbc.core.ResultSetExtractor;
* @see org.springframework.jdbc.support.lob.LobHandler
* @see org.springframework.jdbc.LobRetrievalFailureException
*/
public abstract class AbstractLobStreamingResultSetExtractor implements ResultSetExtractor {
public abstract class AbstractLobStreamingResultSetExtractor<T> implements ResultSetExtractor<T> {
/**
* Delegates to handleNoRowFound, handleMultipleRowsFound and streamData,
@@ -65,7 +65,7 @@ public abstract class AbstractLobStreamingResultSetExtractor implements ResultSe
* @see org.springframework.jdbc.LobRetrievalFailureException
*/
@Override
public final Object extractData(ResultSet rs) throws SQLException, DataAccessException {
public final T extractData(ResultSet rs) throws SQLException, DataAccessException {
if (!rs.next()) {
handleNoRowFound();
}

View File

@@ -219,7 +219,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
public Connection getConnection() throws SQLException {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new Class<?>[] {ConnectionProxy.class},
new LazyConnectionInvocationHandler());
}
@@ -237,7 +237,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
public Connection getConnection(String username, String password) throws SQLException {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new Class<?>[] {ConnectionProxy.class},
new LazyConnectionInvocationHandler(username, password));
}
@@ -289,12 +289,12 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
return System.identityHashCode(proxy);
}
else if (method.getName().equals("unwrap")) {
if (((Class) args[0]).isInstance(proxy)) {
if (((Class<?>) args[0]).isInstance(proxy)) {
return proxy;
}
}
else if (method.getName().equals("isWrapperFor")) {
if (((Class) args[0]).isInstance(proxy)) {
if (((Class<?>) args[0]).isInstance(proxy)) {
return true;
}
}

View File

@@ -278,7 +278,7 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
protected Connection getCloseSuppressingConnectionProxy(Connection target) {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new Class<?>[] {ConnectionProxy.class},
new CloseSuppressingInvocationHandler(target));
}
@@ -307,12 +307,12 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
return System.identityHashCode(proxy);
}
else if (method.getName().equals("unwrap")) {
if (((Class) args[0]).isInstance(proxy)) {
if (((Class<?>) args[0]).isInstance(proxy)) {
return proxy;
}
}
else if (method.getName().equals("isWrapperFor")) {
if (((Class) args[0]).isInstance(proxy)) {
if (((Class<?>) args[0]).isInstance(proxy)) {
return true;
}
}

View File

@@ -138,7 +138,7 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
protected Connection getTransactionAwareConnectionProxy(DataSource targetDataSource) {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new Class<?>[] {ConnectionProxy.class},
new TransactionAwareInvocationHandler(targetDataSource));
}
@@ -198,12 +198,12 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
return sb.toString();
}
else if (method.getName().equals("unwrap")) {
if (((Class) args[0]).isInstance(proxy)) {
if (((Class<?>) args[0]).isInstance(proxy)) {
return proxy;
}
}
else if (method.getName().equals("isWrapperFor")) {
if (((Class) args[0]).isInstance(proxy)) {
if (((Class<?>) args[0]).isInstance(proxy)) {
return true;
}
}

View File

@@ -69,7 +69,7 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
protected final Log logger = LogFactory.getLog(getClass());
private Class wsDataSourceClass;
private Class<?> wsDataSourceClass;
private Method newJdbcConnSpecMethod;
@@ -91,16 +91,16 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
public WebSphereDataSourceAdapter() {
try {
this.wsDataSourceClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.WSDataSource");
Class jdbcConnSpecClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.JDBCConnectionSpec");
Class wsrraFactoryClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.WSRRAFactory");
this.newJdbcConnSpecMethod = wsrraFactoryClass.getMethod("createJDBCConnectionSpec", (Class[]) null);
Class<?> jdbcConnSpecClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.JDBCConnectionSpec");
Class<?> wsrraFactoryClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.WSRRAFactory");
this.newJdbcConnSpecMethod = wsrraFactoryClass.getMethod("createJDBCConnectionSpec", (Class<?>[]) null);
this.wsDataSourceGetConnectionMethod =
this.wsDataSourceClass.getMethod("getConnection", new Class[] {jdbcConnSpecClass});
this.wsDataSourceClass.getMethod("getConnection", new Class<?>[] {jdbcConnSpecClass});
this.setTransactionIsolationMethod =
jdbcConnSpecClass.getMethod("setTransactionIsolation", new Class[] {int.class});
this.setReadOnlyMethod = jdbcConnSpecClass.getMethod("setReadOnly", new Class[] {Boolean.class});
this.setUserNameMethod = jdbcConnSpecClass.getMethod("setUserName", new Class[] {String.class});
this.setPasswordMethod = jdbcConnSpecClass.getMethod("setPassword", new Class[] {String.class});
jdbcConnSpecClass.getMethod("setTransactionIsolation", new Class<?>[] {int.class});
this.setReadOnlyMethod = jdbcConnSpecClass.getMethod("setReadOnly", new Class<?>[] {Boolean.class});
this.setUserNameMethod = jdbcConnSpecClass.getMethod("setUserName", new Class<?>[] {String.class});
this.setPasswordMethod = jdbcConnSpecClass.getMethod("setPassword", new Class<?>[] {String.class});
}
catch (Exception ex) {
throw new IllegalStateException(

View File

@@ -113,7 +113,7 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple
throw new IllegalArgumentException("Property 'targetDataSources' is required");
}
this.resolvedDataSources = new HashMap<Object, DataSource>(this.targetDataSources.size());
for (Map.Entry entry : this.targetDataSources.entrySet()) {
for (Map.Entry<Object, Object> entry : this.targetDataSources.entrySet()) {
Object lookupKey = resolveSpecifiedLookupKey(entry.getKey());
DataSource dataSource = resolveSpecifiedDataSource(entry.getValue());
this.resolvedDataSources.put(lookupKey, dataSource);

View File

@@ -22,13 +22,14 @@ import org.springframework.jdbc.core.RowMapper;
import org.springframework.util.Assert;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
public class GenericSqlQuery extends SqlQuery {
public class GenericSqlQuery<T> extends SqlQuery<T> {
Class rowMapperClass;
Class<?> rowMapperClass;
RowMapper rowMapper;
RowMapper<?> rowMapper;
public void setRowMapperClass(Class rowMapperClass)
@SuppressWarnings("rawtypes")
public void setRowMapperClass(Class<? extends RowMapper> rowMapperClass)
throws IllegalAccessException, InstantiationException {
this.rowMapperClass = rowMapperClass;
if (!RowMapper.class.isAssignableFrom(rowMapperClass))
@@ -44,9 +45,10 @@ public class GenericSqlQuery extends SqlQuery {
}
@Override
protected RowMapper newRowMapper(Object[] parameters, Map context) {
@SuppressWarnings("unchecked")
protected RowMapper<T> newRowMapper(Object[] parameters, Map<?, ?> context) {
try {
return (RowMapper) rowMapperClass.newInstance();
return (RowMapper<T>) rowMapperClass.newInstance();
}
catch (InstantiationException e) {
throw new InvalidDataAccessResourceUsageException("Unable to instantiate RowMapper", e);

View File

@@ -59,7 +59,7 @@ public abstract class MappingSqlQuery<T> extends MappingSqlQueryWithParameters<T
* @see #mapRow(ResultSet, int)
*/
@Override
protected final T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context)
protected final T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map<?, ?> context)
throws SQLException {
return mapRow(rs, rowNum);

View File

@@ -70,7 +70,7 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
* implementation of the mapRow() method.
*/
@Override
protected RowMapper<T> newRowMapper(Object[] parameters, Map context) {
protected RowMapper<T> newRowMapper(Object[] parameters, Map<?, ?> context) {
return new RowMapperImpl(parameters, context);
}
@@ -89,7 +89,7 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
* Subclasses can simply not catch SQLExceptions, relying on the
* framework to clean up.
*/
protected abstract T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context)
protected abstract T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map<?, ?> context)
throws SQLException;
@@ -101,12 +101,12 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
private final Object[] params;
private final Map context;
private final Map<?, ?> context;
/**
* Use an array results. More efficient if we know how many results to expect.
*/
public RowMapperImpl(Object[] parameters, Map context) {
public RowMapperImpl(Object[] parameters, Map<?, ?> context) {
this.params = parameters;
this.context = context;
}

View File

@@ -401,7 +401,7 @@ public abstract class RdbmsOperation implements InitializingBean {
*/
protected void validateNamedParameters(Map<String, ?> parameters) throws InvalidDataAccessApiUsageException {
checkCompiled();
Map paramsToUse = (parameters != null ? parameters : Collections.emptyMap());
Map<String, ?> paramsToUse = (parameters != null ? parameters : Collections.<String, Object> emptyMap());
int declaredInParameters = 0;
for (SqlParameter param : this.declaredParameters) {
if (param.isInputValueProvided()) {

View File

@@ -106,7 +106,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public List<T> execute(Object[] params, Map context) throws DataAccessException {
public List<T> execute(Object[] params, Map<?, ?> context) throws DataAccessException {
validateParameters(params);
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(params), rowMapper);
@@ -126,7 +126,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to execute without parameters.
* @param context the contextual information for object creation
*/
public List<T> execute(Map context) throws DataAccessException {
public List<T> execute(Map<?, ?> context) throws DataAccessException {
return execute((Object[]) null, context);
}
@@ -142,7 +142,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p1 single int parameter
* @param context the contextual information for object creation
*/
public List<T> execute(int p1, Map context) throws DataAccessException {
public List<T> execute(int p1, Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@@ -160,7 +160,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p2 second int parameter
* @param context the contextual information for object creation
*/
public List<T> execute(int p1, int p2, Map context) throws DataAccessException {
public List<T> execute(int p1, int p2, Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1, p2}, context);
}
@@ -178,7 +178,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p1 single long parameter
* @param context the contextual information for object creation
*/
public List<T> execute(long p1, Map context) throws DataAccessException {
public List<T> execute(long p1, Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@@ -195,7 +195,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p1 single String parameter
* @param context the contextual information for object creation
*/
public List<T> execute(String p1, Map context) throws DataAccessException {
public List<T> execute(String p1, Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@@ -219,7 +219,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public List<T> executeByNamedParam(Map<String, ?> paramMap, Map context) throws DataAccessException {
public List<T> executeByNamedParam(Map<String, ?> paramMap, Map<?, ?> context) throws DataAccessException {
validateNamedParameters(paramMap);
ParsedSql parsedSql = getParsedSql();
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
@@ -248,7 +248,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* choose to treat this as an error and throw an exception.
* @see org.springframework.dao.support.DataAccessUtils#singleResult
*/
public T findObject(Object[] params, Map context) throws DataAccessException {
public T findObject(Object[] params, Map<?, ?> context) throws DataAccessException {
List<T> results = execute(params, context);
return DataAccessUtils.singleResult(results);
}
@@ -264,7 +264,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given a single int parameter
* and a context.
*/
public T findObject(int p1, Map context) throws DataAccessException {
public T findObject(int p1, Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
@@ -279,7 +279,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given two int parameters
* and a context.
*/
public T findObject(int p1, int p2, Map context) throws DataAccessException {
public T findObject(int p1, int p2, Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1, p2}, context);
}
@@ -294,7 +294,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given a single long parameter
* and a context.
*/
public T findObject(long p1, Map context) throws DataAccessException {
public T findObject(long p1, Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
@@ -309,7 +309,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given a single String parameter
* and a context.
*/
public T findObject(String p1, Map context) throws DataAccessException {
public T findObject(String p1, Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
@@ -331,7 +331,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public T findObjectByNamedParam(Map<String, ?> paramMap, Map context) throws DataAccessException {
public T findObjectByNamedParam(Map<String, ?> paramMap, Map<?, ?> context) throws DataAccessException {
List<T> results = executeByNamedParam(paramMap, context);
return DataAccessUtils.singleResult(results);
}
@@ -358,6 +358,6 @@ public abstract class SqlQuery<T> extends SqlOperation {
* but it can be useful for creating the objects of the result list.
* @see #execute
*/
protected abstract RowMapper<T> newRowMapper(Object[] parameters, Map context);
protected abstract RowMapper<T> newRowMapper(Object[] parameters, Map<?, ?> context);
}

View File

@@ -60,7 +60,7 @@ public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> {
* implementation of the {@code updateRow()} method.
*/
@Override
protected RowMapper<T> newRowMapper(Object[] parameters, Map context) {
protected RowMapper<T> newRowMapper(Object[] parameters, Map<?, ?> context) {
return new RowMapperImpl(context);
}
@@ -79,7 +79,7 @@ public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> {
* Subclasses can simply not catch SQLExceptions, relying on the
* framework to clean up.
*/
protected abstract T updateRow(ResultSet rs, int rowNum, Map context) throws SQLException;
protected abstract T updateRow(ResultSet rs, int rowNum, Map<?, ?> context) throws SQLException;
/**
@@ -88,9 +88,9 @@ public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> {
*/
protected class RowMapperImpl implements RowMapper<T> {
private final Map context;
private final Map<?, ?> context;
public RowMapperImpl(Map context) {
public RowMapperImpl(Map<?, ?> context) {
this.context = context;
}

View File

@@ -32,7 +32,7 @@ public class CustomSQLErrorCodesTranslation {
private String[] errorCodes = new String[0];
private Class exceptionClass;
private Class<?> exceptionClass;
/**
@@ -52,7 +52,7 @@ public class CustomSQLErrorCodesTranslation {
/**
* Set the exception class for the specified error codes.
*/
public void setExceptionClass(Class exceptionClass) {
public void setExceptionClass(Class<?> exceptionClass) {
if (!DataAccessException.class.isAssignableFrom(exceptionClass)) {
throw new IllegalArgumentException("Invalid exception class [" + exceptionClass +
"]: needs to be a subclass of [org.springframework.dao.DataAccessException]");
@@ -63,7 +63,7 @@ public class CustomSQLErrorCodesTranslation {
/**
* Return the exception class for the specified error codes.
*/
public Class getExceptionClass() {
public Class<?> getExceptionClass() {
return this.exceptionClass;
}

View File

@@ -129,7 +129,7 @@ public abstract class JdbcUtils {
* @return the value object
* @throws SQLException if thrown by the JDBC API
*/
public static Object getResultSetValue(ResultSet rs, int index, Class requiredType) throws SQLException {
public static Object getResultSetValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
if (requiredType == null) {
return getResultSetValue(rs, index);
}

View File

@@ -313,14 +313,14 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
* @see CustomSQLErrorCodesTranslation#setExceptionClass
*/
protected DataAccessException createCustomException(
String task, String sql, SQLException sqlEx, Class exceptionClass) {
String task, String sql, SQLException sqlEx, Class<?> exceptionClass) {
// find appropriate constructor
try {
int constructorType = 0;
Constructor[] constructors = exceptionClass.getConstructors();
for (Constructor constructor : constructors) {
Class[] parameterTypes = constructor.getParameterTypes();
Constructor<?>[] constructors = exceptionClass.getConstructors();
for (Constructor<?> constructor : constructors) {
Class<?>[] parameterTypes = constructor.getParameterTypes();
if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) {
if (constructorType < MESSAGE_ONLY_CONSTRUCTOR)
constructorType = MESSAGE_ONLY_CONSTRUCTOR;
@@ -348,30 +348,30 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
}
// invoke constructor
Constructor exceptionConstructor;
Constructor<?> exceptionConstructor;
switch (constructorType) {
case MESSAGE_SQL_SQLEX_CONSTRUCTOR:
Class[] messageAndSqlAndSqlExArgsClass = new Class[] {String.class, String.class, SQLException.class};
Class<?>[] messageAndSqlAndSqlExArgsClass = new Class<?>[] {String.class, String.class, SQLException.class};
Object[] messageAndSqlAndSqlExArgs = new Object[] {task, sql, sqlEx};
exceptionConstructor = exceptionClass.getConstructor(messageAndSqlAndSqlExArgsClass);
return (DataAccessException) exceptionConstructor.newInstance(messageAndSqlAndSqlExArgs);
case MESSAGE_SQL_THROWABLE_CONSTRUCTOR:
Class[] messageAndSqlAndThrowableArgsClass = new Class[] {String.class, String.class, Throwable.class};
Class<?>[] messageAndSqlAndThrowableArgsClass = new Class<?>[] {String.class, String.class, Throwable.class};
Object[] messageAndSqlAndThrowableArgs = new Object[] {task, sql, sqlEx};
exceptionConstructor = exceptionClass.getConstructor(messageAndSqlAndThrowableArgsClass);
return (DataAccessException) exceptionConstructor.newInstance(messageAndSqlAndThrowableArgs);
case MESSAGE_SQLEX_CONSTRUCTOR:
Class[] messageAndSqlExArgsClass = new Class[] {String.class, SQLException.class};
Class<?>[] messageAndSqlExArgsClass = new Class<?>[] {String.class, SQLException.class};
Object[] messageAndSqlExArgs = new Object[] {task + ": " + sqlEx.getMessage(), sqlEx};
exceptionConstructor = exceptionClass.getConstructor(messageAndSqlExArgsClass);
return (DataAccessException) exceptionConstructor.newInstance(messageAndSqlExArgs);
case MESSAGE_THROWABLE_CONSTRUCTOR:
Class[] messageAndThrowableArgsClass = new Class[] {String.class, Throwable.class};
Class<?>[] messageAndThrowableArgsClass = new Class<?>[] {String.class, Throwable.class};
Object[] messageAndThrowableArgs = new Object[] {task + ": " + sqlEx.getMessage(), sqlEx};
exceptionConstructor = exceptionClass.getConstructor(messageAndThrowableArgsClass);
return (DataAccessException)exceptionConstructor.newInstance(messageAndThrowableArgs);
case MESSAGE_ONLY_CONSTRUCTOR:
Class[] messageOnlyArgsClass = new Class[] {String.class};
Class<?>[] messageOnlyArgsClass = new Class<?>[] {String.class};
Object[] messageOnlyArgs = new Object[] {task + ": " + sqlEx.getMessage()};
exceptionConstructor = exceptionClass.getConstructor(messageOnlyArgsClass);
return (DataAccessException) exceptionConstructor.newInstance(messageOnlyArgs);

View File

@@ -200,6 +200,7 @@ public class DefaultLobHandler extends AbstractLobHandler {
}
@Override
@SuppressWarnings("resource")
public LobCreator getLobCreator() {
return (this.createTemporaryLob ? new TemporaryLobCreator() : new DefaultLobCreator());
}

View File

@@ -111,15 +111,15 @@ public class OracleLobHandler extends AbstractLobHandler {
private Boolean releaseResourcesAfterRead = Boolean.FALSE;
private Class blobClass;
private Class<?> blobClass;
private Class clobClass;
private Class<?> clobClass;
private final Map<Class, Integer> durationSessionConstants = new HashMap<Class, Integer>(2);
private final Map<Class<?>, Integer> durationSessionConstants = new HashMap<Class<?>, Integer>(2);
private final Map<Class, Integer> modeReadWriteConstants = new HashMap<Class, Integer>(2);
private final Map<Class<?>, Integer> modeReadWriteConstants = new HashMap<Class<?>, Integer>(2);
private final Map<Class, Integer> modeReadOnlyConstants = new HashMap<Class, Integer>(2);
private final Map<Class<?>, Integer> modeReadOnlyConstants = new HashMap<Class<?>, Integer>(2);
/**
@@ -569,7 +569,7 @@ public class OracleLobHandler extends AbstractLobHandler {
/**
* Create and open an oracle.sql.BLOB/CLOB instance via reflection.
*/
protected Object prepareLob(Connection con, Class lobClass) throws Exception {
protected Object prepareLob(Connection con, Class<?> lobClass) throws Exception {
/*
BLOB blob = BLOB.createTemporary(con, false, BLOB.DURATION_SESSION);
blob.open(BLOB.MODE_READWRITE);
@@ -589,7 +589,7 @@ public class OracleLobHandler extends AbstractLobHandler {
@Override
public void close() {
try {
for (Iterator it = this.temporaryLobs.iterator(); it.hasNext();) {
for (Iterator<?> it = this.temporaryLobs.iterator(); it.hasNext();) {
/*
BLOB blob = (BLOB) it.next();
blob.freeTemporary();

View File

@@ -63,7 +63,7 @@ public class C3P0NativeJdbcExtractor extends NativeJdbcExtractorAdapter {
public C3P0NativeJdbcExtractor() {
try {
this.getRawConnectionMethod = getClass().getMethod("getRawConnection", new Class[] {Connection.class});
this.getRawConnectionMethod = getClass().getMethod("getRawConnection", new Class<?>[] {Connection.class});
}
catch (NoSuchMethodException ex) {
throw new IllegalStateException("Internal error in C3P0NativeJdbcExtractor: " + ex.getMessage());

View File

@@ -63,7 +63,7 @@ public class CommonsDbcpNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
return null;
}
try {
Class classToAnalyze = obj.getClass();
Class<?> classToAnalyze = obj.getClass();
while (!Modifier.isPublic(classToAnalyze.getModifiers())) {
classToAnalyze = classToAnalyze.getSuperclass();
if (classToAnalyze == null) {

View File

@@ -55,11 +55,11 @@ public class JBossNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
private static final String JBOSS_RESOURCE_PREFIX = "org.jboss.resource.adapter.jdbc.";
private Class wrappedConnectionClass;
private Class<?> wrappedConnectionClass;
private Class wrappedStatementClass;
private Class<?> wrappedStatementClass;
private Class wrappedResultSetClass;
private Class<?> wrappedResultSetClass;
private Method getUnderlyingConnectionMethod;

View File

@@ -46,7 +46,7 @@ public class WebLogicNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
private static final String JDBC_EXTENSION_NAME = "weblogic.jdbc.extensions.WLConnection";
private final Class jdbcExtensionClass;
private final Class<?> jdbcExtensionClass;
private final Method getVendorConnectionMethod;

View File

@@ -45,7 +45,7 @@ public class WebSphereNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
private static final String JDBC_ADAPTER_UTIL_NAME = "com.ibm.ws.rsadapter.jdbc.WSJdbcUtil";
private Class webSphereConnectionClass;
private Class<?> webSphereConnectionClass;
private Method webSphereNativeConnectionMethod;
@@ -57,9 +57,9 @@ public class WebSphereNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
public WebSphereNativeJdbcExtractor() {
try {
this.webSphereConnectionClass = getClass().getClassLoader().loadClass(JDBC_ADAPTER_CONNECTION_NAME);
Class jdbcAdapterUtilClass = getClass().getClassLoader().loadClass(JDBC_ADAPTER_UTIL_NAME);
Class<?> jdbcAdapterUtilClass = getClass().getClassLoader().loadClass(JDBC_ADAPTER_UTIL_NAME);
this.webSphereNativeConnectionMethod =
jdbcAdapterUtilClass.getMethod("getNativeConnection", new Class[] {this.webSphereConnectionClass});
jdbcAdapterUtilClass.getMethod("getNativeConnection", new Class<?>[] {this.webSphereConnectionClass});
}
catch (Exception ex) {
throw new IllegalStateException(

View File

@@ -23,13 +23,14 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLXML;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
import org.springframework.dao.DataAccessResourceFailureException;
import org.w3c.dom.Document;
/**
* Default implementation of the {@link SqlXmlHandler} interface.
@@ -81,14 +82,12 @@ public class Jdbc4SqlXmlHandler implements SqlXmlHandler {
}
@Override
@SuppressWarnings("unchecked")
public Source getXmlAsSource(ResultSet rs, String columnName, Class sourceClass) throws SQLException {
public Source getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass) throws SQLException {
return rs.getSQLXML(columnName).getSource(sourceClass != null ? sourceClass : DOMSource.class);
}
@Override
@SuppressWarnings("unchecked")
public Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException {
public Source getXmlAsSource(ResultSet rs, int columnIndex, Class<? extends Source> sourceClass) throws SQLException {
return rs.getSQLXML(columnIndex).getSource(sourceClass != null ? sourceClass : DOMSource.class);
}
@@ -128,10 +127,9 @@ public class Jdbc4SqlXmlHandler implements SqlXmlHandler {
}
@Override
public SqlXmlValue newSqlXmlValue(final Class resultClass, final XmlResultProvider provider) {
public SqlXmlValue newSqlXmlValue(final Class<? extends Result> resultClass, final XmlResultProvider provider) {
return new AbstractJdbc4SqlXmlValue() {
@Override
@SuppressWarnings("unchecked")
protected void provideXml(SQLXML xmlObject) throws SQLException, IOException {
provider.provideXml(xmlObject.setResult(resultClass));
}

View File

@@ -21,6 +21,7 @@ import java.io.Reader;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.w3c.dom.Document;
@@ -146,7 +147,7 @@ public interface SqlXmlHandler {
* @see java.sql.ResultSet#getSQLXML
* @see java.sql.SQLXML#getSource
*/
Source getXmlAsSource(ResultSet rs, String columnName, Class sourceClass) throws SQLException;
Source getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass) throws SQLException;
/**
* Retrieve the given column as Source implemented using the specified source class
@@ -161,7 +162,7 @@ public interface SqlXmlHandler {
* @see java.sql.ResultSet#getSQLXML
* @see java.sql.SQLXML#getSource
*/
Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException;
Source getXmlAsSource(ResultSet rs, int columnIndex, Class<? extends Source> sourceClass) throws SQLException;
//-------------------------------------------------------------------------
@@ -207,7 +208,7 @@ public interface SqlXmlHandler {
* @see SqlXmlValue
* @see java.sql.SQLXML#setResult(Class)
*/
SqlXmlValue newSqlXmlValue(Class resultClass, XmlResultProvider provider);
SqlXmlValue newSqlXmlValue(Class<? extends Result> resultClass, XmlResultProvider provider);
/**
* Create a {@code SqlXmlValue} instance for the given XML data,