Merge branch '3.2.x'
* 3.2.x: Update javadoc external links JdbcTemplate etc Removed unnecessary default value of LifecycleGroup.lifecycleBeans Introduced public ArgumentPreparedStatementSetter and ArgumentTypePreparedStatementSetter classes Defensively uses JDBC 3.0 getParameterType call for Oracle driver compatibility Preparations for 3.2.3 Fixed ReflectiveMethodResolver to avoid potential UnsupportedOperationException on sort Fixed Jaxb2Marshaller's partial unmarshalling feature to consistently apply to all sources Update copyright year in reference documentation Conflicts: build.gradle gradle.properties spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentPreparedStatementSetter.java spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentTypePreparedStatementSetter.java
This commit is contained in:
commit
761bd9fd56
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -302,16 +302,16 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
|||
|
||||
private final List<LifecycleGroupMember> members = new ArrayList<LifecycleGroupMember>();
|
||||
|
||||
private Map<String, ? extends Lifecycle> lifecycleBeans = getLifecycleBeans();
|
||||
|
||||
private volatile int smartMemberCount;
|
||||
|
||||
private final int phase;
|
||||
|
||||
private final long timeout;
|
||||
|
||||
private final Map<String, ? extends Lifecycle> lifecycleBeans;
|
||||
|
||||
private final boolean autoStartupOnly;
|
||||
|
||||
private volatile int smartMemberCount;
|
||||
|
||||
public LifecycleGroup(int phase, long timeout, Map<String, ? extends Lifecycle> lifecycleBeans, boolean autoStartupOnly) {
|
||||
this.phase = phase;
|
||||
this.timeout = timeout;
|
||||
|
|
|
@ -103,13 +103,15 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
|||
}
|
||||
|
||||
// Sort methods into a sensible order
|
||||
Collections.sort(methods, new Comparator<Method>() {
|
||||
public int compare(Method m1, Method m2) {
|
||||
int m1pl = m1.getParameterTypes().length;
|
||||
int m2pl = m2.getParameterTypes().length;
|
||||
return (new Integer(m1pl)).compareTo(m2pl);
|
||||
}
|
||||
});
|
||||
if (methods.size() > 1) {
|
||||
Collections.sort(methods, new Comparator<Method>() {
|
||||
public int compare(Method m1, Method m2) {
|
||||
int m1pl = m1.getParameterTypes().length;
|
||||
int m2pl = m2.getParameterTypes().length;
|
||||
return (new Integer(m1pl)).compareTo(m2pl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Resolve any bridge methods
|
||||
for (int i = 0; i < methods.size(); i++) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,12 +20,12 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Simple adapter for PreparedStatementSetter that applies
|
||||
* a given array of arguments.
|
||||
* Simple adapter for {@link PreparedStatementSetter} that applies a given array of arguments.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.2.3
|
||||
*/
|
||||
class ArgPreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
|
||||
public class ArgumentPreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
|
||||
|
||||
private final Object[] args;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ArgPreparedStatementSetter implements PreparedStatementSetter, ParameterDi
|
|||
* Create a new ArgPreparedStatementSetter for the given arguments.
|
||||
* @param args the arguments to set
|
||||
*/
|
||||
public ArgPreparedStatementSetter(Object[] args) {
|
||||
public ArgumentPreparedStatementSetter(Object[] args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,17 +20,17 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
/**
|
||||
* Simple adapter for PreparedStatementSetter that applies
|
||||
* Simple adapter for {@link PreparedStatementSetter} that applies
|
||||
* given arrays of arguments and JDBC argument types.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.2.3
|
||||
*/
|
||||
class ArgTypePreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
|
||||
public class ArgumentTypePreparedStatementSetter implements PreparedStatementSetter, ParameterDisposer {
|
||||
|
||||
private final Object[] args;
|
||||
|
||||
|
@ -42,7 +42,7 @@ class ArgTypePreparedStatementSetter implements PreparedStatementSetter, Paramet
|
|||
* @param args the arguments to set
|
||||
* @param argTypes the corresponding SQL types of the arguments
|
||||
*/
|
||||
public ArgTypePreparedStatementSetter(Object[] args, int[] argTypes) {
|
||||
public ArgumentTypePreparedStatementSetter(Object[] args, int[] argTypes) {
|
||||
if ((args != null && argTypes == null) || (args == null && argTypes != null) ||
|
||||
(args != null && args.length != argTypes.length)) {
|
||||
throw new InvalidDataAccessApiUsageException("args and argTypes parameters must match");
|
||||
|
@ -59,12 +59,10 @@ class ArgTypePreparedStatementSetter implements PreparedStatementSetter, Paramet
|
|||
Object arg = this.args[i];
|
||||
if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
|
||||
Collection entries = (Collection) arg;
|
||||
for (Iterator it = entries.iterator(); it.hasNext();) {
|
||||
Object entry = it.next();
|
||||
for (Object entry : entries) {
|
||||
if (entry instanceof Object[]) {
|
||||
Object[] valueArray = ((Object[])entry);
|
||||
for (int k = 0; k < valueArray.length; k++) {
|
||||
Object argValue = valueArray[k];
|
||||
Object[] valueArray = ((Object[]) entry);
|
||||
for (Object argValue : valueArray) {
|
||||
doSetValue(ps, parameterPosition, this.argTypes[i], argValue);
|
||||
parameterPosition++;
|
||||
}
|
||||
|
@ -94,6 +92,7 @@ class ArgTypePreparedStatementSetter implements PreparedStatementSetter, Paramet
|
|||
*/
|
||||
protected void doSetValue(PreparedStatement ps, int parameterPosition, int argType, Object argValue)
|
||||
throws SQLException {
|
||||
|
||||
StatementCreatorUtils.setParameterValue(ps, parameterPosition, argType, argValue);
|
||||
}
|
||||
|
|
@ -1291,24 +1291,26 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new ArgPreparedStatementSetter using the args passed in. This method allows the
|
||||
* creation to be overridden by sub-classes.
|
||||
* Create a new arg-based PreparedStatementSetter using the args passed in.
|
||||
* <p>By default, we'll create an {@link ArgumentPreparedStatementSetter}.
|
||||
* This method allows for the creation to be overridden by subclasses.
|
||||
* @param args object array with arguments
|
||||
* @return the new PreparedStatementSetter
|
||||
* @return the new PreparedStatementSetter to use
|
||||
*/
|
||||
protected PreparedStatementSetter newArgPreparedStatementSetter(Object[] args) {
|
||||
return new ArgPreparedStatementSetter(args);
|
||||
return new ArgumentPreparedStatementSetter(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ArgTypePreparedStatementSetter using the args and argTypes passed in.
|
||||
* This method allows the creation to be overridden by sub-classes.
|
||||
* Create a new arg-type-based PreparedStatementSetter using the args and types passed in.
|
||||
* <p>By default, we'll create an {@link ArgumentTypePreparedStatementSetter}.
|
||||
* This method allows for the creation to be overridden by subclasses.
|
||||
* @param args object array with arguments
|
||||
* @param argTypes int array of SQLTypes for arguments
|
||||
* @return the new PreparedStatementSetter
|
||||
* @param argTypes int array of SQLTypes for the associated arguments
|
||||
* @return the new PreparedStatementSetter to use
|
||||
*/
|
||||
protected PreparedStatementSetter newArgTypePreparedStatementSetter(Object[] args, int[] argTypes) {
|
||||
return new ArgTypePreparedStatementSetter(args, argTypes);
|
||||
return new ArgumentTypePreparedStatementSetter(args, argTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.math.BigInteger;
|
|||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ParameterMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
@ -229,18 +228,13 @@ public abstract class StatementCreatorUtils {
|
|||
boolean useSetObject = false;
|
||||
sqlType = Types.NULL;
|
||||
try {
|
||||
ParameterMetaData pmd = null;
|
||||
sqlType = ps.getParameterMetaData().getParameterType(paramIndex);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.debug("JDBC 3.0 getParameterType call not supported", ex);
|
||||
// JDBC driver not compliant with JDBC 3.0
|
||||
// -> proceed with database-specific checks
|
||||
try {
|
||||
pmd = ps.getParameterMetaData();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// JDBC driver not compliant with JDBC 3.0
|
||||
// -> proceed with database-specific checks
|
||||
}
|
||||
if (pmd != null) {
|
||||
sqlType = pmd.getParameterType(paramIndex);
|
||||
}
|
||||
else {
|
||||
DatabaseMetaData dbmd = ps.getConnection().getMetaData();
|
||||
String databaseProductName = dbmd.getDatabaseProductName();
|
||||
String jdbcDriverName = dbmd.getDriverName();
|
||||
|
@ -255,9 +249,9 @@ public abstract class StatementCreatorUtils {
|
|||
sqlType = Types.VARCHAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.debug("Could not check database or driver name", ex);
|
||||
catch (Throwable ex2) {
|
||||
logger.debug("Could not check database or driver name", ex2);
|
||||
}
|
||||
}
|
||||
if (useSetObject) {
|
||||
ps.setObject(paramIndex, null);
|
||||
|
|
|
@ -720,7 +720,7 @@ public class Jaxb2Marshaller
|
|||
return unmarshalStaxSource(unmarshaller, source);
|
||||
}
|
||||
else if (this.mappedClass != null) {
|
||||
return unmarshaller.unmarshal(source, this.mappedClass);
|
||||
return unmarshaller.unmarshal(source, this.mappedClass).getValue();
|
||||
}
|
||||
else {
|
||||
return unmarshaller.unmarshal(source);
|
||||
|
@ -734,12 +734,16 @@ public class Jaxb2Marshaller
|
|||
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
|
||||
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
|
||||
if (streamReader != null) {
|
||||
return jaxbUnmarshaller.unmarshal(streamReader);
|
||||
return (this.mappedClass != null ?
|
||||
jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
|
||||
jaxbUnmarshaller.unmarshal(streamReader));
|
||||
}
|
||||
else {
|
||||
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
|
||||
if (eventReader != null) {
|
||||
return jaxbUnmarshaller.unmarshal(eventReader);
|
||||
return (this.mappedClass != null ?
|
||||
jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
|
||||
jaxbUnmarshaller.unmarshal(eventReader));
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
|
||||
|
|
|
@ -3,8 +3,17 @@ SPRING FRAMEWORK CHANGELOG
|
|||
http://www.springsource.org
|
||||
|
||||
|
||||
Changes in version 3.2.3 (2013-05-02)
|
||||
-------------------------------------
|
||||
|
||||
* fixed ReflectiveMethodResolver to avoid potential UnsupportedOperationException on sort (SPR-10392)
|
||||
* fixed Jaxb2Marshaller's partial unmarshalling feature to consistently apply to all sources (SPR-10282)
|
||||
* JdbcTemplate defensively uses JDBC 3.0 getParameterType call for Oracle driver compatibility (SPR-10385)
|
||||
* introduced public ArgumentPreparedStatementSetter and ArgumentTypePreparedStatementSetter classes (SPR-10375)
|
||||
|
||||
|
||||
Changes in version 3.2.2 (2013-03-14)
|
||||
--------------------------------------
|
||||
-------------------------------------
|
||||
|
||||
* official support for Hibernate 4.2 (SPR-10255)
|
||||
* fixed missing inter-dependencies in module POMs (SPR-10218)
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
</authorgroup>
|
||||
|
||||
<copyright>
|
||||
<year>2004-2012</year>
|
||||
<year>2004-2013</year>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
|
|
Loading…
Reference in New Issue