Polishing
This commit is contained in:
parent
65d52a4b97
commit
a9a1f783c5
|
|
@ -29,8 +29,8 @@ def customizePom(pom, gradleProject) {
|
||||||
}
|
}
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name "The Apache Software License, Version 2.0"
|
name "Apache License, Version 2.0"
|
||||||
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
url "http://www.apache.org/licenses/LICENSE-2.0"
|
||||||
distribution "repo"
|
distribution "repo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -39,10 +39,11 @@ public class CacheNamespaceHandler extends NamespaceHandlerSupport {
|
||||||
|
|
||||||
static final String DEFAULT_CACHE_MANAGER_BEAN_NAME = "cacheManager";
|
static final String DEFAULT_CACHE_MANAGER_BEAN_NAME = "cacheManager";
|
||||||
|
|
||||||
|
|
||||||
static String extractCacheManager(Element element) {
|
static String extractCacheManager(Element element) {
|
||||||
return (element.hasAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) ? element
|
return (element.hasAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) ?
|
||||||
.getAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE)
|
element.getAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) :
|
||||||
: CacheNamespaceHandler.DEFAULT_CACHE_MANAGER_BEAN_NAME);
|
CacheNamespaceHandler.DEFAULT_CACHE_MANAGER_BEAN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BeanDefinition parseKeyGenerator(Element element, BeanDefinition def) {
|
static BeanDefinition parseKeyGenerator(Element element, BeanDefinition def) {
|
||||||
|
|
@ -53,9 +54,11 @@ public class CacheNamespaceHandler extends NamespaceHandlerSupport {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenCacheBeanDefinitionParser());
|
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenCacheBeanDefinitionParser());
|
||||||
registerBeanDefinitionParser("advice", new CacheAdviceParser());
|
registerBeanDefinitionParser("advice", new CacheAdviceParser());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -256,8 +256,8 @@ public abstract class AbstractApplicationEventMulticaster
|
||||||
* for the given event type
|
* for the given event type
|
||||||
*/
|
*/
|
||||||
protected boolean supportsEvent(Class<?> listenerType, ResolvableType eventType) {
|
protected boolean supportsEvent(Class<?> listenerType, ResolvableType eventType) {
|
||||||
if (GenericApplicationListener.class.isAssignableFrom(listenerType)
|
if (GenericApplicationListener.class.isAssignableFrom(listenerType) ||
|
||||||
|| SmartApplicationListener.class.isAssignableFrom(listenerType)) {
|
SmartApplicationListener.class.isAssignableFrom(listenerType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ResolvableType declaredEventType = GenericApplicationListenerAdapter.resolveDeclaredEventType(listenerType);
|
ResolvableType declaredEventType = GenericApplicationListenerAdapter.resolveDeclaredEventType(listenerType);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -79,6 +79,7 @@ public interface ApplicationEventMulticaster {
|
||||||
* based on the {@code event} instance.
|
* based on the {@code event} instance.
|
||||||
* @param event the event to multicast
|
* @param event the event to multicast
|
||||||
* @param eventType the type of event (can be null)
|
* @param eventType the type of event (can be null)
|
||||||
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
void multicastEvent(ApplicationEvent event, ResolvableType eventType);
|
void multicastEvent(ApplicationEvent event, ResolvableType eventType);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -145,7 +145,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||||
if (CollectionUtils.isEmpty(annotatedMethods)) {
|
if (CollectionUtils.isEmpty(annotatedMethods)) {
|
||||||
this.nonAnnotatedClasses.add(targetType);
|
this.nonAnnotatedClasses.add(targetType);
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("No @EventListener annotations found on bean class: " + targetType);
|
logger.trace("No @EventListener annotations found on bean class: " + targetType.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -23,10 +23,10 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares that a field should be formatted as a date time.
|
* Declares that a field or method parameter should be formatted as a date or time.
|
||||||
*
|
*
|
||||||
* <p>Supports formatting by style pattern, ISO date time pattern, or custom format pattern string.
|
* <p>Supports formatting by style pattern, ISO date time pattern, or custom format pattern string.
|
||||||
* Can be applied to {@code java.util.Date}, {@code java.util.Calendar}, {@code java.long.Long},
|
* Can be applied to {@code java.util.Date}, {@code java.util.Calendar}, {@code java.lang.Long},
|
||||||
* Joda-Time value types; and as of Spring 4 and JDK 8, to JSR-310 <code>java.time</code> types too.
|
* Joda-Time value types; and as of Spring 4 and JDK 8, to JSR-310 <code>java.time</code> types too.
|
||||||
*
|
*
|
||||||
* <p>For style-based formatting, set the {@link #style} attribute to be the style pattern code.
|
* <p>For style-based formatting, set the {@link #style} attribute to be the style pattern code.
|
||||||
|
|
@ -35,7 +35,7 @@ import java.lang.annotation.Target;
|
||||||
* A date or time may be omitted by specifying the style character '-'.
|
* A date or time may be omitted by specifying the style character '-'.
|
||||||
*
|
*
|
||||||
* <p>For ISO-based formatting, set the {@link #iso} attribute to be the desired {@link ISO} format,
|
* <p>For ISO-based formatting, set the {@link #iso} attribute to be the desired {@link ISO} format,
|
||||||
* such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern()} attribute to be the
|
* such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern} attribute to be the
|
||||||
* DateTime pattern, such as {@code yyyy/MM/dd hh:mm:ss a}.
|
* DateTime pattern, such as {@code yyyy/MM/dd hh:mm:ss a}.
|
||||||
*
|
*
|
||||||
* <p>Each attribute is mutually exclusive, so only set one attribute per annotation instance
|
* <p>Each attribute is mutually exclusive, so only set one attribute per annotation instance
|
||||||
|
|
@ -64,7 +64,7 @@ public @interface DateTimeFormat {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ISO pattern to use to format the field.
|
* The ISO pattern to use to format the field.
|
||||||
* The possible ISO patterns are defined in the {@link ISO} enum.
|
* <p>The possible ISO patterns are defined in the {@link ISO} enum.
|
||||||
* <p>Defaults to {@link ISO#NONE}, indicating this attribute should be ignored.
|
* <p>Defaults to {@link ISO#NONE}, indicating this attribute should be ignored.
|
||||||
* Set this attribute when you wish to format your field in accordance with an ISO format.
|
* Set this attribute when you wish to format your field in accordance with an ISO format.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares that a field should be formatted as a number.
|
* Declares that a field or method parameter should be formatted as a number.
|
||||||
*
|
*
|
||||||
* <p>Supports formatting by style or custom pattern string.
|
* <p>Supports formatting by style or custom pattern string.
|
||||||
* Can be applied to any JDK {@code java.lang.Number} type.
|
* Can be applied to any JDK {@code java.lang.Number} type.
|
||||||
|
|
@ -37,7 +37,7 @@ import java.lang.annotation.Target;
|
||||||
* When the {@link #pattern} attribute is specified, it takes precedence over
|
* When the {@link #pattern} attribute is specified, it takes precedence over
|
||||||
* the {@link #style} attribute. When no annotation attributes are specified,
|
* the {@link #style} attribute. When no annotation attributes are specified,
|
||||||
* the default format applied is style-based for either number of currency,
|
* the default format applied is style-based for either number of currency,
|
||||||
* depending on the annotated field type.
|
* depending on the annotated field or method parameter type.
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Spring's repackaging of
|
* Spring's repackaging of
|
||||||
* <a href="http://asm.ow2.org">org.objectweb.asm 5.0</a>
|
* <a href="http://asm.ow2.org">ASM</a>
|
||||||
* (for internal use only).
|
* (for internal use only).
|
||||||
*
|
*
|
||||||
* <p>This repackaging technique avoids any potential conflicts with
|
* <p>This repackaging technique avoids any potential conflicts with
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
* libraries and frameworks.
|
* libraries and frameworks.
|
||||||
*
|
*
|
||||||
* <p>As this repackaging happens at the class file level, sources
|
* <p>As this repackaging happens at the class file level, sources
|
||||||
* and javadocs are not available here. See the original ObjectWeb
|
* and javadocs are not available here.
|
||||||
* <a href="http://asm.ow2.org/asm50/javadoc/user">ASM 5.0 javadocs</a>
|
|
||||||
* for details when working with these classes.
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.asm;
|
package org.springframework.asm;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Spring's repackaging of
|
* Spring's repackaging of
|
||||||
* <a href="http://cglib.sourceforge.net">net.sf.cglib 3.2</a>
|
* <a href="http://cglib.sourceforge.net">CGLIB</a>
|
||||||
* (for internal use only).
|
* (for internal use only).
|
||||||
*
|
*
|
||||||
* <p>This repackaging technique avoids any potential conflicts with
|
* <p>This repackaging technique avoids any potential conflicts with
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
* libraries and frameworks.
|
* libraries and frameworks.
|
||||||
*
|
*
|
||||||
* <p>As this repackaging happens at the class file level, sources
|
* <p>As this repackaging happens at the class file level, sources
|
||||||
* and javadocs are not available here. See the original
|
* and javadocs are not available here.
|
||||||
* <a href="http://cglib.sourceforge.net/apidocs">CGLIB 3.2 javadocs</a>
|
|
||||||
* for details when working with these classes.
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.cglib;
|
package org.springframework.cglib;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -57,7 +57,7 @@ final class CollectionToObjectConverter implements ConditionalGenericConverter {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
Collection<?> sourceCollection = (Collection<?>) source;
|
Collection<?> sourceCollection = (Collection<?>) source;
|
||||||
if (sourceCollection.size() == 0) {
|
if (sourceCollection.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Object firstElement = sourceCollection.iterator().next();
|
Object firstElement = sourceCollection.iterator().next();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -168,11 +168,11 @@ public abstract class ScriptUtils {
|
||||||
String blockCommentStartDelimiter, String blockCommentEndDelimiter, List<String> statements)
|
String blockCommentStartDelimiter, String blockCommentEndDelimiter, List<String> statements)
|
||||||
throws ScriptException {
|
throws ScriptException {
|
||||||
|
|
||||||
Assert.hasText(script, "script must not be null or empty");
|
Assert.hasText(script, "'script' must not be null or empty");
|
||||||
Assert.notNull(separator, "separator must not be null");
|
Assert.notNull(separator, "'separator' must not be null");
|
||||||
Assert.hasText(commentPrefix, "commentPrefix must not be null or empty");
|
Assert.hasText(commentPrefix, "'commentPrefix' must not be null or empty");
|
||||||
Assert.hasText(blockCommentStartDelimiter, "blockCommentStartDelimiter must not be null or empty");
|
Assert.hasText(blockCommentStartDelimiter, "'blockCommentStartDelimiter' must not be null or empty");
|
||||||
Assert.hasText(blockCommentEndDelimiter, "blockCommentEndDelimiter must not be null or empty");
|
Assert.hasText(blockCommentEndDelimiter, "'blockCommentEndDelimiter' must not be null or empty");
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
boolean inSingleQuote = false;
|
boolean inSingleQuote = false;
|
||||||
|
|
@ -199,7 +199,7 @@ public abstract class ScriptUtils {
|
||||||
}
|
}
|
||||||
if (!inSingleQuote && !inDoubleQuote) {
|
if (!inSingleQuote && !inDoubleQuote) {
|
||||||
if (script.startsWith(separator, i)) {
|
if (script.startsWith(separator, i)) {
|
||||||
// we've reached the end of the current statement
|
// We've reached the end of the current statement
|
||||||
if (sb.length() > 0) {
|
if (sb.length() > 0) {
|
||||||
statements.add(sb.toString());
|
statements.add(sb.toString());
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
|
|
@ -208,32 +208,31 @@ public abstract class ScriptUtils {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (script.startsWith(commentPrefix, i)) {
|
else if (script.startsWith(commentPrefix, i)) {
|
||||||
// skip over any content from the start of the comment to the EOL
|
// Skip over any content from the start of the comment to the EOL
|
||||||
int indexOfNextNewline = script.indexOf("\n", i);
|
int indexOfNextNewline = script.indexOf("\n", i);
|
||||||
if (indexOfNextNewline > i) {
|
if (indexOfNextNewline > i) {
|
||||||
i = indexOfNextNewline;
|
i = indexOfNextNewline;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if there's no EOL, we must be at the end
|
// If there's no EOL, we must be at the end of the script, so stop here.
|
||||||
// of the script, so stop here.
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (script.startsWith(blockCommentStartDelimiter, i)) {
|
else if (script.startsWith(blockCommentStartDelimiter, i)) {
|
||||||
// skip over any block comments
|
// Skip over any block comments
|
||||||
int indexOfCommentEnd = script.indexOf(blockCommentEndDelimiter, i);
|
int indexOfCommentEnd = script.indexOf(blockCommentEndDelimiter, i);
|
||||||
if (indexOfCommentEnd > i) {
|
if (indexOfCommentEnd > i) {
|
||||||
i = indexOfCommentEnd + blockCommentEndDelimiter.length() - 1;
|
i = indexOfCommentEnd + blockCommentEndDelimiter.length() - 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new ScriptParseException(String.format("Missing block comment end delimiter [%s].",
|
throw new ScriptParseException(
|
||||||
blockCommentEndDelimiter), resource);
|
"Missing block comment end delimiter: " + blockCommentEndDelimiter, resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (c == ' ' || c == '\n' || c == '\t') {
|
else if (c == ' ' || c == '\n' || c == '\t') {
|
||||||
// avoid multiple adjacent whitespace characters
|
// Avoid multiple adjacent whitespace characters
|
||||||
if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ') {
|
if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ') {
|
||||||
c = ' ';
|
c = ' ';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -395,12 +395,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
* or a newly built {@link HttpEntity} wrapper for that part
|
* or a newly built {@link HttpEntity} wrapper for that part
|
||||||
*/
|
*/
|
||||||
protected HttpEntity<?> getHttpEntity(Object part) {
|
protected HttpEntity<?> getHttpEntity(Object part) {
|
||||||
if (part instanceof HttpEntity) {
|
return (part instanceof HttpEntity ? (HttpEntity<?>) part : new HttpEntity<Object>(part));
|
||||||
return (HttpEntity<?>) part;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new HttpEntity<Object>(part);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -415,7 +410,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
if (part instanceof Resource) {
|
if (part instanceof Resource) {
|
||||||
Resource resource = (Resource) part;
|
Resource resource = (Resource) part;
|
||||||
String filename = resource.getFilename();
|
String filename = resource.getFilename();
|
||||||
if (this.multipartCharset != null) {
|
if (filename != null && this.multipartCharset != null) {
|
||||||
filename = MimeDelegate.encode(filename, this.multipartCharset.name());
|
filename = MimeDelegate.encode(filename, this.multipartCharset.name());
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -67,14 +67,14 @@ public interface GenericHttpMessageConverter<T> extends HttpMessageConverter<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the given class can be written by this converter.
|
* Indicates whether the given class can be written by this converter.
|
||||||
* This method should perform the same checks than
|
* <p>This method should perform the same checks than
|
||||||
* {@link HttpMessageConverter#canWrite(Class, MediaType)} with additional ones
|
* {@link HttpMessageConverter#canWrite(Class, MediaType)} with additional ones
|
||||||
* related to the generic type.
|
* related to the generic type.
|
||||||
* @param type the (potentially generic) type to test for writability, can be
|
* @param type the (potentially generic) type to test for writability
|
||||||
* {@code null} if not specified.
|
* (can be {@code null} if not specified)
|
||||||
* @param clazz the source object class to test for writability
|
* @param clazz the source object class to test for writability
|
||||||
* @param mediaType the media type to write, can be {@code null} if not specified.
|
* @param mediaType the media type to write (can be {@code null} if not specified);
|
||||||
* Typically the value of an {@code Accept} header.
|
* typically the value of an {@code Accept} header.
|
||||||
* @return {@code true} if writable; {@code false} otherwise
|
* @return {@code true} if writable; {@code false} otherwise
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -35,8 +35,8 @@ public interface HttpMessageConverter<T> {
|
||||||
/**
|
/**
|
||||||
* Indicates whether the given class can be read by this converter.
|
* Indicates whether the given class can be read by this converter.
|
||||||
* @param clazz the class to test for readability
|
* @param clazz the class to test for readability
|
||||||
* @param mediaType the media type to read, can be {@code null} if not specified.
|
* @param mediaType the media type to read (can be {@code null} if not specified);
|
||||||
* Typically the value of a {@code Content-Type} header.
|
* typically the value of a {@code Content-Type} header.
|
||||||
* @return {@code true} if readable; {@code false} otherwise
|
* @return {@code true} if readable; {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
boolean canRead(Class<?> clazz, MediaType mediaType);
|
boolean canRead(Class<?> clazz, MediaType mediaType);
|
||||||
|
|
@ -44,8 +44,8 @@ public interface HttpMessageConverter<T> {
|
||||||
/**
|
/**
|
||||||
* Indicates whether the given class can be written by this converter.
|
* Indicates whether the given class can be written by this converter.
|
||||||
* @param clazz the class to test for writability
|
* @param clazz the class to test for writability
|
||||||
* @param mediaType the media type to write, can be {@code null} if not specified.
|
* @param mediaType the media type to write (can be {@code null} if not specified);
|
||||||
* Typically the value of an {@code Accept} header.
|
* typically the value of an {@code Accept} header.
|
||||||
* @return {@code true} if writable; {@code false} otherwise
|
* @return {@code true} if writable; {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
boolean canWrite(Class<?> clazz, MediaType mediaType);
|
boolean canWrite(Class<?> clazz, MediaType mediaType);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2017 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 com.google.gson.GsonBuilder;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link FactoryBean} for creating a Google Gson 2.x {@link Gson} instance.
|
* A {@link FactoryBean} for creating a Google Gson 2.x {@link Gson} instance.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -187,10 +187,9 @@ public class Jaxb2CollectionHttpMessageConverter<T extends Collection>
|
||||||
try {
|
try {
|
||||||
return (T) collectionClass.newInstance();
|
return (T) collectionClass.newInstance();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Throwable ex) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Could not instantiate collection class [" +
|
"Could not instantiate collection class: " + collectionClass.getName(), ex);
|
||||||
collectionClass.getName() + "]: " + ex.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (List.class == collectionClass) {
|
else if (List.class == collectionClass) {
|
||||||
|
|
@ -230,6 +229,7 @@ public class Jaxb2CollectionHttpMessageConverter<T extends Collection>
|
||||||
@Override
|
@Override
|
||||||
public void write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage)
|
public void write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage)
|
||||||
throws IOException, HttpMessageNotWritableException {
|
throws IOException, HttpMessageNotWritableException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -71,6 +71,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
private final UrlPathHelper pathHelper;
|
private final UrlPathHelper pathHelper;
|
||||||
|
|
||||||
|
|
||||||
public ForwardedHeaderFilter() {
|
public ForwardedHeaderFilter() {
|
||||||
this.pathHelper = new UrlPathHelper();
|
this.pathHelper = new UrlPathHelper();
|
||||||
this.pathHelper.setUrlDecode(false);
|
this.pathHelper.setUrlDecode(false);
|
||||||
|
|
@ -143,8 +144,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
|
||||||
String prefix = getForwardedPrefix(request);
|
String prefix = getForwardedPrefix(request);
|
||||||
this.contextPath = (prefix != null ? prefix : request.getContextPath());
|
this.contextPath = (prefix != null ? prefix : request.getContextPath());
|
||||||
this.requestUri = this.contextPath + pathHelper.getPathWithinApplication(request);
|
this.requestUri = this.contextPath + pathHelper.getPathWithinApplication(request);
|
||||||
this.requestUrl = this.scheme + "://" + this.host +
|
this.requestUrl = this.scheme + "://" + this.host + (port == -1 ? "" : ":" + port) + this.requestUri;
|
||||||
(port == -1 ? "" : ":" + port) + this.requestUri;
|
|
||||||
this.headers = initHeaders(request);
|
this.headers = initHeaders(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,13 +235,13 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ForwardedHeaderResponseWrapper extends HttpServletResponseWrapper {
|
private static class ForwardedHeaderResponseWrapper extends HttpServletResponseWrapper {
|
||||||
|
|
||||||
private static final String FOLDER_SEPARATOR = "/";
|
private static final String FOLDER_SEPARATOR = "/";
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
private final HttpServletRequest request;
|
||||||
|
|
||||||
|
|
||||||
public ForwardedHeaderResponseWrapper(HttpServletResponse response, HttpServletRequest request) {
|
public ForwardedHeaderResponseWrapper(HttpServletResponse response, HttpServletRequest request) {
|
||||||
super(response);
|
super(response);
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
|
@ -249,7 +249,6 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendRedirect(String location) throws IOException {
|
public void sendRedirect(String location) throws IOException {
|
||||||
|
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location);
|
||||||
|
|
||||||
// Absolute location
|
// Absolute location
|
||||||
|
|
@ -259,20 +258,15 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network-path reference
|
// Network-path reference
|
||||||
if(location.startsWith("//")) {
|
if (location.startsWith("//")) {
|
||||||
String scheme = this.request.getScheme();
|
String scheme = this.request.getScheme();
|
||||||
super.sendRedirect(builder.scheme(scheme).toUriString());
|
super.sendRedirect(builder.scheme(scheme).toUriString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relative to Servlet container root or to current request
|
// Relative to Servlet container root or to current request
|
||||||
String path;
|
String path = (location.startsWith(FOLDER_SEPARATOR) ? location :
|
||||||
if (location.startsWith(FOLDER_SEPARATOR)) {
|
StringUtils.applyRelativePath(this.request.getRequestURI(), location));
|
||||||
path = location;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
path = StringUtils.applyRelativePath(this.request.getRequestURI(), location);
|
|
||||||
}
|
|
||||||
|
|
||||||
String result = UriComponentsBuilder
|
String result = UriComponentsBuilder
|
||||||
.fromHttpRequest(new ServletServerHttpRequest(this.request))
|
.fromHttpRequest(new ServletServerHttpRequest(this.request))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -99,7 +99,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||||
assertEquals("Foo", result.get("string"));
|
assertEquals("Foo", result.get("string"));
|
||||||
assertEquals(42, result.get("number"));
|
assertEquals(42, result.get("number"));
|
||||||
assertEquals(42D, (Double) result.get("fraction"), 0D);
|
assertEquals(42D, (Double) result.get("fraction"), 0D);
|
||||||
List<String> array = new ArrayList<String>();
|
List<String> array = new ArrayList<>();
|
||||||
array.add("Foo");
|
array.add("Foo");
|
||||||
array.add("Bar");
|
array.add("Bar");
|
||||||
assertEquals(array, result.get("array"));
|
assertEquals(array, result.get("array"));
|
||||||
|
|
@ -162,7 +162,6 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void readGenerics() throws IOException {
|
public void readGenerics() throws IOException {
|
||||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter() {
|
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JavaType getJavaType(Type type, Class<?> contextClass) {
|
protected JavaType getJavaType(Type type, Class<?> contextClass) {
|
||||||
if (type instanceof Class && List.class.isAssignableFrom((Class<?>)type)) {
|
if (type instanceof Class && List.class.isAssignableFrom((Class<?>)type)) {
|
||||||
|
|
@ -451,9 +450,9 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private interface MyJacksonView1 {};
|
private interface MyJacksonView1 {}
|
||||||
|
|
||||||
private interface MyJacksonView2 {};
|
private interface MyJacksonView2 {}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -89,7 +89,7 @@ public class ModelAndView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new ModelAndView given a view name and a model.
|
* Create a new ModelAndView given a view name and a model.
|
||||||
* @param viewName name of the View to render, to be resolved
|
* @param viewName name of the View to render, to be resolved
|
||||||
* by the DispatcherServlet's ViewResolver
|
* by the DispatcherServlet's ViewResolver
|
||||||
* @param model Map of model names (Strings) to model objects
|
* @param model Map of model names (Strings) to model objects
|
||||||
|
|
@ -104,7 +104,7 @@ public class ModelAndView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new ModelAndView given a View object and a model.
|
* Create a new ModelAndView given a View object and a model.
|
||||||
* <emphasis>Note: the supplied model data is copied into the internal
|
* <emphasis>Note: the supplied model data is copied into the internal
|
||||||
* storage of this class. You should not consider to modify the supplied
|
* storage of this class. You should not consider to modify the supplied
|
||||||
* Map after supplying it to this class</emphasis>
|
* Map after supplying it to this class</emphasis>
|
||||||
|
|
@ -121,14 +121,27 @@ public class ModelAndView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new ModelAndView given a view name, model, and status.
|
* Create a new ModelAndView given a view name and HTTP status.
|
||||||
|
* @param viewName name of the View to render, to be resolved
|
||||||
|
* by the DispatcherServlet's ViewResolver
|
||||||
|
* @param status an HTTP status code to use for the response
|
||||||
|
* (to be set just prior to View rendering)
|
||||||
|
* @since 4.3.8
|
||||||
|
*/
|
||||||
|
public ModelAndView(String viewName, HttpStatus status) {
|
||||||
|
this.view = viewName;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ModelAndView given a view name, model, and HTTP status.
|
||||||
* @param viewName name of the View to render, to be resolved
|
* @param viewName name of the View to render, to be resolved
|
||||||
* by the DispatcherServlet's ViewResolver
|
* by the DispatcherServlet's ViewResolver
|
||||||
* @param model Map of model names (Strings) to model objects
|
* @param model Map of model names (Strings) to model objects
|
||||||
* (Objects). Model entries may not be {@code null}, but the
|
* (Objects). Model entries may not be {@code null}, but the
|
||||||
* model Map may be {@code null} if there is no model data.
|
* model Map may be {@code null} if there is no model data.
|
||||||
* @param status an alternative status code to use for the response;
|
* @param status an HTTP status code to use for the response
|
||||||
* The response status is set just prior to View rendering.
|
* (to be set just prior to View rendering)
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public ModelAndView(String viewName, Map<String, ?> model, HttpStatus status) {
|
public ModelAndView(String viewName, Map<String, ?> model, HttpStatus status) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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,6 +13,7 @@
|
||||||
* 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.mvc.method.annotation;
|
package org.springframework.web.servlet.mvc.method.annotation;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -34,13 +35,11 @@ import org.springframework.web.context.request.async.StandardServletAsyncWebRequ
|
||||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link DeferredResultMethodReturnValueHandler}.
|
* Unit tests for {@link DeferredResultMethodReturnValueHandler}.
|
||||||
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
*/
|
*/
|
||||||
public class DeferredResultReturnValueHandlerTests {
|
public class DeferredResultReturnValueHandlerTests {
|
||||||
|
|
@ -53,7 +52,7 @@ public class DeferredResultReturnValueHandlerTests {
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setup() throws Exception {
|
||||||
this.handler = new DeferredResultMethodReturnValueHandler();
|
this.handler = new DeferredResultMethodReturnValueHandler();
|
||||||
this.request = new MockHttpServletRequest();
|
this.request = new MockHttpServletRequest();
|
||||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue