Browse Source

Polishing

pull/803/head
Juergen Hoeller 11 years ago
parent
commit
ce4e795f09
  1. 5
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
  2. 6
      spring-context/src/main/java/org/springframework/cache/Cache.java
  3. 14
      spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java
  4. 5
      spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java
  5. 23
      spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
  6. 14
      spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java
  7. 9
      spring-core/src/main/java/org/springframework/util/ReflectionUtils.java
  8. 2
      spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java
  9. 19
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java
  10. 28
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java
  11. 21
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
  12. 5
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java
  13. 33
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java
  14. 12
      spring-web/src/main/java/org/springframework/http/StreamingHttpOutputMessage.java
  15. 4
      spring-web/src/main/java/org/springframework/web/multipart/MaxUploadSizeExceededException.java
  16. 24
      spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java
  17. 12
      spring-webmvc/src/main/java/org/springframework/web/servlet/NoHandlerFoundException.java

5
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -203,8 +203,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
pointcutParameters[i] = parser.createPointcutParameter( pointcutParameters[i] = parser.createPointcutParameter(
this.pointcutParameterNames[i], this.pointcutParameterTypes[i]); this.pointcutParameterNames[i], this.pointcutParameterTypes[i]);
} }
return parser.parsePointcutExpression( return parser.parsePointcutExpression(replaceBooleanOperators(getExpression()),
replaceBooleanOperators(getExpression()),
this.pointcutDeclarationScope, pointcutParameters); this.pointcutDeclarationScope, pointcutParameters);
} }

6
spring-context/src/main/java/org/springframework/cache/Cache.java vendored

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.springframework.cache; package org.springframework.cache;
/** /**
* Interface that defines the common cache operations. * Interface that defines common cache operations.
* *
* <b>Note:</b> Due to the generic use of caching, it is recommended that * <b>Note:</b> Due to the generic use of caching, it is recommended that
* implementations allow storage of <tt>null</tt> values (for example to * implementations allow storage of <tt>null</tt> values (for example to
@ -68,8 +68,8 @@ public interface Cache {
* the cache contains no mapping for this key * the cache contains no mapping for this key
* @throws IllegalStateException if a cache entry has been found * @throws IllegalStateException if a cache entry has been found
* but failed to match the specified type * but failed to match the specified type
* @see #get(Object)
* @since 4.0 * @since 4.0
* @see #get(Object)
*/ */
<T> T get(Object key, Class<T> type); <T> T get(Object key, Class<T> type);

14
spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java vendored

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -162,13 +162,12 @@ public @interface EnableCaching {
* Indicate whether subclass-based (CGLIB) proxies are to be created as opposed * Indicate whether subclass-based (CGLIB) proxies are to be created as opposed
* to standard Java interface-based proxies. The default is {@code false}. <strong> * to standard Java interface-based proxies. The default is {@code false}. <strong>
* Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>. * Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>.
*
* <p>Note that setting this attribute to {@code true} will affect <em>all</em> * <p>Note that setting this attribute to {@code true} will affect <em>all</em>
* Spring-managed beans requiring proxying, not just those marked with * Spring-managed beans requiring proxying, not just those marked with {@code @Cacheable}.
* {@code @Cacheable}. For example, other beans marked with Spring's * For example, other beans marked with Spring's {@code @Transactional} annotation will
* {@code @Transactional} annotation will be upgraded to subclass proxying at the same * be upgraded to subclass proxying at the same time. This approach has no negative
* time. This approach has no negative impact in practice unless one is explicitly * impact in practice unless one is explicitly expecting one type of proxy vs another,
* expecting one type of proxy vs another, e.g. in tests. * e.g. in tests.
*/ */
boolean proxyTargetClass() default false; boolean proxyTargetClass() default false;
@ -185,4 +184,5 @@ public @interface EnableCaching {
* The default is {@link Ordered#LOWEST_PRECEDENCE}. * The default is {@link Ordered#LOWEST_PRECEDENCE}.
*/ */
int order() default Ordered.LOWEST_PRECEDENCE; int order() default Ordered.LOWEST_PRECEDENCE;
} }

5
spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import groovy.lang.MetaClass;
import groovy.lang.Script; import groovy.lang.Script;
import org.codehaus.groovy.control.CompilationFailedException; import org.codehaus.groovy.control.CompilationFailedException;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
@ -102,7 +101,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableListableBeanFactory) { if (beanFactory instanceof ConfigurableListableBeanFactory) {
((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class); ((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
} }

23
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -94,7 +94,7 @@ import org.springframework.util.StringUtils;
* &lt;property name="message" value="Hello World!"/&gt; * &lt;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt; * &lt;/bean&gt;
* *
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"&gt; * &lt;bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"&gt;
* &lt;constructor-arg value="classpath:mypackage/Messenger.groovy"/&gt; * &lt;constructor-arg value="classpath:mypackage/Messenger.groovy"/&gt;
* &lt;property name="message" value="Hello World!"/&gt; * &lt;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt;</pre> * &lt;/bean&gt;</pre>
@ -346,17 +346,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
* @param scriptedObjectBeanName the name of the internal scripted object bean * @param scriptedObjectBeanName the name of the internal scripted object bean
*/ */
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) { protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a prototype. // Avoid recreation of the script bean definition in case of a prototype.
synchronized (this.scriptBeanFactory) { synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) { if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName, this.scriptBeanFactory.registerBeanDefinition(
createScriptFactoryBeanDefinition(bd)); scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory = this.scriptBeanFactory ScriptFactory scriptFactory =
.getBean(scriptFactoryBeanName, ScriptFactory.class); this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, ScriptSource scriptSource =
scriptFactory.getScriptSourceLocator()); getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces(); Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces; Class<?>[] scriptedInterfaces = interfaces;
@ -365,8 +364,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface); scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
} }
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource, BeanDefinition objectBd = createScriptedObjectBeanDefinition(
scriptedInterfaces); bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd); long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) { if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE); objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
@ -569,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
proxyFactory.setInterfaces(interfaces); proxyFactory.setInterfaces(interfaces);
if (proxyTargetClass) { if (proxyTargetClass) {
classLoader = null; // force use of Class.getClassLoader() classLoader = null; // force use of Class.getClassLoader()
proxyFactory.setProxyTargetClass(proxyTargetClass); proxyFactory.setProxyTargetClass(true);
} }
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts); DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);

14
spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -667,27 +667,27 @@ public class InjectAnnotationAutowireContextTests {
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Qualifier @Qualifier
public static @interface TestQualifier { public @interface TestQualifier {
} }
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Qualifier @Qualifier
public static @interface TestQualifierWithDefaultValue { public @interface TestQualifierWithDefaultValue {
public abstract String value() default "default"; String value() default "default";
} }
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Qualifier @Qualifier
public static @interface TestQualifierWithMultipleAttributes { public @interface TestQualifierWithMultipleAttributes {
public abstract String value() default "default"; String value() default "default";
public abstract int number(); int number();
} }
} }

9
spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

@ -84,7 +84,8 @@ public abstract class ReflectionUtils {
while (!Object.class.equals(searchType) && searchType != null) { while (!Object.class.equals(searchType) && searchType != null) {
Field[] fields = searchType.getDeclaredFields(); Field[] fields = searchType.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
if ((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) { if ((name == null || name.equals(field.getName())) &&
(type == null || type.equals(field.getType()))) {
return field; return field;
} }
} }
@ -410,8 +411,7 @@ public abstract class ReflectionUtils {
i--; i--;
} }
return ((i > CGLIB_RENAMED_METHOD_PREFIX.length()) && return ((i > CGLIB_RENAMED_METHOD_PREFIX.length()) &&
(i < name.length() - 1) && (i < name.length() - 1) && name.charAt(i) == '$');
(name.charAt(i) == '$'));
} }
return false; return false;
} }
@ -425,7 +425,8 @@ public abstract class ReflectionUtils {
* @see java.lang.reflect.Field#setAccessible * @see java.lang.reflect.Field#setAccessible
*/ */
public static void makeAccessible(Field field) { public static void makeAccessible(Field field) {
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || if ((!Modifier.isPublic(field.getModifiers()) ||
!Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) { Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
field.setAccessible(true); field.setAccessible(true);
} }

2
spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

19
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,16 +31,14 @@ import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.MetaDataAccessException; import org.springframework.jdbc.support.MetaDataAccessException;
/** /**
* Factory used to create a {@link CallMetaDataProvider} implementation based on the type of databse being used. * Factory used to create a {@link CallMetaDataProvider} implementation
* based on the type of databse being used.
* *
* @author Thomas Risberg * @author Thomas Risberg
* @since 2.5 * @since 2.5
*/ */
public class CallMetaDataProviderFactory { public class CallMetaDataProviderFactory {
/** Logger */
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
/** List of supported database products for procedure calls */ /** List of supported database products for procedure calls */
public static final List<String> supportedDatabaseProductsForProcedures = Arrays.asList( public static final List<String> supportedDatabaseProductsForProcedures = Arrays.asList(
"Apache Derby", "Apache Derby",
@ -51,6 +49,7 @@ public class CallMetaDataProviderFactory {
"PostgreSQL", "PostgreSQL",
"Sybase" "Sybase"
); );
/** List of supported database products for function calls */ /** List of supported database products for function calls */
public static final List<String> supportedDatabaseProductsForFunctions = Arrays.asList( public static final List<String> supportedDatabaseProductsForFunctions = Arrays.asList(
"MySQL", "MySQL",
@ -59,6 +58,9 @@ public class CallMetaDataProviderFactory {
"PostgreSQL" "PostgreSQL"
); );
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
/** /**
* Create a CallMetaDataProvider based on the database metadata * Create a CallMetaDataProvider based on the database metadata
* @param dataSource used to retrieve metadata * @param dataSource used to retrieve metadata
@ -124,17 +126,16 @@ public class CallMetaDataProviderFactory {
} }
provider.initializeWithMetaData(databaseMetaData); provider.initializeWithMetaData(databaseMetaData);
if (accessProcedureColumnMetaData) { if (accessProcedureColumnMetaData) {
provider.initializeWithProcedureColumnMetaData( provider.initializeWithProcedureColumnMetaData(databaseMetaData,
databaseMetaData, context.getCatalogName(), context.getSchemaName(), context.getProcedureName()); context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
} }
return provider; return provider;
} }
}); });
} }
catch (MetaDataAccessException ex) { catch (MetaDataAccessException ex) {
throw new DataAccessResourceFailureException("Error retreiving database metadata", ex); throw new DataAccessResourceFailureException("Error retrieving database metadata", ex);
} }
} }
} }

28
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
Arrays.asList("Apache Derby", "HSQL Database Engine"); Arrays.asList("Apache Derby", "HSQL Database Engine");
/** Collection of TableParameterMetaData objects */ /** Collection of TableParameterMetaData objects */
private List<TableParameterMetaData> insertParameterMetaData = new ArrayList<TableParameterMetaData>(); private List<TableParameterMetaData> tableParameterMetaData = new ArrayList<TableParameterMetaData>();
/** NativeJdbcExtractor that can be used to retrieve the native connection */ /** NativeJdbcExtractor that can be used to retrieve the native connection */
private NativeJdbcExtractor nativeJdbcExtractor; private NativeJdbcExtractor nativeJdbcExtractor;
@ -109,7 +109,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
@Override @Override
public List<TableParameterMetaData> getTableParameterMetaData() { public List<TableParameterMetaData> getTableParameterMetaData() {
return this.insertParameterMetaData; return this.tableParameterMetaData;
} }
@Override @Override
@ -376,17 +376,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
} }
try { try {
tableColumns = databaseMetaData.getColumns( tableColumns = databaseMetaData.getColumns(
metaDataCatalogName, metaDataCatalogName, metaDataSchemaName, metaDataTableName, null);
metaDataSchemaName,
metaDataTableName,
null);
while (tableColumns.next()) { while (tableColumns.next()) {
String columnName = tableColumns.getString("COLUMN_NAME"); String columnName = tableColumns.getString("COLUMN_NAME");
int dataType = tableColumns.getInt("DATA_TYPE"); int dataType = tableColumns.getInt("DATA_TYPE");
if (dataType == Types.DECIMAL) { if (dataType == Types.DECIMAL) {
String typeName = tableColumns.getString("TYPE_NAME"); String typeName = tableColumns.getString("TYPE_NAME");
int decimalDigits = tableColumns.getInt("DECIMAL_DIGITS"); int decimalDigits = tableColumns.getInt("DECIMAL_DIGITS");
// override a DECIMAL data type for no-decimal numerics // Override a DECIMAL data type for no-decimal numerics
// (this is for better Oracle support where there have been issues // (this is for better Oracle support where there have been issues
// using DECIMAL for certain inserts (see SPR-6912)) // using DECIMAL for certain inserts (see SPR-6912))
if ("NUMBER".equals(typeName) && decimalDigits == 0) { if ("NUMBER".equals(typeName) && decimalDigits == 0) {
@ -400,18 +397,11 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
} }
} }
boolean nullable = tableColumns.getBoolean("NULLABLE"); boolean nullable = tableColumns.getBoolean("NULLABLE");
TableParameterMetaData meta = new TableParameterMetaData( TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable);
columnName, this.tableParameterMetaData.add(meta);
dataType,
nullable
);
this.insertParameterMetaData.add(meta);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Retrieved metadata: " logger.debug("Retrieved metadata: " + meta.getParameterName() +
+ meta.getParameterName() + " " + meta.getSqlType() + " " + meta.isNullable());
" " + meta.getSqlType() +
" " + meta.isNullable()
);
} }
} }
} }

21
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -202,7 +202,8 @@ public class TableMetaDataContext {
* @param generatedKeyNames name of generated keys * @param generatedKeyNames name of generated keys
*/ */
public void processMetaData(DataSource dataSource, List<String> declaredColumns, String[] generatedKeyNames) { public void processMetaData(DataSource dataSource, List<String> declaredColumns, String[] generatedKeyNames) {
this.metaDataProvider = TableMetaDataProviderFactory.createMetaDataProvider(dataSource, this, this.nativeJdbcExtractor); this.metaDataProvider =
TableMetaDataProviderFactory.createMetaDataProvider(dataSource, this, this.nativeJdbcExtractor);
this.tableColumns = reconcileColumnsToUse(declaredColumns, generatedKeyNames); this.tableColumns = reconcileColumnsToUse(declaredColumns, generatedKeyNames);
} }
@ -299,14 +300,14 @@ public class TableMetaDataContext {
} }
StringBuilder insertStatement = new StringBuilder(); StringBuilder insertStatement = new StringBuilder();
insertStatement.append("INSERT INTO "); insertStatement.append("INSERT INTO ");
if (this.getSchemaName() != null) { if (getSchemaName() != null) {
insertStatement.append(this.getSchemaName()); insertStatement.append(getSchemaName());
insertStatement.append("."); insertStatement.append(".");
} }
insertStatement.append(this.getTableName()); insertStatement.append(getTableName());
insertStatement.append(" ("); insertStatement.append(" (");
int columnCount = 0; int columnCount = 0;
for (String columnName : this.getTableColumns()) { for (String columnName : getTableColumns()) {
if (!keys.contains(columnName.toUpperCase())) { if (!keys.contains(columnName.toUpperCase())) {
columnCount++; columnCount++;
if (columnCount > 1) { if (columnCount > 1) {
@ -319,11 +320,11 @@ public class TableMetaDataContext {
if (columnCount < 1) { if (columnCount < 1) {
if (this.generatedKeyColumnsUsed) { if (this.generatedKeyColumnsUsed) {
logger.info("Unable to locate non-key columns for table '" + logger.info("Unable to locate non-key columns for table '" +
this.getTableName() + "' so an empty insert statement is generated"); getTableName() + "' so an empty insert statement is generated");
} }
else { else {
throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" + throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
this.getTableName() + "' so an insert statement can't be generated"); getTableName() + "' so an insert statement can't be generated");
} }
} }
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
@ -341,7 +342,7 @@ public class TableMetaDataContext {
* @return the array of types to be used * @return the array of types to be used
*/ */
public int[] createInsertTypes() { public int[] createInsertTypes() {
int[] types = new int[this.getTableColumns().size()]; int[] types = new int[getTableColumns().size()];
List<TableParameterMetaData> parameters = this.metaDataProvider.getTableParameterMetaData(); List<TableParameterMetaData> parameters = this.metaDataProvider.getTableParameterMetaData();
Map<String, TableParameterMetaData> parameterMap = Map<String, TableParameterMetaData> parameterMap =
new LinkedHashMap<String, TableParameterMetaData>(parameters.size()); new LinkedHashMap<String, TableParameterMetaData>(parameters.size());
@ -349,7 +350,7 @@ public class TableMetaDataContext {
parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd); parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd);
} }
int typeIndx = 0; int typeIndx = 0;
for (String column : this.getTableColumns()) { for (String column : getTableColumns()) {
if (column == null) { if (column == null) {
types[typeIndx] = SqlTypeValue.TYPE_UNKNOWN; types[typeIndx] = SqlTypeValue.TYPE_UNKNOWN;
} }

5
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,7 +30,8 @@ import org.springframework.jdbc.support.MetaDataAccessException;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor; import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;
/** /**
* Factory used to create a {@link TableMetaDataProvider} implementation based on the type of databse being used. * Factory used to create a {@link TableMetaDataProvider} implementation
* based on the type of databse being used.
* *
* @author Thomas Risberg * @author Thomas Risberg
* @since 2.5 * @since 2.5

33
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -162,7 +162,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
} }
} }
private void updateStompHeadersFromSimpMessageHeaders() { void updateStompHeadersFromSimpMessageHeaders() {
if (getDestination() != null) { if (getDestination() != null) {
setNativeHeader(STOMP_DESTINATION_HEADER, getDestination()); setNativeHeader(STOMP_DESTINATION_HEADER, getDestination());
} }
@ -218,19 +218,28 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
return (StompCommand) getHeader(COMMAND_HEADER); return (StompCommand) getHeader(COMMAND_HEADER);
} }
public Set<String> getAcceptVersion() {
String rawValue = getFirstNativeHeader(STOMP_ACCEPT_VERSION_HEADER);
return (rawValue != null ? StringUtils.commaDelimitedListToSet(rawValue) : Collections.<String>emptySet());
}
public boolean isHeartbeat() { public boolean isHeartbeat() {
return (SimpMessageType.HEARTBEAT == getMessageType()); return (SimpMessageType.HEARTBEAT == getMessageType());
} }
public long[] getHeartbeat() {
String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
if (!StringUtils.hasText(rawValue)) {
return Arrays.copyOf(DEFAULT_HEARTBEAT, 2);
}
String[] rawValues = StringUtils.commaDelimitedListToStringArray(rawValue);
return new long[] {Long.valueOf(rawValues[0]), Long.valueOf(rawValues[1])};
}
public void setAcceptVersion(String acceptVersion) { public void setAcceptVersion(String acceptVersion) {
setNativeHeader(STOMP_ACCEPT_VERSION_HEADER, acceptVersion); setNativeHeader(STOMP_ACCEPT_VERSION_HEADER, acceptVersion);
} }
public Set<String> getAcceptVersion() {
String rawValue = getFirstNativeHeader(STOMP_ACCEPT_VERSION_HEADER);
return (rawValue != null ? StringUtils.commaDelimitedListToSet(rawValue) : Collections.<String>emptySet());
}
public void setHost(String host) { public void setHost(String host) {
setNativeHeader(STOMP_HOST_HEADER, host); setNativeHeader(STOMP_HOST_HEADER, host);
} }
@ -245,15 +254,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
setNativeHeader(STOMP_DESTINATION_HEADER, destination); setNativeHeader(STOMP_DESTINATION_HEADER, destination);
} }
public long[] getHeartbeat() { @Override
String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
if (!StringUtils.hasText(rawValue)) {
return Arrays.copyOf(DEFAULT_HEARTBEAT, 2);
}
String[] rawValues = StringUtils.commaDelimitedListToStringArray(rawValue);
return new long[] { Long.valueOf(rawValues[0]), Long.valueOf(rawValues[1])};
}
public void setContentType(MimeType contentType) { public void setContentType(MimeType contentType) {
super.setContentType(contentType); super.setContentType(contentType);
setNativeHeader(STOMP_CONTENT_TYPE_HEADER, contentType.toString()); setNativeHeader(STOMP_CONTENT_TYPE_HEADER, contentType.toString());

12
spring-web/src/main/java/org/springframework/http/StreamingHttpOutputMessage.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -33,12 +33,13 @@ public interface StreamingHttpOutputMessage extends HttpOutputMessage {
*/ */
void setBody(Body body); void setBody(Body body);
/** /**
* Defines the contract for bodies that can be written directly to a * Defines the contract for bodies that can be written directly to an {@link OutputStream}.
* {@link OutputStream}. It is useful with HTTP client libraries that provide indirect * It is useful with HTTP client libraries that provide indirect access to an
* access to an {@link OutputStream} via a callback mechanism. * {@link OutputStream} via a callback mechanism.
*/ */
public interface Body { interface Body {
/** /**
* Writes this body to the given {@link OutputStream}. * Writes this body to the given {@link OutputStream}.
@ -46,7 +47,6 @@ public interface StreamingHttpOutputMessage extends HttpOutputMessage {
* @throws IOException in case of errors * @throws IOException in case of errors
*/ */
void writeTo(OutputStream outputStream) throws IOException; void writeTo(OutputStream outputStream) throws IOException;
} }
} }

4
spring-web/src/main/java/org/springframework/web/multipart/MaxUploadSizeExceededException.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ public class MaxUploadSizeExceededException extends MultipartException {
* Return the maximum upload size allowed. * Return the maximum upload size allowed.
*/ */
public long getMaxUploadSize() { public long getMaxUploadSize() {
return maxUploadSize; return this.maxUploadSize;
} }
} }

24
spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -147,6 +147,28 @@ public class WebRequestDataBinderTests {
assertFalse(target.isPostProcessed()); assertFalse(target.isPostProcessed());
} }
@Test
public void testFieldDefaultWithNestedProperty() throws Exception {
TestBean target = new TestBean();
target.setSpouse(new TestBean());
WebRequestDataBinder binder = new WebRequestDataBinder(target);
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("!spouse.postProcessed", "on");
request.addParameter("_spouse.postProcessed", "visible");
request.addParameter("spouse.postProcessed", "on");
binder.bind(new ServletWebRequest(request));
assertTrue(((TestBean) target.getSpouse()).isPostProcessed());
request.removeParameter("spouse.postProcessed");
binder.bind(new ServletWebRequest(request));
assertTrue(((TestBean) target.getSpouse()).isPostProcessed());
request.removeParameter("!spouse.postProcessed");
binder.bind(new ServletWebRequest(request));
assertFalse(((TestBean) target.getSpouse()).isPostProcessed());
}
@Test @Test
public void testFieldDefaultNonBoolean() throws Exception { public void testFieldDefaultNonBoolean() throws Exception {
TestBean target = new TestBean(); TestBean target = new TestBean();

12
spring-webmvc/src/main/java/org/springframework/web/servlet/NoHandlerFoundException.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,20 +13,24 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.web.servlet; package org.springframework.web.servlet;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
/** /**
* Exception to be thrown if DispatcherServlet is unable to determine a corresponding * Exception to be thrown if DispatcherServlet is unable to determine a corresponding
* handler for an incoming HTTP request. The DispatcherServlet throws this exception only * handler for an incoming HTTP request. The DispatcherServlet throws this exception
* if its throwExceptionIfNoHandlerFound property is set to "true". * only if its "throwExceptionIfNoHandlerFound" property is set to "true".
* *
* @author Brian Clozel * @author Brian Clozel
* @since 4.0 * @since 4.0
* @see org.springframework.web.servlet.DispatcherServlet * @see DispatcherServlet#setThrowExceptionIfNoHandlerFound(boolean)
* @see DispatcherServlet#noHandlerFound(HttpServletRequest, HttpServletResponse)
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class NoHandlerFoundException extends ServletException { public class NoHandlerFoundException extends ServletException {

Loading…
Cancel
Save