Polishing (backported from master)
This commit is contained in:
parent
16d5ba9b3a
commit
92d78c10a2
|
@ -879,10 +879,10 @@ project("spring-webmvc") {
|
|||
testCompile("commons-io:commons-io:1.3")
|
||||
testCompile("joda-time:joda-time:${jodaVersion}")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
testCompile("org.jruby:jruby:${jrubyVersion}")
|
||||
testCompile("org.python:jython-standalone:2.5.3")
|
||||
testCompile("org.mozilla:rhino:1.7.7.1")
|
||||
testCompile("org.webjars:underscorejs:1.8.3")
|
||||
testRuntime("org.jruby:jruby:${jrubyVersion}")
|
||||
testRuntime("org.python:jython-standalone:2.5.3")
|
||||
testRuntime("org.webjars:underscorejs:1.8.3")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface MethodInterceptor extends Interceptor {
|
|||
* after the invocation. Polite implementations would certainly
|
||||
* like to invoke {@link Joinpoint#proceed()}.
|
||||
* @param invocation the method invocation joinpoint
|
||||
* @return the result of the call to {@link Joinpoint#proceed();
|
||||
* @return the result of the call to {@link Joinpoint#proceed()};
|
||||
* might be intercepted by the interceptor
|
||||
* @throws Throwable if the interceptors or the target object
|
||||
* throws an exception
|
||||
|
|
|
@ -269,7 +269,7 @@ class TypeConverterDelegate {
|
|||
}
|
||||
else {
|
||||
// convertedValue == null
|
||||
if (javaUtilOptionalEmpty != null && requiredType.equals(javaUtilOptionalEmpty.getClass())) {
|
||||
if (javaUtilOptionalEmpty != null && requiredType == javaUtilOptionalEmpty.getClass()) {
|
||||
convertedValue = javaUtilOptionalEmpty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1002,7 +1002,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
|||
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException {
|
||||
|
||||
descriptor.initParameterNameDiscovery(getParameterNameDiscoverer());
|
||||
if (descriptor.getDependencyType().equals(javaUtilOptionalClass)) {
|
||||
if (javaUtilOptionalClass == descriptor.getDependencyType()) {
|
||||
return new OptionalDependencyFactory().createOptionalDependency(descriptor, beanName);
|
||||
}
|
||||
else if (ObjectFactory.class == descriptor.getDependencyType() ||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -125,7 +125,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
|||
setBeanClass(beanClass);
|
||||
setAutowireMode(autowireMode);
|
||||
if (dependencyCheck && getResolvedAutowireMode() != AUTOWIRE_CONSTRUCTOR) {
|
||||
setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
|
||||
setDependencyCheck(DEPENDENCY_CHECK_OBJECTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
* <p>Note: EhCache 3.x lives in a different package namespace
|
||||
* and is not covered by the traditional support classes here.
|
||||
* Instead, consider using it through JCache (JSR-107), with
|
||||
* Spring's support in {@link org.springframework.cache.jcache}.
|
||||
* Spring's support in {@code org.springframework.cache.jcache}.
|
||||
*/
|
||||
package org.springframework.cache.ehcache;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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 CachingConfigurationSelector extends AdviceModeImportSelector<Enabl
|
|||
private static final boolean jsr107Present = ClassUtils.isPresent(
|
||||
"javax.cache.Cache", CachingConfigurationSelector.class.getClassLoader());
|
||||
|
||||
private static final boolean jCacheImplPresent = ClassUtils.isPresent(
|
||||
private static final boolean jcacheImplPresent = ClassUtils.isPresent(
|
||||
PROXY_JCACHE_CONFIGURATION_CLASS, CachingConfigurationSelector.class.getClassLoader());
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector<Enabl
|
|||
List<String> result = new ArrayList<String>();
|
||||
result.add(AutoProxyRegistrar.class.getName());
|
||||
result.add(ProxyCachingConfiguration.class.getName());
|
||||
if (jsr107Present && jCacheImplPresent) {
|
||||
if (jsr107Present && jcacheImplPresent) {
|
||||
result.add(PROXY_JCACHE_CONFIGURATION_CLASS);
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
|
@ -94,7 +94,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector<Enabl
|
|||
private String[] getAspectJImports() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
result.add(CACHE_ASPECT_CONFIGURATION_CLASS_NAME);
|
||||
if (jsr107Present && jCacheImplPresent) {
|
||||
if (jsr107Present && jcacheImplPresent) {
|
||||
result.add(JCACHE_ASPECT_CONFIGURATION_CLASS_NAME);
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -60,11 +60,10 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
|||
private static final String JCACHE_ASPECT_CLASS_NAME =
|
||||
"org.springframework.cache.aspectj.JCacheCacheAspect";
|
||||
|
||||
|
||||
private static final boolean jsr107Present = ClassUtils.isPresent(
|
||||
"javax.cache.Cache", AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
private static final boolean jCacheImplPresent = ClassUtils.isPresent(
|
||||
private static final boolean jcacheImplPresent = ClassUtils.isPresent(
|
||||
"org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource",
|
||||
AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
|
@ -91,7 +90,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
|||
|
||||
private void registerCacheAspect(Element element, ParserContext parserContext) {
|
||||
SpringCachingConfigurer.registerCacheAspect(element, parserContext);
|
||||
if (jsr107Present && jCacheImplPresent) { // Register JCache aspect
|
||||
if (jsr107Present && jcacheImplPresent) {
|
||||
JCacheCachingConfigurer.registerCacheAspect(element, parserContext);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +98,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
|||
private void registerCacheAdvisor(Element element, ParserContext parserContext) {
|
||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
|
||||
SpringCachingConfigurer.registerCacheAdvisor(element, parserContext);
|
||||
if (jsr107Present && jCacheImplPresent) { // Register JCache advisor
|
||||
if (jsr107Present && jcacheImplPresent) {
|
||||
JCacheCachingConfigurer.registerCacheAdvisor(element, parserContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,8 @@ package org.springframework.cache.interceptor;
|
|||
public interface CacheOperationInvoker {
|
||||
|
||||
/**
|
||||
* Invoke the cache operation defined by this instance. Wraps any
|
||||
* exception that is thrown during the invocation in a
|
||||
* {@link ThrowableWrapper}.
|
||||
* Invoke the cache operation defined by this instance. Wraps any exception
|
||||
* that is thrown during the invocation in a {@link ThrowableWrapper}.
|
||||
* @return the result of the operation
|
||||
* @throws ThrowableWrapper if an error occurred while invoking the operation
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -127,15 +127,13 @@ public class AnnotatedBeanDefinitionReader {
|
|||
registerBean(annotatedClass, null, (Class<? extends Annotation>[]) null);
|
||||
}
|
||||
|
||||
public void registerBean(Class<?> annotatedClass,
|
||||
@SuppressWarnings("unchecked") Class<? extends Annotation>... qualifiers) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void registerBean(Class<?> annotatedClass, Class<? extends Annotation>... qualifiers) {
|
||||
registerBean(annotatedClass, null, qualifiers);
|
||||
}
|
||||
|
||||
public void registerBean(Class<?> annotatedClass, String name,
|
||||
@SuppressWarnings("unchecked") Class<? extends Annotation>... qualifiers) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
|
||||
AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
|
||||
if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) {
|
||||
return;
|
||||
|
|
|
@ -466,7 +466,7 @@ public class GroovyScriptFactoryTests {
|
|||
@Test // SPR-6268
|
||||
public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("jruby-with-xsd-proxy-target-class.xml", getClass());
|
||||
new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", getClass());
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
assertTrue(ex.getMessage().contains("Cannot use proxyTargetClass=true"));
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">
|
||||
|
||||
<lang:defaults proxy-target-class="true"/>
|
||||
|
||||
<lang:jruby id="refreshableMessenger" refresh-check-delay="1000"
|
||||
script-source="classpath:org/springframework/scripting/jruby/Messenger.rb"
|
||||
script-interfaces="org.springframework.scripting.Messenger">
|
||||
<lang:property name="message" value="Hello World!"/>
|
||||
</lang:jruby>
|
||||
|
||||
</beans>
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -85,10 +85,9 @@ public abstract class MethodIntrospector {
|
|||
|
||||
/**
|
||||
* Select methods on the given target type based on a filter.
|
||||
* <p>Callers define methods of interest through the
|
||||
* {@link ReflectionUtils.MethodFilter} parameter.
|
||||
* <p>Callers define methods of interest through the {@code MethodFilter} parameter.
|
||||
* @param targetType the target type to search methods on
|
||||
* @param methodFilter a {@link ReflectionUtils.MethodFilter} to help
|
||||
* @param methodFilter a {@code MethodFilter} to help
|
||||
* recognize handler methods of interest
|
||||
* @return the selected methods, or an empty set in case of no match
|
||||
*/
|
||||
|
|
|
@ -343,7 +343,7 @@ public class TypeDescriptor implements Serializable {
|
|||
if (streamAvailable && StreamDelegate.isStream(this.type)) {
|
||||
return StreamDelegate.getStreamElementType(this);
|
||||
}
|
||||
return getRelatedIfResolvable(this, this.resolvableType.asCollection().getGeneric());
|
||||
return getRelatedIfResolvable(this, this.resolvableType.asCollection().getGeneric(0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -706,7 +706,7 @@ public class TypeDescriptor implements Serializable {
|
|||
}
|
||||
|
||||
public static TypeDescriptor getStreamElementType(TypeDescriptor source) {
|
||||
return getRelatedIfResolvable(source, source.resolvableType.as(Stream.class).getGeneric());
|
||||
return getRelatedIfResolvable(source, source.resolvableType.as(Stream.class).getGeneric(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ import org.springframework.lang.UsesJava8;
|
|||
* Codec present, {@link #encode}/{@link #decode} calls will throw an IllegalStateException.
|
||||
* However, as of Spring 4.2, {@link #encodeToString} and {@link #decodeFromString} will
|
||||
* nevertheless work since they can delegate to the JAXB DatatypeConverter as a fallback.
|
||||
* However, this does not apply when using the ...UrlSafe... methods for RFC 4648 "URL and
|
||||
* However, this does not apply when using the "UrlSafe" methods for RFC 4648 "URL and
|
||||
* Filename Safe Alphabet"; a delegate is required.
|
||||
* <p>
|
||||
* <em>Note:</em> Apache Commons Codec does not add padding ({@code =}) when encoding with
|
||||
* the URL and Filename Safe Alphabet.
|
||||
*
|
||||
* <p><em>Note:</em> Apache Commons Codec does not add padding ({@code =}) when encoding
|
||||
* with the URL and Filename Safe Alphabet.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Gary Russell
|
||||
|
|
|
@ -24,13 +24,12 @@ import java.security.NoSuchAlgorithmException;
|
|||
/**
|
||||
* Miscellaneous methods for calculating digests.
|
||||
* <p>Mainly for internal use within the framework; consider
|
||||
* <a href="http://commons.apache.org/codec/">Apache Commons Codec</a> for a
|
||||
* more comprehensive suite of digest utilities.
|
||||
* <a href="http://commons.apache.org/codec/">Apache Commons Codec</a>
|
||||
* for a more comprehensive suite of digest utilities.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Craig Andrews
|
||||
* @since 3.0
|
||||
* @see org.apache.commons.codec.digest.DigestUtils
|
||||
*/
|
||||
public abstract class DigestUtils {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
|
|||
* Update the message digest with the rest of the bytes in this stream.
|
||||
* <p>Using this method is more optimized since it avoids creating new
|
||||
* byte arrays for each call.
|
||||
* @param messageDigest The message digest to update
|
||||
* @param messageDigest the message digest to update
|
||||
* @throws IOException when propagated from {@link #read()}
|
||||
*/
|
||||
public void updateMessageDigest(MessageDigest messageDigest) throws IOException {
|
||||
|
@ -47,7 +47,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
|
|||
* Update the message digest with the next len bytes in this stream.
|
||||
* <p>Using this method is more optimized since it avoids creating new
|
||||
* byte arrays for each call.
|
||||
* @param messageDigest The message digest to update
|
||||
* @param messageDigest the message digest to update
|
||||
* @param len how many bytes to read from this stream and use to update the message digest
|
||||
* @throws IOException when propagated from {@link #read()}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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 java.util.function.BiFunction;
|
|||
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
|
||||
/**
|
||||
* Adapts a {@link CompletableFuture} into a {@link ListenableFuture}.
|
||||
*
|
||||
|
@ -38,6 +37,7 @@ public class CompletableToListenableFutureAdapter<T> implements ListenableFuture
|
|||
|
||||
private final ListenableFutureCallbackRegistry<T> callbacks = new ListenableFutureCallbackRegistry<T>();
|
||||
|
||||
|
||||
public CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture) {
|
||||
this.completableFuture = completableFuture;
|
||||
this.completableFuture.handle(new BiFunction<T, Throwable, Object>() {
|
||||
|
@ -54,6 +54,7 @@ public class CompletableToListenableFutureAdapter<T> implements ListenableFuture
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addCallback(ListenableFutureCallback<? super T> callback) {
|
||||
this.callbacks.addCallback(callback);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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,10 +24,9 @@ import java.util.concurrent.TimeoutException;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract class that adapts a {@link Future} parameterized over S into a {@code
|
||||
* Future} parameterized over T. All methods are delegated to the adaptee, where {@link
|
||||
* #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's
|
||||
* result.
|
||||
* Abstract class that adapts a {@link Future} parameterized over S into a {@code Future}
|
||||
* parameterized over T. All methods are delegated to the adaptee, where {@link #get()}
|
||||
* and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's result.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 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,13 +30,15 @@ import static org.hamcrest.CoreMatchers.*;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractPropertySource} implementations.
|
||||
* Unit tests for {@link PropertySource} implementations.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
*/
|
||||
public class PropertySourceTests {
|
||||
@Test @SuppressWarnings("serial")
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void equals() {
|
||||
Map<String, Object> map1 = new HashMap<String, Object>() {{ put("a", "b"); }};
|
||||
Map<String, Object> map2 = new HashMap<String, Object>() {{ put("c", "d"); }};
|
||||
|
@ -59,14 +61,15 @@ public class PropertySourceTests {
|
|||
assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props2)), is(false));
|
||||
}
|
||||
|
||||
@Test @SuppressWarnings("serial")
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void collectionsOperations() {
|
||||
Map<String, Object> map1 = new HashMap<String, Object>() {{ put("a", "b"); }};
|
||||
Map<String, Object> map2 = new HashMap<String, Object>() {{ put("c", "d"); }};
|
||||
|
||||
PropertySource<?> ps1 = new MapPropertySource("ps1", map1);
|
||||
ps1.getSource();
|
||||
List<PropertySource<?>> propertySources = new ArrayList<PropertySource<?>>();
|
||||
List<PropertySource<?>> propertySources = new ArrayList<>();
|
||||
assertThat(propertySources.add(ps1), equalTo(true));
|
||||
assertThat(propertySources.contains(ps1), is(true));
|
||||
assertThat(propertySources.contains(PropertySource.named("ps1")), is(true));
|
||||
|
@ -116,4 +119,5 @@ public class PropertySourceTests {
|
|||
logger.setLevel(original);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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,72 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the main expression evaluation method has been generated, this
|
||||
* method will callback any registered FieldAdders or ClinitAdders to add any
|
||||
* extra information to the class representing the compiled expression.
|
||||
*/
|
||||
public void finish() {
|
||||
if (this.fieldAdders != null) {
|
||||
for (FieldAdder fieldAdder : this.fieldAdders) {
|
||||
fieldAdder.generateField(cw,this);
|
||||
}
|
||||
}
|
||||
if (this.clinitAdders != null) {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
mv.visitCode();
|
||||
this.nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit
|
||||
for (ClinitAdder clinitAdder : this.clinitAdders) {
|
||||
clinitAdder.generateCode(mv, this);
|
||||
}
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS
|
||||
mv.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a FieldAdder which will add a new field to the generated
|
||||
* class to support the code produced by an ast nodes primary
|
||||
* generateCode() method.
|
||||
*/
|
||||
public void registerNewField(FieldAdder fieldAdder) {
|
||||
if (this.fieldAdders == null) {
|
||||
this.fieldAdders = new ArrayList<FieldAdder>();
|
||||
}
|
||||
this.fieldAdders.add(fieldAdder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ClinitAdder which will add code to the static
|
||||
* initializer in the generated class to support the code
|
||||
* produced by an ast nodes primary generateCode() method.
|
||||
*/
|
||||
public void registerNewClinit(ClinitAdder clinitAdder) {
|
||||
if (this.clinitAdders == null) {
|
||||
this.clinitAdders = new ArrayList<ClinitAdder>();
|
||||
}
|
||||
this.clinitAdders.add(clinitAdder);
|
||||
}
|
||||
|
||||
public int nextFieldId() {
|
||||
return this.nextFieldId++;
|
||||
}
|
||||
|
||||
public int nextFreeVariableId() {
|
||||
return this.nextFreeVariableId++;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return this.clazzName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getClassname() {
|
||||
return this.clazzName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert any necessary cast and value call to convert from a boxed type to a
|
||||
* primitive value
|
||||
|
@ -778,74 +844,6 @@ public class CodeFlow implements Opcodes {
|
|||
return descriptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the main expression evaluation method has been generated, this
|
||||
* method will callback any registered FieldAdders or ClinitAdders to add any
|
||||
* extra information to the class representing the compiled expression.
|
||||
*/
|
||||
public void finish() {
|
||||
if (fieldAdders != null) {
|
||||
for (FieldAdder fieldAdder: fieldAdders) {
|
||||
fieldAdder.generateField(cw,this);
|
||||
}
|
||||
}
|
||||
if (clinitAdders != null) {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
mv.visitCode();
|
||||
nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit
|
||||
for (ClinitAdder clinitAdder: clinitAdders) {
|
||||
clinitAdder.generateCode(mv, this);
|
||||
}
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS
|
||||
mv.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a FieldAdder which will add a new field to the generated
|
||||
* class to support the code produced by an ast nodes primary
|
||||
* generateCode() method.
|
||||
*/
|
||||
public void registerNewField(FieldAdder fieldAdder) {
|
||||
if (fieldAdders == null) {
|
||||
fieldAdders = new ArrayList<FieldAdder>();
|
||||
}
|
||||
fieldAdders.add(fieldAdder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ClinitAdder which will add code to the static
|
||||
* initializer in the generated class to support the code
|
||||
* produced by an ast nodes primary generateCode() method.
|
||||
*/
|
||||
public void registerNewClinit(ClinitAdder clinitAdder) {
|
||||
if (clinitAdders == null) {
|
||||
clinitAdders = new ArrayList<ClinitAdder>();
|
||||
}
|
||||
clinitAdders.add(clinitAdder);
|
||||
}
|
||||
|
||||
public int nextFieldId() {
|
||||
return nextFieldId++;
|
||||
}
|
||||
|
||||
public int nextFreeVariableId() {
|
||||
return nextFreeVariableId++;
|
||||
}
|
||||
|
||||
public String getClassname() {
|
||||
return clazzName;
|
||||
}
|
||||
|
||||
public interface FieldAdder {
|
||||
public void generateField(ClassWriter cw, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
public interface ClinitAdder {
|
||||
public void generateCode(MethodVisitor mv, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the optimal instruction for loading a number on the stack.
|
||||
* @param mv where to insert the bytecode
|
||||
|
@ -977,4 +975,15 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
|
||||
|
||||
public interface FieldAdder {
|
||||
|
||||
void generateField(ClassWriter cw, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
|
||||
public interface ClinitAdder {
|
||||
|
||||
void generateCode(MethodVisitor mv, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -132,8 +132,8 @@ public class InlineList extends SpelNodeImpl {
|
|||
|
||||
@Override
|
||||
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
|
||||
final String constantFieldName = "inlineList$"+codeflow.nextFieldId();
|
||||
final String clazzname = codeflow.getClassname();
|
||||
final String constantFieldName = "inlineList$" + codeflow.nextFieldId();
|
||||
final String className = codeflow.getClassName();
|
||||
|
||||
codeflow.registerNewField(new CodeFlow.FieldAdder() {
|
||||
public void generateField(ClassWriter cw, CodeFlow codeflow) {
|
||||
|
@ -143,11 +143,11 @@ public class InlineList extends SpelNodeImpl {
|
|||
|
||||
codeflow.registerNewClinit(new CodeFlow.ClinitAdder() {
|
||||
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
|
||||
generateClinitCode(clazzname,constantFieldName, mv,codeflow,false);
|
||||
generateClinitCode(className, constantFieldName, mv, codeflow, false);
|
||||
}
|
||||
});
|
||||
|
||||
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
|
||||
mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;");
|
||||
codeflow.pushDescriptor("Ljava/util/List");
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,8 @@ public class InlineList extends SpelNodeImpl {
|
|||
if (!nested) {
|
||||
mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
|
||||
}
|
||||
int childcount = getChildCount();
|
||||
for (int c=0; c < childcount; c++) {
|
||||
int childCount = getChildCount();
|
||||
for (int c = 0; c < childCount; c++) {
|
||||
if (!nested) {
|
||||
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -542,6 +542,7 @@ public abstract class AbstractJdbcInsert {
|
|||
* @param batch array of Maps with parameter names and values to be used in batch insert
|
||||
* @return array of number of rows affected
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected int[] doExecuteBatch(Map<String, ?>... batch) {
|
||||
checkCompiled();
|
||||
List<List<Object>> batchValues = new ArrayList<List<Object>>(batch.length);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -148,6 +148,7 @@ public class SimpleJdbcInsert extends AbstractJdbcInsert implements SimpleJdbcIn
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public int[] executeBatch(Map<String, ?>... batch) {
|
||||
return doExecuteBatch(batch);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -152,6 +152,7 @@ public interface SimpleJdbcInsertOperations {
|
|||
* @param batch an array of Maps containing a batch of column names and corresponding value
|
||||
* @return the array of number of rows affected as returned by the JDBC driver
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
int[] executeBatch(Map<String, ?>... batch);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -101,7 +101,7 @@ public class TransactionAwareConnectionFactoryProxy
|
|||
* Set the target ConnectionFactory that this ConnectionFactory should delegate to.
|
||||
*/
|
||||
public final void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory) {
|
||||
Assert.notNull(targetConnectionFactory, "targetConnectionFactory must not be nul");
|
||||
Assert.notNull(targetConnectionFactory, "'targetConnectionFactory' must not be null");
|
||||
this.targetConnectionFactory = targetConnectionFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -61,7 +61,7 @@ public class JmsMessageEndpointFactory extends AbstractMessageEndpointFactory {
|
|||
* Return the JMS MessageListener for this endpoint.
|
||||
*/
|
||||
protected MessageListener getMessageListener() {
|
||||
return messageListener;
|
||||
return this.messageListener;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -196,6 +196,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
|||
@Override
|
||||
public Message toMessage(Object object, Session session, Object conversionHint)
|
||||
throws JMSException, MessageConversionException {
|
||||
|
||||
return toMessage(object, session, getSerializationView(conversionHint));
|
||||
}
|
||||
|
||||
|
@ -234,6 +235,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
|||
|
||||
protected Message toMessage(Object object, Session session, ObjectWriter objectWriter)
|
||||
throws JMSException, MessageConversionException {
|
||||
|
||||
Message message;
|
||||
try {
|
||||
switch (this.targetType) {
|
||||
|
@ -319,8 +321,8 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
|||
* @return the resulting message
|
||||
* @throws JMSException if thrown by JMS methods
|
||||
* @throws IOException in case of I/O errors
|
||||
* @see Session#createBytesMessage
|
||||
* @since 4.3
|
||||
* @see Session#createBytesMessage
|
||||
*/
|
||||
protected BytesMessage mapToBytesMessage(Object object, Session session, ObjectWriter objectWriter)
|
||||
throws JMSException, IOException {
|
||||
|
@ -400,7 +402,6 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method to dispatch to converters for individual message types.
|
||||
*/
|
||||
|
|
|
@ -152,7 +152,4 @@ public class MessagingMessageConverter implements MessageConverter, Initializing
|
|||
return this.headerMapper.toHeaders(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
|||
|
||||
private static final String MVC_VALIDATOR_NAME = "mvcValidator";
|
||||
|
||||
private static final boolean jackson2Present= ClassUtils.isPresent(
|
||||
private static final boolean jackson2Present = ClassUtils.isPresent(
|
||||
"com.fasterxml.jackson.databind.ObjectMapper", AbstractMessageBrokerConfiguration.class.getClassLoader());
|
||||
|
||||
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link org.springframework.messaging.converter.AbstractMessageConverter}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class AbstractMessageConverterTests {
|
||||
|
||||
private TestMessageConverter converter;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.converter = new TestMessageConverter();
|
||||
this.converter.setContentTypeResolver(new DefaultContentTypeResolver());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsTargetClass() {
|
||||
Message<String> message = MessageBuilder.withPayload("ABC").build();
|
||||
|
||||
assertEquals("success-from", this.converter.fromMessage(message, String.class));
|
||||
assertNull(this.converter.fromMessage(message, Integer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeType() {
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
|
||||
|
||||
assertEquals("success-from", this.converter.fromMessage(message, String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeTypeNotSupported() {
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build();
|
||||
|
||||
assertNull(this.converter.fromMessage(message, String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeTypeNotSpecified() {
|
||||
Message<String> message = MessageBuilder.withPayload("ABC").build();
|
||||
assertEquals("success-from", this.converter.fromMessage(message, String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeTypeNoneConfigured() {
|
||||
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build();
|
||||
|
||||
this.converter = new TestMessageConverter(Collections.<MimeType>emptyList());
|
||||
this.converter.setContentTypeResolver(new DefaultContentTypeResolver());
|
||||
|
||||
assertEquals("success-from", this.converter.fromMessage(message, String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toMessageHeadersCopied() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("foo", "bar");
|
||||
MessageHeaders headers = new MessageHeaders(map );
|
||||
Message<?> message = this.converter.toMessage("ABC", headers);
|
||||
|
||||
assertEquals("bar", message.getHeaders().get("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toMessageContentTypeHeader() {
|
||||
Message<?> message = this.converter.toMessage("ABC", null);
|
||||
assertEquals(MimeTypeUtils.TEXT_PLAIN, message.getHeaders().get(MessageHeaders.CONTENT_TYPE));
|
||||
}
|
||||
|
||||
|
||||
private static class TestMessageConverter extends AbstractMessageConverter {
|
||||
|
||||
public TestMessageConverter() {
|
||||
super(MimeTypeUtils.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
public TestMessageConverter(Collection<MimeType> supportedMimeTypes) {
|
||||
super(supportedMimeTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supports(Class<?> clazz) {
|
||||
return String.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertFromInternal(Message<?> message, Class<?> targetClass) {
|
||||
return "success-from";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertToInternal(Object payload, MessageHeaders headers) {
|
||||
return "success-to";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -44,6 +44,7 @@ public class MessageConverterTests {
|
|||
|
||||
private TestMessageConverter converter = new TestMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void supportsTargetClass() {
|
||||
Message<String> message = MessageBuilder.withPayload("ABC").build();
|
||||
|
@ -105,7 +106,7 @@ public class MessageConverterTests {
|
|||
|
||||
@Test
|
||||
public void toMessageWithHeaders() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
MessageHeaders headers = new MessageHeaders(map);
|
||||
Message<?> message = this.converter.toMessage("ABC", headers);
|
||||
|
|
|
@ -115,11 +115,11 @@ public abstract class SharedEntityManagerCreator {
|
|||
*/
|
||||
public static EntityManager createSharedEntityManager(
|
||||
EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction) {
|
||||
Class<?> entityManagerInterface = (emf instanceof EntityManagerFactoryInfo ?
|
||||
|
||||
Class<?> emIfc = (emf instanceof EntityManagerFactoryInfo ?
|
||||
((EntityManagerFactoryInfo) emf).getEntityManagerInterface() : EntityManager.class);
|
||||
return createSharedEntityManager(emf, properties, synchronizedWithTransaction,
|
||||
(entityManagerInterface == null ? NO_ENTITY_MANAGER_INTERFACES :
|
||||
new Class<?>[] { entityManagerInterface }));
|
||||
(emIfc == null ? NO_ENTITY_MANAGER_INTERFACES : new Class<?>[] {emIfc}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Spring's O/R Mapping package: supporting Hibernate, JPA, JDO, and iBATIS SQL Maps.
|
||||
Spring's O/R Mapping package: supporting Hibernate, JPA, and JDO.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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,8 +37,9 @@ import static org.junit.Assert.*;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class OxmNamespaceHandlerTests {
|
||||
|
||||
private final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
|
||||
"oxmNamespaceHandlerTest.xml", getClass());
|
||||
private final ApplicationContext applicationContext =
|
||||
new ClassPathXmlApplicationContext("oxmNamespaceHandlerTest.xml", getClass());
|
||||
|
||||
|
||||
@Test
|
||||
public void xmlBeansMarshaller() throws Exception {
|
||||
|
@ -85,4 +86,5 @@ public class OxmNamespaceHandlerTests {
|
|||
CastorMarshaller castorMarshaller = applicationContext.getBean("castorMappingLocationMarshaller", CastorMarshaller.class);
|
||||
assertNotNull(castorMarshaller);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class TestPropertySourceUtils {
|
|||
/**
|
||||
* The name of the {@link MapPropertySource} created from <em>inlined properties</em>.
|
||||
* @since 4.1.5
|
||||
* @see {@link #addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[])}
|
||||
* @see #addInlinedPropertiesToEnvironment
|
||||
*/
|
||||
public static final String INLINED_PROPERTIES_PROPERTY_SOURCE_NAME = "Inlined Test Properties";
|
||||
|
||||
|
@ -224,8 +224,7 @@ public abstract class TestPropertySourceUtils {
|
|||
* @see TestPropertySource#properties
|
||||
* @see #addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[])
|
||||
*/
|
||||
public static void addInlinedPropertiesToEnvironment(ConfigurableApplicationContext context,
|
||||
String... inlinedProperties) {
|
||||
public static void addInlinedPropertiesToEnvironment(ConfigurableApplicationContext context, String... inlinedProperties) {
|
||||
Assert.notNull(context, "context must not be null");
|
||||
Assert.notNull(inlinedProperties, "inlinedProperties must not be null");
|
||||
addInlinedPropertiesToEnvironment(context.getEnvironment(), inlinedProperties);
|
||||
|
@ -252,13 +251,11 @@ public abstract class TestPropertySourceUtils {
|
|||
Assert.notNull(inlinedProperties, "inlinedProperties must not be null");
|
||||
if (!ObjectUtils.isEmpty(inlinedProperties)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Adding inlined properties to environment: "
|
||||
+ ObjectUtils.nullSafeToString(inlinedProperties));
|
||||
logger.debug("Adding inlined properties to environment: " + ObjectUtils.nullSafeToString(inlinedProperties));
|
||||
}
|
||||
MapPropertySource ps = (MapPropertySource) environment.getPropertySources().get(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
if (ps == null) {
|
||||
ps = new MapPropertySource(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME,
|
||||
new LinkedHashMap<String, Object>());
|
||||
ps = new MapPropertySource(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME, new LinkedHashMap<String, Object>());
|
||||
environment.getPropertySources().addFirst(ps);
|
||||
}
|
||||
ps.getSource().putAll(convertInlinedPropertiesToMap(inlinedProperties));
|
||||
|
@ -285,21 +282,19 @@ public abstract class TestPropertySourceUtils {
|
|||
public static Map<String, Object> convertInlinedPropertiesToMap(String... inlinedProperties) {
|
||||
Assert.notNull(inlinedProperties, "inlinedProperties must not be null");
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
for (String pair : inlinedProperties) {
|
||||
if (!StringUtils.hasText(pair)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
props.load(new StringReader(pair));
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to load test environment property from [" + pair + "].", e);
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Failed to load test environment property from [" + pair + "]", ex);
|
||||
}
|
||||
Assert.state(props.size() == 1, "Failed to load exactly one test environment property from [" + pair + "].");
|
||||
|
||||
Assert.state(props.size() == 1, "Failed to load exactly one test environment property from [" + pair + "]");
|
||||
for (String name : props.stringPropertyNames()) {
|
||||
map.put(name, props.getProperty(name));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -124,6 +124,7 @@ public class JdbcTestUtils {
|
|||
*/
|
||||
public static int deleteFromTableWhere(JdbcTemplate jdbcTemplate, String tableName, String whereClause,
|
||||
Object... args) {
|
||||
|
||||
String sql = "DELETE FROM " + tableName;
|
||||
if (StringUtils.hasText(whereClause)) {
|
||||
sql += " WHERE " + whereClause;
|
||||
|
@ -170,6 +171,7 @@ public class JdbcTestUtils {
|
|||
@Deprecated
|
||||
public static void executeSqlScript(JdbcTemplate jdbcTemplate, ResourceLoader resourceLoader,
|
||||
String sqlResourcePath, boolean continueOnError) throws DataAccessException {
|
||||
|
||||
Resource resource = resourceLoader.getResource(sqlResourcePath);
|
||||
executeSqlScript(jdbcTemplate, resource, continueOnError);
|
||||
}
|
||||
|
@ -197,6 +199,7 @@ public class JdbcTestUtils {
|
|||
@Deprecated
|
||||
public static void executeSqlScript(JdbcTemplate jdbcTemplate, Resource resource, boolean continueOnError)
|
||||
throws DataAccessException {
|
||||
|
||||
executeSqlScript(jdbcTemplate, new EncodedResource(resource), continueOnError);
|
||||
}
|
||||
|
||||
|
@ -220,6 +223,7 @@ public class JdbcTestUtils {
|
|||
@Deprecated
|
||||
public static void executeSqlScript(JdbcTemplate jdbcTemplate, EncodedResource resource, boolean continueOnError)
|
||||
throws DataAccessException {
|
||||
|
||||
new ResourceDatabasePopulator(continueOnError, false, resource.getEncoding(), resource.getResource()).execute(jdbcTemplate.getDataSource());
|
||||
}
|
||||
|
||||
|
@ -288,4 +292,5 @@ public class JdbcTestUtils {
|
|||
public static void splitSqlScript(String script, char delim, List<String> statements) {
|
||||
ScriptUtils.splitSqlScript(script, delim, statements);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -23,22 +23,23 @@ import org.springframework.http.HttpRequest;
|
|||
/**
|
||||
* Represents the context of a client-side HTTP request execution.
|
||||
*
|
||||
* <p>Used to invoke the next interceptor in the interceptor chain, or - if the calling interceptor is last - execute
|
||||
* the request itself.
|
||||
* <p>Used to invoke the next interceptor in the interceptor chain,
|
||||
* or - if the calling interceptor is last - execute the request itself.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @see ClientHttpRequestInterceptor
|
||||
* @since 3.1
|
||||
* @see ClientHttpRequestInterceptor
|
||||
*/
|
||||
public interface ClientHttpRequestExecution {
|
||||
|
||||
/**
|
||||
* Execute the request with the given request attributes and body, and return the response.
|
||||
*
|
||||
* Execute the request with the given request attributes and body,
|
||||
* and return the response.
|
||||
* @param request the request, containing method, URI, and headers
|
||||
* @param body the body of the request to execute
|
||||
* @return the response
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -812,7 +812,7 @@ public class Jackson2ObjectMapperBuilder {
|
|||
return new XmlMapper(new XmlFactory(xmlInputFactory()), module);
|
||||
}
|
||||
|
||||
private static final XMLInputFactory xmlInputFactory() {
|
||||
private static XMLInputFactory xmlInputFactory() {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
|
||||
inputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2016 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,9 +31,9 @@ import javax.xml.ws.WebServiceProvider;
|
|||
* <p>Note that this exporter will only work if the JAX-WS runtime actually
|
||||
* supports publishing with an address argument, i.e. if the JAX-WS runtime
|
||||
* ships an internal HTTP server. This is the case with the JAX-WS runtime
|
||||
* that's inclued in Sun's JDK 1.6 but not with the standalone JAX-WS 2.1 RI.
|
||||
* that's included in Sun's JDK 6 but not with the standalone JAX-WS 2.1 RI.
|
||||
*
|
||||
* <p>For explicit configuration of JAX-WS endpoints with Sun's JDK 1.6
|
||||
* <p>For explicit configuration of JAX-WS endpoints with Sun's JDK 6
|
||||
* HTTP server, consider using {@link SimpleHttpServerJaxWsServiceExporter}!
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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,6 +70,9 @@ import org.springframework.web.multipart.MultipartRequest;
|
|||
*/
|
||||
public class WebRequestDataBinder extends WebDataBinder {
|
||||
|
||||
private static final boolean servlet3Parts = ClassUtils.hasMethod(HttpServletRequest.class, "getParts");
|
||||
|
||||
|
||||
/**
|
||||
* Create a new WebRequestDataBinder instance, with default object name.
|
||||
* @param target the target object to bind onto (or {@code null}
|
||||
|
@ -116,7 +119,7 @@ public class WebRequestDataBinder extends WebDataBinder {
|
|||
if (multipartRequest != null) {
|
||||
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);
|
||||
}
|
||||
else if (ClassUtils.hasMethod(HttpServletRequest.class, "getParts")) {
|
||||
else if (servlet3Parts) {
|
||||
HttpServletRequest serlvetRequest = ((NativeWebRequest) request).getNativeRequest(HttpServletRequest.class);
|
||||
new Servlet3MultipartHelper(isBindEmptyMultipartFiles()).bindParts(serlvetRequest, mpvs);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
|
|
@ -122,7 +122,7 @@ public abstract class MultipartResolutionDelegate {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if (parameter.getNestedParameterType() == servletPartClass) {
|
||||
else if (servletPartClass == parameter.getNestedParameterType()) {
|
||||
return (isMultipart ? RequestPartResolver.resolvePart(request, name) : null);
|
||||
}
|
||||
else if (isPartCollection(parameter)) {
|
||||
|
|
|
@ -93,7 +93,7 @@ public interface HandlerInterceptor {
|
|||
* @throws Exception in case of errors
|
||||
*/
|
||||
boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception;
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Intercept the execution of a handler. Called after HandlerAdapter actually
|
||||
|
@ -114,7 +114,8 @@ public interface HandlerInterceptor {
|
|||
* (can also be {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
void postHandle(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
|
@ -136,7 +137,8 @@ public interface HandlerInterceptor {
|
|||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
void afterCompletion(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -51,8 +51,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
public interface LocaleResolver {
|
||||
|
||||
/**
|
||||
* Resolve the current locale via the given request. Can return a default locale as
|
||||
* fallback in any case.
|
||||
* Resolve the current locale via the given request.
|
||||
* Can return a default locale as fallback in any case.
|
||||
* @param request the request to resolve the locale for
|
||||
* @return the current locale (never {@code null})
|
||||
*/
|
||||
|
@ -63,8 +63,8 @@ public interface LocaleResolver {
|
|||
* @param request the request to be used for locale modification
|
||||
* @param response the response to be used for locale modification
|
||||
* @param locale the new locale, or {@code null} to clear the locale
|
||||
* @throws UnsupportedOperationException if the LocaleResolver implementation does not
|
||||
* support dynamic changing of the locale
|
||||
* @throws UnsupportedOperationException if the LocaleResolver
|
||||
* implementation does not support dynamic changing of the locale
|
||||
*/
|
||||
void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -28,9 +28,9 @@ import org.springframework.util.StringUtils;
|
|||
*
|
||||
* <p>This is the default implementation used by the
|
||||
* {@link org.springframework.web.servlet.DispatcherServlet}, along with
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}
|
||||
* (on Java 5 and higher). Alternatively, {@link SimpleUrlHandlerMapping} allows for
|
||||
* customizing a handler mapping declaratively.
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}.
|
||||
* Alternatively, {@link SimpleUrlHandlerMapping} allows for customizing a
|
||||
* handler mapping declaratively.
|
||||
*
|
||||
* <p>The mapping is from URL to bean name. Thus an incoming URL "/foo" would map
|
||||
* to a handler named "/foo", or to "/foo /foo2" in case of multiple mappings to
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -23,7 +23,7 @@ import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
|||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* Abstract adapter class for the HandlerInterceptor interface,
|
||||
* Abstract adapter class for the {@link AsyncHandlerInterceptor} interface,
|
||||
* for simplified implementation of pre-only/post-only interceptors.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
@ -36,7 +36,8 @@ public abstract class HandlerInterceptorAdapter implements AsyncHandlerIntercept
|
|||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -34,7 +34,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
|||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated as of 4.3 {@link DeferredResultMethodReturnValueHandler} supports
|
||||
* CompletionStage return values via an adapter mechanism.
|
||||
*/
|
||||
|
|
|
@ -114,6 +114,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapter for {@code ListenableFuture} return values.
|
||||
*/
|
||||
|
@ -137,6 +138,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapter for {@code CompletionStage} return values.
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*
|
||||
* @deprecated as of 4.3 {@link DeferredResultMethodReturnValueHandler} supports
|
||||
* ListenableFuture return values via an adapter mechanism.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -49,12 +49,11 @@ import org.springframework.util.StringUtils;
|
|||
*/
|
||||
public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(CssLinkResourceTransformer.class);
|
||||
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
private static final Log logger = LogFactory.getLog(CssLinkResourceTransformer.class);
|
||||
|
||||
private final List<CssLinkParser> linkParsers = new ArrayList<CssLinkParser>();
|
||||
private final List<CssLinkParser> linkParsers = new ArrayList<CssLinkParser>(2);
|
||||
|
||||
|
||||
public CssLinkResourceTransformer() {
|
||||
|
@ -81,7 +80,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
|
||||
String content = new String(bytes, DEFAULT_CHARSET);
|
||||
|
||||
Set<CssLinkInfo> infos = new HashSet<CssLinkInfo>(5);
|
||||
Set<CssLinkInfo> infos = new HashSet<CssLinkInfo>(8);
|
||||
for (CssLinkParser parser : this.linkParsers) {
|
||||
parser.parseLink(content, infos);
|
||||
}
|
||||
|
@ -123,17 +122,16 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
private boolean hasScheme(String link) {
|
||||
int schemeIndex = link.indexOf(":");
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"))
|
||||
|| link.indexOf("//") == 0;
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) || link.indexOf("//") == 0;
|
||||
}
|
||||
|
||||
|
||||
protected static interface CssLinkParser {
|
||||
protected interface CssLinkParser {
|
||||
|
||||
void parseLink(String content, Set<CssLinkInfo> linkInfos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected static abstract class AbstractCssLinkParser implements CssLinkParser {
|
||||
|
||||
/**
|
||||
|
@ -189,6 +187,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private static class ImportStatementCssLinkParser extends AbstractCssLinkParser {
|
||||
|
||||
@Override
|
||||
|
@ -208,6 +207,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class UrlFunctionCssLinkParser extends AbstractCssLinkParser {
|
||||
|
||||
@Override
|
||||
|
@ -229,8 +229,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
private final int end;
|
||||
|
||||
|
||||
private CssLinkInfo(int start, int end) {
|
||||
public CssLinkInfo(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -35,10 +35,10 @@ public interface ResourceTransformer {
|
|||
* @param request the current request
|
||||
* @param resource the resource to transform
|
||||
* @param transformerChain the chain of remaining transformers to delegate to
|
||||
* @return the transformed resource, never {@code null}
|
||||
* @return the transformed resource (never {@code null})
|
||||
* @throws IOException if the transformation fails
|
||||
*/
|
||||
Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -54,6 +54,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
|
||||
private DispatcherServlet servlet;
|
||||
|
||||
|
||||
@Test
|
||||
public void simple() throws Exception {
|
||||
initServlet(SimpleUriTemplateController.class);
|
||||
|
@ -318,8 +319,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
assertEquals("test-42", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6640
|
||||
@Test
|
||||
@Test // SPR-6640
|
||||
public void menuTree() throws Exception {
|
||||
initServlet(MenuTreeController.class);
|
||||
|
||||
|
@ -329,8 +329,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
assertEquals("M5", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6876
|
||||
@Test
|
||||
@Test // SPR-6876
|
||||
public void variableNames() throws Exception {
|
||||
initServlet(VariableNamesController.class);
|
||||
|
||||
|
@ -345,8 +344,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
assertEquals("bar-bar", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-8543
|
||||
@Test
|
||||
@Test // SPR-8543
|
||||
public void variableNamesWithUrlExtension() throws Exception {
|
||||
initServlet(VariableNamesController.class);
|
||||
|
||||
|
@ -356,8 +354,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
assertEquals("foo-foo", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-9333
|
||||
@Test
|
||||
@Test // SPR-9333
|
||||
@SuppressWarnings("serial")
|
||||
public void suppressDefaultSuffixPattern() throws Exception {
|
||||
servlet = new DispatcherServlet() {
|
||||
|
@ -381,8 +378,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
assertEquals("foo-jsmith@mail.com", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6906
|
||||
@Test
|
||||
@Test // SPR-6906
|
||||
@SuppressWarnings("serial")
|
||||
public void controllerClassName() throws Exception {
|
||||
servlet = new DispatcherServlet() {
|
||||
|
@ -416,8 +412,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
|||
assertEquals("plain-bar", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6978
|
||||
@Test
|
||||
@Test // SPR-6978
|
||||
public void doIt() throws Exception {
|
||||
initServlet(Spr6978Controller.class);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -26,7 +26,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.ClientEndpointConfig.Configurator;
|
||||
import javax.websocket.ContainerProvider;
|
||||
|
@ -51,7 +50,6 @@ import org.springframework.web.socket.adapter.standard.StandardWebSocketSession;
|
|||
import org.springframework.web.socket.adapter.standard.WebSocketToStandardExtensionAdapter;
|
||||
import org.springframework.web.socket.client.AbstractWebSocketClient;
|
||||
|
||||
|
||||
/**
|
||||
* A WebSocketClient based on standard Java WebSocket API.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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,8 +67,8 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
org.springframework.messaging.simp.user.UserSessionRegistry userSessionRegistry,
|
||||
TaskScheduler defaultSockJsTaskScheduler) {
|
||||
|
||||
Assert.notNull(webSocketHandler, "'webSocketHandler' is required ");
|
||||
Assert.notNull(transportRegistration, "'transportRegistration' is required");
|
||||
Assert.notNull(webSocketHandler, "WebSocketHandler is required ");
|
||||
Assert.notNull(transportRegistration, "WebSocketTransportRegistration is required");
|
||||
|
||||
this.webSocketHandler = webSocketHandler;
|
||||
this.subProtocolWebSocketHandler = unwrapSubProtocolWebSocketHandler(webSocketHandler);
|
||||
|
@ -87,19 +87,17 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
this.stompHandler.setMessageSizeLimit(transportRegistration.getMessageSizeLimit());
|
||||
}
|
||||
|
||||
|
||||
this.sockJsScheduler = defaultSockJsTaskScheduler;
|
||||
}
|
||||
|
||||
private static SubProtocolWebSocketHandler unwrapSubProtocolWebSocketHandler(WebSocketHandler handler) {
|
||||
WebSocketHandler actual = WebSocketHandlerDecorator.unwrap(handler);
|
||||
Assert.isInstanceOf(SubProtocolWebSocketHandler.class, actual, "No SubProtocolWebSocketHandler in " + handler);
|
||||
if (!(actual instanceof SubProtocolWebSocketHandler)) {
|
||||
throw new IllegalArgumentException("No SubProtocolWebSocketHandler in " + handler);
|
||||
};
|
||||
return (SubProtocolWebSocketHandler) actual;
|
||||
}
|
||||
|
||||
protected void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.stompHandler.setApplicationEventPublisher(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StompWebSocketEndpointRegistration addEndpoint(String... paths) {
|
||||
|
@ -144,6 +142,11 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
return this;
|
||||
}
|
||||
|
||||
protected void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.stompHandler.setApplicationEventPublisher(applicationContext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a handler mapping with the mapped ViewControllers; or {@code null}
|
||||
* in case of no registrations.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -193,7 +193,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
|||
|
||||
private static final Method registerMethod;
|
||||
|
||||
private static final Method unRegisterMethod;
|
||||
private static final Method unregisterMethod;
|
||||
|
||||
static {
|
||||
try {
|
||||
|
@ -204,7 +204,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
|||
throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments");
|
||||
}
|
||||
registerMethod = TyrusWebSocketEngine.class.getDeclaredMethod("register", TyrusEndpointWrapper.class);
|
||||
unRegisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class);
|
||||
unregisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class);
|
||||
ReflectionUtils.makeAccessible(registerMethod);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@ -259,7 +259,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
|||
@Override
|
||||
public void unregister(TyrusWebSocketEngine engine, Object endpoint) {
|
||||
try {
|
||||
unRegisterMethod.invoke(engine, endpoint);
|
||||
unregisterMethod.invoke(engine, endpoint);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new HandshakeFailureException("Failed to unregister " + endpoint, ex);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -60,7 +60,6 @@ public class WebLogicRequestUpgradeStrategy extends AbstractTyrusRequestUpgradeS
|
|||
private static final WebLogicServletWriterHelper servletWriterHelper = new WebLogicServletWriterHelper();
|
||||
|
||||
private static final Connection.CloseListener noOpCloseListener = new Connection.CloseListener() {
|
||||
|
||||
@Override
|
||||
public void close(CloseReason reason) {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -54,6 +54,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
|||
PRELUDE = new String(bytes, SockJsFrame.CHARSET);
|
||||
}
|
||||
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean xhrStreamingDisabled;
|
||||
|
@ -137,6 +138,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
|||
URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
|
||||
SettableListenableFuture<WebSocketSession> connectFuture);
|
||||
|
||||
|
||||
// InfoReceiver methods
|
||||
|
||||
@Override
|
||||
|
@ -165,6 +167,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
|||
|
||||
protected abstract ResponseEntity<String> executeInfoRequestInternal(URI infoUrl, HttpHeaders headers);
|
||||
|
||||
|
||||
// XhrTransport methods
|
||||
|
||||
@Override
|
||||
|
@ -184,8 +187,8 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract ResponseEntity<String> executeSendRequestInternal(URI url,
|
||||
HttpHeaders headers, TextMessage message);
|
||||
protected abstract ResponseEntity<String> executeSendRequestInternal(
|
||||
URI url, HttpHeaders headers, TextMessage message);
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig;
|
|||
*/
|
||||
public class PollingSockJsSession extends AbstractHttpSockJsSession {
|
||||
|
||||
|
||||
public PollingSockJsSession(String sessionId, SockJsServiceConfig config,
|
||||
WebSocketHandler wsHandler, Map<String, Object> attributes) {
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
@ -48,9 +47,7 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
|||
*/
|
||||
public abstract class AbstractWebSocketIntegrationTests {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private static Map<Class<?>, Class<?>> upgradeStrategyConfigTypes = new HashMap<Class<?>, Class<?>>();
|
||||
private static Map<Class<?>, Class<?>> upgradeStrategyConfigTypes = new HashMap<>();
|
||||
|
||||
static {
|
||||
upgradeStrategyConfigTypes.put(JettyWebSocketTestServer.class, JettyUpgradeStrategyConfig.class);
|
||||
|
@ -58,6 +55,7 @@ public abstract class AbstractWebSocketIntegrationTests {
|
|||
upgradeStrategyConfigTypes.put(UndertowTestServer.class, UndertowUpgradeStrategyConfig.class);
|
||||
}
|
||||
|
||||
|
||||
@Rule
|
||||
public final TestName testName = new TestName();
|
||||
|
||||
|
@ -67,12 +65,13 @@ public abstract class AbstractWebSocketIntegrationTests {
|
|||
@Parameter(1)
|
||||
public WebSocketClient webSocketClient;
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
protected AnnotationConfigWebApplicationContext wac;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" +
|
||||
this.webSocketClient.getClass().getSimpleName() + ", server=" +
|
||||
this.server.getClass().getSimpleName());
|
||||
|
@ -155,6 +154,7 @@ public abstract class AbstractWebSocketIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class TomcatUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig {
|
||||
|
||||
|
@ -164,6 +164,7 @@ public abstract class AbstractWebSocketIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class UndertowUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
@ -46,9 +46,10 @@ import static org.junit.Assert.*;
|
|||
* Client and server-side WebSocket integration tests.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
|
||||
public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests {
|
||||
|
||||
@Parameters(name = "server [{0}], client [{1}]")
|
||||
public static Iterable<Object[]> arguments() {
|
||||
|
@ -62,7 +63,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest
|
|||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedConfigClasses() {
|
||||
return new Class<?>[] { TestConfig.class };
|
||||
return new Class<?>[] {TestConfig.class};
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -75,11 +76,8 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest
|
|||
session.close();
|
||||
}
|
||||
|
||||
// SPR-12727
|
||||
|
||||
@Test
|
||||
@Test // SPR-12727
|
||||
public void unsolicitedPongWithEmptyPayload() throws Exception {
|
||||
|
||||
String url = getWsBaseUrl() + "/ws";
|
||||
WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get();
|
||||
|
||||
|
@ -126,7 +124,6 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest
|
|||
|
||||
private Throwable transportError;
|
||||
|
||||
|
||||
public void setWaitMessageCount(int waitMessageCount) {
|
||||
this.waitMessageCount = waitMessageCount;
|
||||
}
|
Loading…
Reference in New Issue