提交 4db258b9 编写于 作者: J Juergen Hoeller

Polishing

上级 d100eef8
......@@ -47,7 +47,7 @@ public class PreparedStatementCreatorFactory {
/** The SQL, which won't change when the parameters change */
private final String sql;
/** List of SqlParameter objects. May not be {@code null}. */
/** List of SqlParameter objects (may not be {@code null}) */
private final List<SqlParameter> declaredParameters;
private int resultSetType = ResultSet.TYPE_FORWARD_ONLY;
......@@ -75,7 +75,7 @@ public class PreparedStatementCreatorFactory {
* @param sql SQL to execute
* @param types int array of JDBC types
*/
public PreparedStatementCreatorFactory(String sql, int[] types) {
public PreparedStatementCreatorFactory(String sql, int... types) {
this.sql = sql;
this.declaredParameters = SqlParameter.sqlTypesToAnonymousParameterList(types);
}
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
......@@ -177,7 +177,7 @@ public class SqlParameter {
* Convert a list of JDBC types, as defined in {@code java.sql.Types},
* to a List of SqlParameter objects as used in this package.
*/
public static List<SqlParameter> sqlTypesToAnonymousParameterList(int[] types) {
public static List<SqlParameter> sqlTypesToAnonymousParameterList(int... types) {
List<SqlParameter> result = new LinkedList<SqlParameter>();
if (types != null) {
for (int type : types) {
......
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
......@@ -53,6 +53,9 @@ public abstract class AbstractJdbcCall {
/** Lower-level class used to execute SQL */
private final JdbcTemplate jdbcTemplate;
/** Context used to retrieve and manage database metadata */
private final CallMetaDataContext callMetaDataContext = new CallMetaDataContext();
/** List of SqlParameter objects */
private final List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>();
......@@ -66,12 +69,9 @@ public abstract class AbstractJdbcCall {
*/
private boolean compiled = false;
/** the generated string used for call statement */
/** The generated string used for call statement */
private String callString;
/** context used to retrieve and manage database metadata */
private CallMetaDataContext callMetaDataContext = new CallMetaDataContext();
/**
* Object enabling us to create CallableStatementCreators
* efficiently, based on this class's declared parameters.
......@@ -103,13 +103,6 @@ public abstract class AbstractJdbcCall {
return this.jdbcTemplate;
}
/**
* Get the {@link CallableStatementCreatorFactory} being used
*/
protected CallableStatementCreatorFactory getCallableStatementFactory() {
return this.callableStatementFactory;
}
/**
* Set the name of the stored procedure.
*/
......@@ -153,7 +146,7 @@ public abstract class AbstractJdbcCall {
}
/**
* Set the schema name to use,
* Set the schema name to use.
*/
public void setSchemaName(String schemaName) {
this.callMetaDataContext.setSchemaName(schemaName);
......@@ -183,8 +176,8 @@ public abstract class AbstractJdbcCall {
/**
* Specify whether the call requires a rerurn value.
*/
public void setReturnValueRequired(boolean b) {
this.callMetaDataContext.setReturnValueRequired(b);
public void setReturnValueRequired(boolean returnValueRequired) {
this.callMetaDataContext.setReturnValueRequired(returnValueRequired);
}
/**
......@@ -194,6 +187,28 @@ public abstract class AbstractJdbcCall {
return this.callMetaDataContext.isReturnValueRequired();
}
/**
* Specify whether the parameter metadata for the call should be used. The default is true.
*/
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) {
this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData);
}
/**
* Get the call string that should be used based on parameters and meta data.
*/
public String getCallString() {
return this.callString;
}
/**
* Get the {@link CallableStatementCreatorFactory} being used
*/
protected CallableStatementCreatorFactory getCallableStatementFactory() {
return this.callableStatementFactory;
}
/**
* Add a declared parameter to the list of parameters for the call.
* Only parameters declared as {@code SqlParameter} and {@code SqlInOutParameter}
......@@ -226,20 +241,6 @@ public abstract class AbstractJdbcCall {
}
}
/**
* Get the call string that should be used based on parameters and meta data.
*/
public String getCallString() {
return this.callString;
}
/**
* Specify whether the parameter metadata for the call should be used. The default is true.
*/
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) {
this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData);
}
//-------------------------------------------------------------------------
// Methods handling compilation issues
......@@ -366,18 +367,21 @@ public abstract class AbstractJdbcCall {
/**
* Method to perform the actual call processing
*/
private Map<String, Object> executeCallInternal(Map<String, ?> params) {
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(params);
private Map<String, Object> executeCallInternal(Map<String, ?> args) {
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(args);
if (logger.isDebugEnabled()) {
logger.debug("The following parameters are used for call " + getCallString() + " with: " + params);
logger.debug("The following parameters are used for call " + getCallString() + " with " + args);
int i = 1;
for (SqlParameter p : getCallParameters()) {
logger.debug(i++ + ": " + p.getName() + " SQL Type "+ p.getSqlType() + " Type Name " + p.getTypeName() + " " + p.getClass().getName());
for (SqlParameter param : getCallParameters()) {
logger.debug(i + ": " + param.getName() + ", SQL type "+ param.getSqlType() + ", type name " +
param.getTypeName() + ", parameter class [" + param.getClass().getName() + "]");
i++;
}
}
return getJdbcTemplate().call(csc, getCallParameters());
}
/**
* Get the name of a single out parameter or return value.
* Used for functions or procedures with one out parameter.
......@@ -386,6 +390,14 @@ public abstract class AbstractJdbcCall {
return this.callMetaDataContext.getScalarOutParameterName();
}
/**
* Get a List of all the call parameters to be used for call. This includes any parameters added
* based on meta data processing.
*/
protected List<SqlParameter> getCallParameters() {
return this.callMetaDataContext.getCallParameters();
}
/**
* Match the provided in parameter values with registered parameters and
* parameters defined via metadata processing.
......@@ -416,12 +428,4 @@ public abstract class AbstractJdbcCall {
return this.callMetaDataContext.matchInParameterValuesWithCallParameters(args);
}
/**
* Get a List of all the call parameters to be used for call. This includes any parameters added
* based on meta data processing.
*/
protected List<SqlParameter> getCallParameters() {
return this.callMetaDataContext.getCallParameters();
}
}
......@@ -73,6 +73,9 @@ public abstract class AbstractJdbcInsert {
/** List of columns objects to be used in insert statement */
private final List<String> declaredColumns = new ArrayList<String>();
/** The names of the columns holding the generated key */
private String[] generatedKeyNames = new String[0];
/**
* Has this operation been compiled? Compilation means at least checking
* that a DataSource or JdbcTemplate has been provided, but subclasses
......@@ -86,9 +89,6 @@ public abstract class AbstractJdbcInsert {
/** The SQL type information for the insert columns */
private int[] insertTypes;
/** The names of the columns holding the generated key */
private String[] generatedKeyNames = new String[0];
/**
* Constructor for sublasses to delegate to for setting the DataSource.
......@@ -119,7 +119,7 @@ public abstract class AbstractJdbcInsert {
}
/**
* Set the name of the table for this insert
* Set the name of the table for this insert.
*/
public void setTableName(String tableName) {
checkIfConfigurationModificationIsAllowed();
......@@ -127,14 +127,14 @@ public abstract class AbstractJdbcInsert {
}
/**
* Get the name of the table for this insert
* Get the name of the table for this insert.
*/
public String getTableName() {
return this.tableMetaDataContext.getTableName();
}
/**
* Set the name of the schema for this insert
* Set the name of the schema for this insert.
*/
public void setSchemaName(String schemaName) {
checkIfConfigurationModificationIsAllowed();
......@@ -142,14 +142,14 @@ public abstract class AbstractJdbcInsert {
}
/**
* Get the name of the schema for this insert
* Get the name of the schema for this insert.
*/
public String getSchemaName() {
return this.tableMetaDataContext.getSchemaName();
}
/**
* Set the name of the catalog for this insert
* Set the name of the catalog for this insert.
*/
public void setCatalogName(String catalogName) {
checkIfConfigurationModificationIsAllowed();
......@@ -157,14 +157,14 @@ public abstract class AbstractJdbcInsert {
}
/**
* Get the name of the catalog for this insert
* Get the name of the catalog for this insert.
*/
public String getCatalogName() {
return this.tableMetaDataContext.getCatalogName();
}
/**
* Set the names of the columns to be used
* Set the names of the columns to be used.
*/
public void setColumnNames(List<String> columnNames) {
checkIfConfigurationModificationIsAllowed();
......@@ -173,14 +173,14 @@ public abstract class AbstractJdbcInsert {
}
/**
* Get the names of the columns used
* Get the names of the columns used.
*/
public List<String> getColumnNames() {
return Collections.unmodifiableList(this.declaredColumns);
}
/**
* Specify the name of a single generated key column
* Specify the name of a single generated key column.
*/
public void setGeneratedKeyName(String generatedKeyName) {
checkIfConfigurationModificationIsAllowed();
......@@ -188,7 +188,7 @@ public abstract class AbstractJdbcInsert {
}
/**
* Set the names of any generated keys
* Set the names of any generated keys.
*/
public void setGeneratedKeyNames(String... generatedKeyNames) {
checkIfConfigurationModificationIsAllowed();
......@@ -196,21 +196,23 @@ public abstract class AbstractJdbcInsert {
}
/**
* Get the names of any generated keys
* Get the names of any generated keys.
*/
public String[] getGeneratedKeyNames() {
return this.generatedKeyNames;
}
/**
* Specify whether the parameter metadata for the call should be used. The default is true.
* Specify whether the parameter metadata for the call should be used.
* The default is {@code true}.
*/
public void setAccessTableColumnMetaData(boolean accessTableColumnMetaData) {
this.tableMetaDataContext.setAccessTableColumnMetaData(accessTableColumnMetaData);
}
/**
* Specify whether the default for including synonyms should be changed. The default is false.
* Specify whether the default for including synonyms should be changed.
* The default is {@code false}.
*/
public void setOverrideIncludeSynonymsDefault(boolean override) {
this.tableMetaDataContext.setOverrideIncludeSynonymsDefault(override);
......@@ -224,14 +226,14 @@ public abstract class AbstractJdbcInsert {
}
/**
* Get the insert string to be used
* Get the insert string to be used.
*/
public String getInsertString() {
return this.insertString;
}
/**
* Get the array of {@link java.sql.Types} to be used for insert
* Get the array of {@link java.sql.Types} to be used for insert.
*/
public int[] getInsertTypes() {
return this.insertTypes;
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
......@@ -17,7 +17,6 @@
package org.springframework.web.servlet.view.xslt;
import java.util.Properties;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.URIResolver;
......@@ -49,10 +48,15 @@ public class XsltViewResolver extends UrlBasedViewResolver {
public XsltViewResolver() {
setViewClass(XsltView.class);
setViewClass(requiredViewClass());
}
@Override
protected Class<?> requiredViewClass() {
return XsltView.class;
}
/**
* Set the name of the model attribute that represents the XSLT Source.
* If not specified, the model map will be searched for a matching value type.
......@@ -117,11 +121,6 @@ public class XsltViewResolver extends UrlBasedViewResolver {
}
@Override
protected Class<?> requiredViewClass() {
return XsltView.class;
}
@Override
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
XsltView view = (XsltView) super.buildView(viewName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册