Polishing
This commit is contained in:
42
build.gradle
42
build.gradle
@@ -441,7 +441,7 @@ project("spring-tx") {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
optional(project(":spring-aop"))
|
||||
optional(project(":spring-context")) // for JCA, @EnableTransactionManagement
|
||||
optional(project(":spring-context")) // for JCA, @EnableTransactionManagement
|
||||
optional("aopalliance:aopalliance:1.0")
|
||||
optional("javax.transaction:javax.transaction-api:1.2")
|
||||
optional("javax.resource:connector-api:1.5")
|
||||
@@ -516,7 +516,7 @@ project("spring-jdbc") {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-tx"))
|
||||
optional(project(":spring-context")) // for JndiDataSourceLookup
|
||||
optional(project(":spring-context")) // for JndiDataSourceLookup
|
||||
optional("javax.transaction:javax.transaction-api:1.2")
|
||||
optional("com.mchange:c3p0:0.9.2.1")
|
||||
optional("org.hsqldb:hsqldb:${hsqldbVersion}")
|
||||
@@ -533,8 +533,8 @@ project("spring-context-support") {
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-context"))
|
||||
optional(project(":spring-jdbc")) // for Quartz support
|
||||
optional(project(":spring-tx")) // for Quartz support
|
||||
optional(project(":spring-jdbc")) // for Quartz support
|
||||
optional(project(":spring-tx")) // for Quartz support
|
||||
optional("javax.mail:javax.mail-api:1.4.7")
|
||||
optional("javax.cache:cache-api:1.0.0")
|
||||
optional("com.google.guava:guava:17.0")
|
||||
@@ -550,8 +550,8 @@ project("spring-context-support") {
|
||||
exclude group: "xml-apis", module: "xml-apis"
|
||||
}
|
||||
testCompile("org.apache.poi:poi:3.10.1")
|
||||
testCompile("commons-beanutils:commons-beanutils:1.8.0") // for Velocity/JasperReports
|
||||
testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports
|
||||
testCompile("commons-beanutils:commons-beanutils:1.8.0") // for Velocity/JasperReports
|
||||
testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports
|
||||
testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
|
||||
testCompile("org.slf4j:slf4j-api:${slf4jVersion}")
|
||||
testRuntime("com.sun.mail:javax.mail:1.4.7")
|
||||
@@ -565,12 +565,12 @@ project("spring-web") {
|
||||
description = "Spring Web"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-aop")) // for JaxWsPortProxyFactoryBean
|
||||
compile(project(":spring-beans")) // for MultiPartFilter
|
||||
compile(project(":spring-aop")) // for JaxWsPortProxyFactoryBean
|
||||
compile(project(":spring-beans")) // for MultipartFilter
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
provided("javax.servlet:javax.servlet-api:3.0.1")
|
||||
optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter
|
||||
optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter
|
||||
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
|
||||
optional("javax.portlet:portlet-api:2.0")
|
||||
optional("javax.el:javax.el-api:2.2.5")
|
||||
@@ -578,7 +578,7 @@ project("spring-web") {
|
||||
optional("aopalliance:aopalliance:1.0")
|
||||
optional("com.caucho:hessian:4.0.7")
|
||||
optional("commons-fileupload:commons-fileupload:1.3.1")
|
||||
optional("org.apache.httpcomponents:httpclient:4.3.5")
|
||||
optional("org.apache.httpcomponents:httpclient:4.3.6")
|
||||
optional("org.apache.httpcomponents:httpasyncclient:4.0.2")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:${jackson1Version}")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
||||
@@ -711,8 +711,8 @@ project("spring-webmvc") {
|
||||
compile(project(":spring-expression"))
|
||||
compile(project(":spring-web"))
|
||||
provided("javax.servlet:javax.servlet-api:3.0.1")
|
||||
optional(project(":spring-context-support")) // for Velocity support
|
||||
optional(project(":spring-oxm")) // for MarshallingView
|
||||
optional(project(":spring-context-support")) // for Velocity support
|
||||
optional(project(":spring-oxm")) // for MarshallingView
|
||||
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
|
||||
optional("javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1")
|
||||
optional("net.sourceforge.jexcelapi:jxl:2.6.12")
|
||||
@@ -764,7 +764,7 @@ project("spring-webmvc") {
|
||||
}
|
||||
testCompile("javax.validation:validation-api:1.0.0.GA")
|
||||
testCompile("org.hibernate:hibernate-validator:${hibVal4Version}")
|
||||
testCompile("org.apache.httpcomponents:httpclient:4.3.5")
|
||||
testCompile("org.apache.httpcomponents:httpclient:4.3.6")
|
||||
testCompile("commons-fileupload:commons-fileupload:1.3.1")
|
||||
testCompile("commons-io:commons-io:1.3")
|
||||
testCompile("joda-time:joda-time:${jodaVersion}")
|
||||
@@ -915,13 +915,13 @@ project("spring-aspects") {
|
||||
rt("org.aspectj:aspectjrt:${aspectjVersion}")
|
||||
compile("org.aspectj:aspectjweaver:${aspectjVersion}")
|
||||
provided("org.eclipse.persistence:javax.persistence:2.0.0")
|
||||
optional(project(":spring-aop")) // for @Async support
|
||||
optional(project(":spring-beans")) // for @Configurable support
|
||||
optional(project(":spring-context")) // for @Enable* support
|
||||
optional(project(":spring-context-support")) // for JavaMail support
|
||||
optional(project(":spring-orm")) // for JPA exception translation support
|
||||
optional(project(":spring-tx")) // for JPA, @Transactional support
|
||||
testCompile(project(":spring-core")) // for CodeStyleAspect
|
||||
optional(project(":spring-aop")) // for @Async support
|
||||
optional(project(":spring-beans")) // for @Configurable support
|
||||
optional(project(":spring-context")) // for @Enable* support
|
||||
optional(project(":spring-context-support")) // for JavaMail support
|
||||
optional(project(":spring-orm")) // for JPA exception translation support
|
||||
optional(project(":spring-tx")) // for JPA, @Transactional support
|
||||
testCompile(project(":spring-core")) // for CodeStyleAspect
|
||||
testCompile(project(":spring-test"))
|
||||
testCompile("javax.mail:javax.mail-api:1.4.7")
|
||||
}
|
||||
@@ -1157,7 +1157,7 @@ configure(rootProject) {
|
||||
}
|
||||
}
|
||||
|
||||
// Create an distribution that contains all dependencies (required and optional).
|
||||
// Create a distribution that contains all dependencies (required and optional).
|
||||
// Not published by default; only for use when building from source.
|
||||
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
|
||||
group = "Distribution"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -104,9 +104,11 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class);
|
||||
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnreferencedSingletonWasInstantiated() {
|
||||
KnowsIfInstantiated.clearInstantiationRecord();
|
||||
@@ -2748,6 +2750,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class KnowsIfInstantiated {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<util:property-path id="name" path="
|
||||
configuredBean.
|
||||
name
|
||||
"/>
|
||||
"/>
|
||||
|
||||
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
|
||||
<property name="name">
|
||||
|
||||
@@ -27,8 +27,9 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Converts an Array to another Array. First adapts the source array to a List, then
|
||||
* delegates to {@link CollectionToArrayConverter} to perform the target array conversion.
|
||||
* Converts an array to another array. First adapts the source array to a List,
|
||||
* then delegates to {@link CollectionToArrayConverter} to perform the target
|
||||
* array conversion.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Phillip Webb
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -27,23 +27,27 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
|
||||
/**
|
||||
* Converts an Array to a Collection.
|
||||
* Converts an array to a Collection.
|
||||
*
|
||||
* <p>First, creates a new Collection of the requested targetType.
|
||||
* <p>First, creates a new Collection of the requested target type.
|
||||
* Then adds each array element to the target collection.
|
||||
* Will perform an element conversion from the source component type to the collection's parameterized type if necessary.
|
||||
* Will perform an element conversion from the source component type
|
||||
* to the collection's parameterized type if necessary.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
*/
|
||||
final class ArrayToCollectionConverter implements ConditionalGenericConverter {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public ArrayToCollectionConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(Object[].class, Collection.class));
|
||||
@@ -60,9 +64,12 @@ final class ArrayToCollectionConverter implements ConditionalGenericConverter {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int length = Array.getLength(source);
|
||||
TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
|
||||
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), length);
|
||||
if (targetType.getElementTypeDescriptor() == null) {
|
||||
|
||||
if (elementDesc == null) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
Object sourceElement = Array.get(source, i);
|
||||
target.add(sourceElement);
|
||||
@@ -72,7 +79,7 @@ final class ArrayToCollectionConverter implements ConditionalGenericConverter {
|
||||
for (int i = 0; i < length; i++) {
|
||||
Object sourceElement = Array.get(source, i);
|
||||
Object targetElement = this.conversionService.convert(sourceElement,
|
||||
sourceType.elementTypeDescriptor(sourceElement), targetType.getElementTypeDescriptor());
|
||||
sourceType.elementTypeDescriptor(sourceElement), elementDesc);
|
||||
target.add(targetElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -25,7 +25,8 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
|
||||
/**
|
||||
* Converts an Array to an Object by returning the first array element after converting it to the desired targetType.
|
||||
* Converts an array to an Object by returning the first array element
|
||||
* after converting it to the desired target type.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
@@ -34,10 +35,12 @@ final class ArrayToObjectConverter implements ConditionalGenericConverter {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public ArrayToObjectConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(Object[].class, Object.class));
|
||||
|
||||
@@ -26,9 +26,9 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Converts an Array to a comma-delimited String.
|
||||
* This implementation first adapts the source Array to a List,
|
||||
* then delegates to {@link CollectionToStringConverter} to perform the target String conversion.
|
||||
* Converts an array to a comma-delimited String. First adapts the source array
|
||||
* to a List, then delegates to {@link CollectionToStringConverter} to perform
|
||||
* the target String conversion.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
* map's parameterized types K,V if necessary.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
*/
|
||||
final class MapToMapConverter implements ConditionalGenericConverter {
|
||||
@@ -64,17 +65,22 @@ final class MapToMapConverter implements ConditionalGenericConverter {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
boolean copyRequired = !targetType.getType().isInstance(source);
|
||||
Map<Object, Object> sourceMap = (Map<Object, Object>) source;
|
||||
|
||||
// Shortcut if possible...
|
||||
boolean copyRequired = !targetType.getType().isInstance(source);
|
||||
if (!copyRequired && sourceMap.isEmpty()) {
|
||||
return sourceMap;
|
||||
}
|
||||
TypeDescriptor keyDesc = targetType.getMapKeyTypeDescriptor();
|
||||
TypeDescriptor valueDesc = targetType.getMapValueTypeDescriptor();
|
||||
|
||||
List<MapEntry> targetEntries = new ArrayList<MapEntry>(sourceMap.size());
|
||||
for (Map.Entry<Object, Object> entry : sourceMap.entrySet()) {
|
||||
Object sourceKey = entry.getKey();
|
||||
Object sourceValue = entry.getValue();
|
||||
Object targetKey = convertKey(sourceKey, sourceType, targetType.getMapKeyTypeDescriptor());
|
||||
Object targetValue = convertValue(sourceValue, sourceType, targetType.getMapValueTypeDescriptor());
|
||||
Object targetKey = convertKey(sourceKey, sourceType, keyDesc);
|
||||
Object targetValue = convertValue(sourceValue, sourceType, valueDesc);
|
||||
targetEntries.add(new MapEntry(targetKey, targetValue));
|
||||
if (sourceKey != targetKey || sourceValue != targetValue) {
|
||||
copyRequired = true;
|
||||
@@ -83,6 +89,7 @@ final class MapToMapConverter implements ConditionalGenericConverter {
|
||||
if (!copyRequired) {
|
||||
return sourceMap;
|
||||
}
|
||||
|
||||
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
|
||||
for (MapEntry entry : targetEntries) {
|
||||
entry.addToMap(targetMap);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -25,8 +25,8 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
|
||||
/**
|
||||
* Converts an Object to a single-element Array containing the Object.
|
||||
* Will convert the Object to the target Array's component type if necessary.
|
||||
* Converts an Object to a single-element array containing the Object.
|
||||
* Will convert the Object to the target array's component type if necessary.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
@@ -35,10 +35,12 @@ final class ObjectToArrayConverter implements ConditionalGenericConverter {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public ObjectToArrayConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(Object.class, Object[].class));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -37,10 +37,12 @@ final class ObjectToCollectionConverter implements ConditionalGenericConverter {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public ObjectToCollectionConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(Object.class, Collection.class));
|
||||
@@ -56,12 +58,15 @@ final class ObjectToCollectionConverter implements ConditionalGenericConverter {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
|
||||
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), 1);
|
||||
if (targetType.getElementTypeDescriptor() == null || targetType.getElementTypeDescriptor().isCollection()) {
|
||||
|
||||
if (elementDesc == null || elementDesc.isCollection()) {
|
||||
target.add(source);
|
||||
}
|
||||
else {
|
||||
Object singleElement = this.conversionService.convert(source, sourceType, targetType.getElementTypeDescriptor());
|
||||
Object singleElement = this.conversionService.convert(source, sourceType, elementDesc);
|
||||
target.add(singleElement);
|
||||
}
|
||||
return target;
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
* {@code String.class} can be converted to it.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
*/
|
||||
final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
@@ -61,16 +62,19 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
return null;
|
||||
}
|
||||
String string = (String) source;
|
||||
|
||||
String[] fields = StringUtils.commaDelimitedListToStringArray(string);
|
||||
TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
|
||||
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), fields.length);
|
||||
if (targetType.getElementTypeDescriptor() == null) {
|
||||
|
||||
if (elementDesc == null) {
|
||||
for (String field : fields) {
|
||||
target.add(field.trim());
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (String field : fields) {
|
||||
Object targetElement = this.conversionService.convert(field.trim(), sourceType, targetType.getElementTypeDescriptor());
|
||||
Object targetElement = this.conversionService.convert(field.trim(), sourceType, elementDesc);
|
||||
target.add(targetElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterFactory;
|
||||
|
||||
/**
|
||||
* Converts from a String to a java.lang.Enum by calling {@link Enum#valueOf(Class, String)}.
|
||||
* Converts from a String to a {@link java.lang.Enum} by calling {@link Enum#valueOf(Class, String)}.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
final class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,8 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
|
||||
enumType = enumType.getSuperclass();
|
||||
}
|
||||
if (enumType == null) {
|
||||
throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum");
|
||||
throw new IllegalArgumentException(
|
||||
"The target type " + targetType.getName() + " does not refer to an enum");
|
||||
}
|
||||
return new StringToEnum(enumType);
|
||||
}
|
||||
|
||||
@@ -34,16 +34,19 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* Base class for {@code Filter}s that perform logging operations before and after a request is processed.
|
||||
* Base class for {@code Filter}s that perform logging operations before and after a request
|
||||
* is processed.
|
||||
*
|
||||
* <p>Subclasses should override the {@code beforeRequest(HttpServletRequest, String)} and
|
||||
* {@code afterRequest(HttpServletRequest, String)} methods to perform the actual logging around the request.
|
||||
* {@code afterRequest(HttpServletRequest, String)} methods to perform the actual logging
|
||||
* around the request.
|
||||
*
|
||||
* <p>Subclasses are passed the message to write to the log in the {@code beforeRequest} and
|
||||
* {@code afterRequest} methods. By default, only the URI of the request is logged. However, setting the
|
||||
* {@code includeQueryString} property to {@code true} will cause the query string of the request to be
|
||||
* included also. The payload (body) of the request can be logged via the {@code includePayload} flag. Note that
|
||||
* this will only log that which is read, which might not be the entire payload.
|
||||
* {@code afterRequest} methods. By default, only the URI of the request is logged. However,
|
||||
* setting the {@code includeQueryString} property to {@code true} will cause the query string
|
||||
* of the request to be included also. The payload (body) of the request can be logged via the
|
||||
* {@code includePayload} flag. Note that this will only log that which is read, which might
|
||||
* not be the entire payload.
|
||||
*
|
||||
* <p>Prefixes and suffixes for the before and after messages can be configured using the
|
||||
* {@code beforeMessagePrefix}, {@code afterMessagePrefix}, {@code beforeMessageSuffix} and
|
||||
@@ -87,41 +90,43 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
|
||||
|
||||
/**
|
||||
* Set whether or not the query string should be included in the log message. <p>Should be configured using an
|
||||
* {@code <init-param>} for parameter name "includeQueryString" in the filter definition in
|
||||
* {@code web.xml}.
|
||||
* Set whether the query string should be included in the log message.
|
||||
* <p>Should be configured using an {@code <init-param>} for parameter name
|
||||
* "includeQueryString" in the filter definition in {@code web.xml}.
|
||||
*/
|
||||
public void setIncludeQueryString(boolean includeQueryString) {
|
||||
this.includeQueryString = includeQueryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the query string should be included in the log message.
|
||||
* Return whether the query string should be included in the log message.
|
||||
*/
|
||||
protected boolean isIncludeQueryString() {
|
||||
return this.includeQueryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not the client address and session id should be included in the log message. <p>Should be configured
|
||||
* using an {@code <init-param>} for parameter name "includeClientInfo" in the filter definition in
|
||||
* {@code web.xml}.
|
||||
* Set whether the client address and session id should be included in the
|
||||
* log message.
|
||||
* <p>Should be configured using an {@code <init-param>} for parameter name
|
||||
* "includeClientInfo" in the filter definition in {@code web.xml}.
|
||||
*/
|
||||
public void setIncludeClientInfo(boolean includeClientInfo) {
|
||||
this.includeClientInfo = includeClientInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the client address and session id should be included in the log message.
|
||||
* Return whether the client address and session id should be included in the
|
||||
* log message.
|
||||
*/
|
||||
protected boolean isIncludeClientInfo() {
|
||||
return this.includeClientInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not the request payload (body) should be included in the log message. <p>Should be configured using
|
||||
* an {@code <init-param>} for parameter name "includePayload" in the filter definition in
|
||||
* {@code web.xml}.
|
||||
* Set whether the request payload (body) should be included in the log message.
|
||||
* <p>Should be configured using an {@code <init-param>} for parameter name
|
||||
* "includePayload" in the filter definition in {@code web.xml}.
|
||||
*/
|
||||
|
||||
public void setIncludePayload(boolean includePayload) {
|
||||
@@ -129,14 +134,15 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the request payload (body) should be included in the log message.
|
||||
* Return whether the request payload (body) should be included in the log message.
|
||||
*/
|
||||
protected boolean isIncludePayload() {
|
||||
return includePayload;
|
||||
return this.includePayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum length of the payload body to be included in the log message. Default is 50 characters.
|
||||
* Sets the maximum length of the payload body to be included in the log message.
|
||||
* Default is 50 characters.
|
||||
*/
|
||||
public void setMaxPayloadLength(int maxPayloadLength) {
|
||||
Assert.isTrue(maxPayloadLength >= 0, "'maxPayloadLength' should be larger than or equal to 0");
|
||||
@@ -147,32 +153,36 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
* Return the maximum length of the payload body to be included in the log message.
|
||||
*/
|
||||
protected int getMaxPayloadLength() {
|
||||
return maxPayloadLength;
|
||||
return this.maxPayloadLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value that should be prepended to the log message written <i>before</i> a request is processed.
|
||||
* Set the value that should be prepended to the log message written
|
||||
* <i>before</i> a request is processed.
|
||||
*/
|
||||
public void setBeforeMessagePrefix(String beforeMessagePrefix) {
|
||||
this.beforeMessagePrefix = beforeMessagePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value that should be apppended to the log message written <i>before</i> a request is processed.
|
||||
* Set the value that should be appended to the log message written
|
||||
* <i>before</i> a request is processed.
|
||||
*/
|
||||
public void setBeforeMessageSuffix(String beforeMessageSuffix) {
|
||||
this.beforeMessageSuffix = beforeMessageSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value that should be prepended to the log message written <i>after</i> a request is processed.
|
||||
* Set the value that should be prepended to the log message written
|
||||
* <i>after</i> a request is processed.
|
||||
*/
|
||||
public void setAfterMessagePrefix(String afterMessagePrefix) {
|
||||
this.afterMessagePrefix = afterMessagePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value that should be appended to the log message written <i>after</i> a request is processed.
|
||||
* Set the value that should be appended to the log message written
|
||||
* <i>after</i> a request is processed.
|
||||
*/
|
||||
public void setAfterMessageSuffix(String afterMessageSuffix) {
|
||||
this.afterMessageSuffix = afterMessageSuffix;
|
||||
@@ -200,22 +210,21 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
throws ServletException, IOException {
|
||||
|
||||
boolean isFirstRequest = !isAsyncDispatch(request);
|
||||
HttpServletRequest requestToUse = request;
|
||||
|
||||
if (isIncludePayload()) {
|
||||
if (isFirstRequest) {
|
||||
request = new RequestCachingRequestWrapper(request);
|
||||
}
|
||||
if (isIncludePayload() && isFirstRequest) {
|
||||
requestToUse = new RequestCachingRequestWrapper(request);
|
||||
}
|
||||
|
||||
if (isFirstRequest) {
|
||||
beforeRequest(request, getBeforeMessage(request));
|
||||
beforeRequest(requestToUse, getBeforeMessage(requestToUse));
|
||||
}
|
||||
try {
|
||||
filterChain.doFilter(request, response);
|
||||
filterChain.doFilter(requestToUse, response);
|
||||
}
|
||||
finally {
|
||||
if (!isAsyncStarted(request)) {
|
||||
afterRequest(request, getAfterMessage(request));
|
||||
if (!isAsyncStarted(requestToUse)) {
|
||||
afterRequest(requestToUse, getAfterMessage(requestToUse));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,9 +364,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user