Skip to content

Commit

Permalink
Merge branch '3.2.x'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
philwebb committed Apr 13, 2013
2 parents cf687fc + 39d043d commit 761bd9f
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -302,16 +302,16 @@ private class LifecycleGroup {

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ public MethodExecutor resolve(EvaluationContext context, Object targetObject, St
}

// 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++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,12 +20,12 @@
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;

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,17 +20,17 @@
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;

Expand All @@ -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");
Expand All @@ -59,12 +59,10 @@ public void setValues(PreparedStatement ps) throws SQLException {
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++;
}
Expand Down Expand Up @@ -94,6 +92,7 @@ public void setValues(PreparedStatement ps) throws SQLException {
*/
protected void doSetValue(PreparedStatement ps, int parameterPosition, int argType, Object argValue)
throws SQLException {

StatementCreatorUtils.setParameterValue(ps, parameterPosition, argType, argValue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1291,24 +1291,26 @@ protected void applyStatementSettings(Statement stmt) throws SQLException {
}

/**
* 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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;
Expand Down Expand Up @@ -229,18 +228,13 @@ private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, S
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();
Expand All @@ -255,9 +249,9 @@ else if (databaseProductName.startsWith("DB2") ||
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMa
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);
Expand All @@ -734,12 +734,16 @@ else if (this.mappedClass != null) {
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");
Expand Down
11 changes: 10 additions & 1 deletion src/dist/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/reference/docbook/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
</authorgroup>

<copyright>
<year>2004-2012</year>
<year>2004-2013</year>
</copyright>

<legalnotice>
Expand Down

0 comments on commit 761bd9f

Please sign in to comment.