提交 ce4e795f 编写于 作者: J Juergen Hoeller

Polishing

上级 0cd7fed0
/*
* 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");
* 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(
this.pointcutParameterNames[i], this.pointcutParameterTypes[i]);
}
return parser.parsePointcutExpression(
replaceBooleanOperators(getExpression()),
return parser.parsePointcutExpression(replaceBooleanOperators(getExpression()),
this.pointcutDeclarationScope, pointcutParameters);
}
......
/*
* 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");
* you may not use this file except in compliance with the License.
......@@ -17,7 +17,7 @@
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
* 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
* @throws IllegalStateException if a cache entry has been found
* but failed to match the specified type
* @see #get(Object)
* @since 4.0
* @see #get(Object)
*/
<T> T get(Object key, Class<T> type);
......
/*
* 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");
* 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
* to standard Java interface-based proxies. The default is {@code false}. <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>
* Spring-managed beans requiring proxying, not just those marked with
* {@code @Cacheable}. For example, other beans marked with Spring's
* {@code @Transactional} annotation will be upgraded to subclass proxying at the same
* time. This approach has no negative impact in practice unless one is explicitly
* expecting one type of proxy vs another, e.g. in tests.
* Spring-managed beans requiring proxying, not just those marked with {@code @Cacheable}.
* For example, other beans marked with Spring's {@code @Transactional} annotation will
* be upgraded to subclass proxying at the same time. This approach has no negative
* impact in practice unless one is explicitly expecting one type of proxy vs another,
* e.g. in tests.
*/
boolean proxyTargetClass() default false;
......@@ -185,4 +184,5 @@ public @interface EnableCaching {
* The default is {@link Ordered#LOWEST_PRECEDENCE}.
*/
int order() default Ordered.LOWEST_PRECEDENCE;
}
/*
* 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");
* 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 org.codehaus.groovy.control.CompilationFailedException;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
......@@ -102,7 +101,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableListableBeanFactory) {
((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
}
......
/*
* 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");
* 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;/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;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt;</pre>
......@@ -346,17 +346,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
* @param scriptedObjectBeanName the name of the internal scripted object bean
*/
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a prototype.
synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory = this.scriptBeanFactory
.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
scriptFactory.getScriptSourceLocator());
this.scriptBeanFactory.registerBeanDefinition(
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory =
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource =
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces;
......@@ -365,8 +364,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
scriptedInterfaces);
BeanDefinition objectBd = createScriptedObjectBeanDefinition(
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
......@@ -569,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
proxyFactory.setInterfaces(interfaces);
if (proxyTargetClass) {
classLoader = null; // force use of Class.getClassLoader()
proxyFactory.setProxyTargetClass(proxyTargetClass);
proxyFactory.setProxyTargetClass(true);
}
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
......
/*
* 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");
* 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})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifier {
public @interface TestQualifier {
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifierWithDefaultValue {
public @interface TestQualifierWithDefaultValue {
public abstract String value() default "default";
String value() default "default";
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifierWithMultipleAttributes {
public @interface TestQualifierWithMultipleAttributes {
public abstract String value() default "default";
String value() default "default";
public abstract int number();
int number();
}
}
......@@ -84,7 +84,8 @@ public abstract class ReflectionUtils {
while (!Object.class.equals(searchType) && searchType != null) {
Field[] fields = searchType.getDeclaredFields();
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;
}
}
......@@ -410,8 +411,7 @@ public abstract class ReflectionUtils {
i--;
}
return ((i > CGLIB_RENAMED_METHOD_PREFIX.length()) &&
(i < name.length() - 1) &&
(name.charAt(i) == '$'));
(i < name.length() - 1) && name.charAt(i) == '$');
}
return false;
}
......@@ -425,7 +425,8 @@ public abstract class ReflectionUtils {
* @see java.lang.reflect.Field#setAccessible
*/
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()) {
field.setAccessible(true);
}
......
/*
* 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");
* you may not use this file except in compliance with the License.
......@@ -67,12 +67,12 @@ public class GenericTypeResolverTests {
@Test
public void methodReturnTypes() {
assertEquals(Integer.class,
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class));
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class));
assertEquals(String.class,
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class));
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class));
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class));
assertEquals(null,
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class));
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class));
}
@Test
......@@ -81,13 +81,13 @@ public class GenericTypeResolverTests {
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
assertEquals(MyInterfaceType.class,
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage",
MyInterfaceType[].class);
MyInterfaceType[].class);
MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0);
assertEquals(MyInterfaceType[].class,
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage",
Object[].class);
......
/*
* 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");
* 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;
/**
* 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
* @since 2.5
*/
public class CallMetaDataProviderFactory {
/** Logger */
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
/** List of supported database products for procedure calls */
public static final List<String> supportedDatabaseProductsForProcedures = Arrays.asList(
"Apache Derby",
......@@ -51,6 +49,7 @@ public class CallMetaDataProviderFactory {
"PostgreSQL",
"Sybase"
);
/** List of supported database products for function calls */
public static final List<String> supportedDatabaseProductsForFunctions = Arrays.asList(
"MySQL",
......@@ -59,6 +58,9 @@ public class CallMetaDataProviderFactory {
"PostgreSQL"
);
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
/**
* Create a CallMetaDataProvider based on the database metadata
* @param dataSource used to retrieve metadata
......@@ -124,17 +126,16 @@ public class CallMetaDataProviderFactory {
}
provider.initializeWithMetaData(databaseMetaData);
if (accessProcedureColumnMetaData) {
provider.initializeWithProcedureColumnMetaData(
databaseMetaData, context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
provider.initializeWithProcedureColumnMetaData(databaseMetaData,
context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
}
return provider;
}
});
}
catch (MetaDataAccessException ex) {
throw new DataAccessResourceFailureException("Error retreiving database metadata", ex);
throw new DataAccessResourceFailureException("Error retrieving database metadata", ex);
}
}
}
/*
* 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");
* 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");
/** 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 */
private NativeJdbcExtractor nativeJdbcExtractor;
......@@ -109,7 +109,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
@Override
public List<TableParameterMetaData> getTableParameterMetaData() {
return this.insertParameterMetaData;
return this.tableParameterMetaData;
}
@Override
......@@ -376,17 +376,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
try {
tableColumns = databaseMetaData.getColumns(
metaDataCatalogName,
metaDataSchemaName,
metaDataTableName,
null);
metaDataCatalogName, metaDataSchemaName, metaDataTableName, null);
while (tableColumns.next()) {
String columnName = tableColumns.getString("COLUMN_NAME");
int dataType = tableColumns.getInt("DATA_TYPE");
if (dataType == Types.DECIMAL) {
String typeName = tableColumns.getString("TYPE_NAME");
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
// using DECIMAL for certain inserts (see SPR-6912))
if ("NUMBER".equals(typeName) && decimalDigits == 0) {
......@@ -400,18 +397,11 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
}
boolean nullable = tableColumns.getBoolean("NULLABLE");
TableParameterMetaData meta = new TableParameterMetaData(
columnName,
dataType,
nullable
);
this.insertParameterMetaData.add(meta);
TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable);
this.tableParameterMetaData.add(meta);
if (logger.isDebugEnabled()) {
logger.debug("Retrieved metadata: "
+ meta.getParameterName() +
" " + meta.getSqlType() +
" " + meta.isNullable()
);
logger.debug("Retrieved metadata: " + meta.getParameterName() +
" " + meta.getSqlType() + " " + meta.isNullable());
}
}
}
......
/*
* 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");
* 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
*/
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);
}
......@@ -299,14 +300,14 @@ public class TableMetaDataContext {
}
StringBuilder insertStatement = new StringBuilder();
insertStatement.append("INSERT INTO ");
if (this.getSchemaName() != null) {
insertStatement.append(this.getSchemaName());
if (getSchemaName() != null) {
insertStatement.append(getSchemaName());
insertStatement.append(".");
}
insertStatement.append(this.getTableName());
insertStatement.append(getTableName());
insertStatement.append(" (");
int columnCount = 0;
for (String columnName : this.getTableColumns()) {
for (String columnName : getTableColumns()) {
if (!keys.contains(columnName.toUpperCase())) {
columnCount++;
if (columnCount > 1) {
......@@ -319,11 +320,11 @@ public class TableMetaDataContext {
if (columnCount < 1) {
if (this.generatedKeyColumnsUsed) {
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 {
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++) {
......@@ -341,7 +342,7 @@ public class TableMetaDataContext {
* @return the array of types to be used
*/
public int[] createInsertTypes() {
int[] types = new int[this.getTableColumns().size()];
int[] types = new int[getTableColumns().size()];
List<TableParameterMetaData> parameters = this.metaDataProvider.getTableParameterMetaData();
Map<String, TableParameterMetaData> parameterMap =
new LinkedHashMap<String, TableParameterMetaData>(parameters.size());
......@@ -349,7 +350,7 @@ public class TableMetaDataContext {
parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd);
}
int typeIndx = 0;
for (String column : this.getTableColumns()) {
for (String column : getTableColumns()) {
if (column == null) {
types[typeIndx] = SqlTypeValue.TYPE_UNKNOWN;
}
......
/*
* 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");
* 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;
/**
* 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
* @since 2.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");
* 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) {
setNativeHeader(STOMP_DESTINATION_HEADER, getDestination());
}
......@@ -218,19 +218,28 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
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() {
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) {
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) {
setNativeHeader(STOMP_HOST_HEADER, host);
}
......@@ -245,15 +254,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
setNativeHeader(STOMP_DESTINATION_HEADER, destination);
}
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])};
}
@Override
public void setContentType(MimeType contentType) {
super.setContentType(contentType);
setNativeHeader(STOMP_CONTENT_TYPE_HEADER, contentType.toString());
......
/*
* 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");
* 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);
/**
* Defines the contract for bodies that can be written directly to a
* {@link OutputStream}. It is useful with HTTP client libraries that provide indirect
* access to an {@link OutputStream} via a callback mechanism.
* Defines the contract for bodies that can be written directly to an {@link OutputStream}.
* It is useful with HTTP client libraries that provide indirect access to an
* {@link OutputStream} via a callback mechanism.
*/
public interface Body {
interface Body {
/**
* Writes this body to the given {@link OutputStream}.
......@@ -46,7 +47,6 @@ public interface StreamingHttpOutputMessage extends HttpOutputMessage {
* @throws IOException in case of errors
*/
void writeTo(OutputStream outputStream) throws IOException;
}
}
/*
* 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");
* 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.
*/
public long getMaxUploadSize() {
return maxUploadSize;
return this.maxUploadSize;
}
}
/*
* 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");
* you may not use this file except in compliance with the License.
......@@ -147,6 +147,28 @@ public class WebRequestDataBinderTests {
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
public void testFieldDefaultNonBoolean() throws Exception {
TestBean target = new TestBean();
......
/*
* 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");
* 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
* limitations under the License.
*/
package org.springframework.web.servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpHeaders;
/**
* Exception to be thrown if DispatcherServlet is unable to determine a corresponding
* handler for an incoming HTTP request. The DispatcherServlet throws this exception only
* if its throwExceptionIfNoHandlerFound property is set to "true".
* handler for an incoming HTTP request. The DispatcherServlet throws this exception
* only if its "throwExceptionIfNoHandlerFound" property is set to "true".
*
* @author Brian Clozel
* @since 4.0
* @see org.springframework.web.servlet.DispatcherServlet
* @see DispatcherServlet#setThrowExceptionIfNoHandlerFound(boolean)
* @see DispatcherServlet#noHandlerFound(HttpServletRequest, HttpServletResponse)
*/
@SuppressWarnings("serial")
public class NoHandlerFoundException extends ServletException {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册