Backported refinements and polishing
This commit is contained in:
parent
503d65d570
commit
36e1c82ef5
|
|
@ -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.
|
||||
|
|
@ -55,10 +55,12 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
|||
return this.aspectClass.newInstance();
|
||||
}
|
||||
catch (InstantiationException ex) {
|
||||
throw new AopConfigException("Unable to instantiate aspect class [" + this.aspectClass.getName() + "]", ex);
|
||||
throw new AopConfigException(
|
||||
"Unable to instantiate aspect class: " + this.aspectClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new AopConfigException("Cannot access element class [" + this.aspectClass.getName() + "]", ex);
|
||||
throw new AopConfigException(
|
||||
"Could not access aspect constructor: " + this.aspectClass.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,11 +63,10 @@ public abstract class BeanUtils {
|
|||
|
||||
/**
|
||||
* Convenience method to instantiate a class using its no-arg constructor.
|
||||
* As this method doesn't try to load classes by name, it should avoid
|
||||
* class-loading issues.
|
||||
* @param clazz class to instantiate
|
||||
* @return the new instance
|
||||
* @throws BeanInstantiationException if the bean cannot be instantiated
|
||||
* @see Class#newInstance()
|
||||
*/
|
||||
public static <T> T instantiate(Class<T> clazz) throws BeanInstantiationException {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
|
|
@ -87,13 +86,12 @@ public abstract class BeanUtils {
|
|||
|
||||
/**
|
||||
* Instantiate a class using its no-arg constructor.
|
||||
* As this method doesn't try to load classes by name, it should avoid
|
||||
* class-loading issues.
|
||||
* <p>Note that this method tries to set the constructor accessible
|
||||
* if given a non-accessible (that is, non-public) constructor.
|
||||
* @param clazz class to instantiate
|
||||
* @return the new instance
|
||||
* @throws BeanInstantiationException if the bean cannot be instantiated
|
||||
* @see Constructor#newInstance
|
||||
*/
|
||||
public static <T> T instantiateClass(Class<T> clazz) throws BeanInstantiationException {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
|
|
@ -111,17 +109,15 @@ public abstract class BeanUtils {
|
|||
/**
|
||||
* Instantiate a class using its no-arg constructor and return the new instance
|
||||
* as the specified assignable type.
|
||||
* <p>Useful in cases where
|
||||
* the type of the class to instantiate (clazz) is not available, but the type
|
||||
* desired (assignableTo) is known.
|
||||
* <p>As this method doesn't try to load classes by name, it should avoid
|
||||
* class-loading issues.
|
||||
* <p>Note that this method tries to set the constructor accessible
|
||||
* if given a non-accessible (that is, non-public) constructor.
|
||||
* <p>Useful in cases where the type of the class to instantiate (clazz) is not
|
||||
* available, but the type desired (assignableTo) is known.
|
||||
* <p>Note that this method tries to set the constructor accessible if given a
|
||||
* non-accessible (that is, non-public) constructor.
|
||||
* @param clazz class to instantiate
|
||||
* @param assignableTo type that clazz must be assignableTo
|
||||
* @return the new instance
|
||||
* @throws BeanInstantiationException if the bean cannot be instantiated
|
||||
* @see Constructor#newInstance
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo) throws BeanInstantiationException {
|
||||
|
|
@ -131,14 +127,13 @@ public abstract class BeanUtils {
|
|||
|
||||
/**
|
||||
* Convenience method to instantiate a class using the given constructor.
|
||||
* As this method doesn't try to load classes by name, it should avoid
|
||||
* class-loading issues.
|
||||
* <p>Note that this method tries to set the constructor accessible
|
||||
* if given a non-accessible (that is, non-public) constructor.
|
||||
* <p>Note that this method tries to set the constructor accessible if given a
|
||||
* non-accessible (that is, non-public) constructor.
|
||||
* @param ctor the constructor to instantiate
|
||||
* @param args the constructor arguments to apply
|
||||
* @return the new instance
|
||||
* @throws BeanInstantiationException if the bean cannot be instantiated
|
||||
* @see Constructor#newInstance
|
||||
*/
|
||||
public static <T> T instantiateClass(Constructor<T> ctor, Object... args) throws BeanInstantiationException {
|
||||
Assert.notNull(ctor, "Constructor must not be null");
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -24,6 +24,7 @@ package org.springframework.beans;
|
|||
* spouse property of the target object has a null value.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class NullValueInNestedPathException extends InvalidPropertyException {
|
||||
|
|
@ -47,4 +48,16 @@ public class NullValueInNestedPathException extends InvalidPropertyException {
|
|||
super(beanClass, propertyName, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new NullValueInNestedPathException.
|
||||
* @param beanClass the offending bean class
|
||||
* @param propertyName the offending property
|
||||
* @param msg the detail message
|
||||
* @param cause the root cause
|
||||
* @since 4.3.2
|
||||
*/
|
||||
public NullValueInNestedPathException(Class<?> beanClass, String propertyName, String msg, Throwable cause) {
|
||||
super(beanClass, propertyName, msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -45,8 +45,8 @@ public class BeanNotOfRequiredTypeException extends BeansException {
|
|||
* the expected type
|
||||
*/
|
||||
public BeanNotOfRequiredTypeException(String beanName, Class<?> requiredType, Class<?> actualType) {
|
||||
super("Bean named '" + beanName + "' must be of type [" + requiredType.getName() +
|
||||
"], but was actually of type [" + actualType.getName() + "]");
|
||||
super("Bean named '" + beanName + "' is expected to be of type [" + requiredType.getName() +
|
||||
"] but was actually of type [" + actualType.getName() + "]");
|
||||
this.beanName = beanName;
|
||||
this.requiredType = requiredType;
|
||||
this.actualType = actualType;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -115,7 +115,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
|
|||
Class<?> subclass = createEnhancedSubclass(this.beanDefinition);
|
||||
Object instance;
|
||||
if (ctor == null) {
|
||||
instance = BeanUtils.instantiate(subclass);
|
||||
instance = BeanUtils.instantiateClass(subclass);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -609,8 +609,8 @@ class ConstructorResolver {
|
|||
private int resolveConstructorArguments(String beanName, RootBeanDefinition mbd, BeanWrapper bw,
|
||||
ConstructorArgumentValues cargs, ConstructorArgumentValues resolvedValues) {
|
||||
|
||||
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
|
||||
this.beanFactory.getCustomTypeConverter() : bw);
|
||||
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
|
||||
TypeConverter converter = (customConverter != null ? customConverter : bw);
|
||||
BeanDefinitionValueResolver valueResolver =
|
||||
new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter);
|
||||
|
||||
|
|
@ -665,8 +665,8 @@ class ConstructorResolver {
|
|||
BeanWrapper bw, Class<?>[] paramTypes, String[] paramNames, Object methodOrCtor,
|
||||
boolean autowiring) throws UnsatisfiedDependencyException {
|
||||
|
||||
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
|
||||
this.beanFactory.getCustomTypeConverter() : bw);
|
||||
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
|
||||
TypeConverter converter = (customConverter != null ? customConverter : bw);
|
||||
|
||||
ArgumentsHolder args = new ArgumentsHolder(paramTypes.length);
|
||||
Set<ConstructorArgumentValues.ValueHolder> usedValueHolders =
|
||||
|
|
@ -769,12 +769,13 @@ class ConstructorResolver {
|
|||
private Object[] resolvePreparedArguments(
|
||||
String beanName, RootBeanDefinition mbd, BeanWrapper bw, Member methodOrCtor, Object[] argsToResolve) {
|
||||
|
||||
Class<?>[] paramTypes = (methodOrCtor instanceof Method ?
|
||||
((Method) methodOrCtor).getParameterTypes() : ((Constructor<?>) methodOrCtor).getParameterTypes());
|
||||
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
|
||||
this.beanFactory.getCustomTypeConverter() : bw);
|
||||
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
|
||||
TypeConverter converter = (customConverter != null ? customConverter : bw);
|
||||
BeanDefinitionValueResolver valueResolver =
|
||||
new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter);
|
||||
Class<?>[] paramTypes = (methodOrCtor instanceof Method ?
|
||||
((Method) methodOrCtor).getParameterTypes() : ((Constructor<?>) methodOrCtor).getParameterTypes());
|
||||
|
||||
Object[] resolvedArgs = new Object[argsToResolve.length];
|
||||
for (int argIndex = 0; argIndex < argsToResolve.length; argIndex++) {
|
||||
Object argValue = argsToResolve[argIndex];
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
|||
}
|
||||
bd.resolvedConstructorOrFactoryMethod = constructorToUse;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -154,9 +154,9 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
|
|||
try {
|
||||
return collectionType.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not instantiate collection class [" + collectionType.getName() + "]: " + ex.getMessage());
|
||||
"Could not instantiate collection class: " + collectionType.getName(), ex);
|
||||
}
|
||||
}
|
||||
else if (List.class == collectionType) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -132,9 +132,9 @@ public class CustomMapEditor extends PropertyEditorSupport {
|
|||
try {
|
||||
return mapType.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not instantiate map class [" + mapType.getName() + "]: " + ex.getMessage());
|
||||
"Could not instantiate map class: " + mapType.getName(), ex);
|
||||
}
|
||||
}
|
||||
else if (SortedMap.class == mapType) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ class ConfigurationClassEnhancer {
|
|||
try {
|
||||
fbProxy = fbClass.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Unable to instantiate enhanced FactoryBean using Objenesis, " +
|
||||
"and regular FactoryBean instantiation via default constructor fails as well", ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ class ConfigurationClassParser {
|
|||
|
||||
Class<? extends PropertySourceFactory> factoryClass = propertySource.getClass("factory");
|
||||
PropertySourceFactory factory = (factoryClass == PropertySourceFactory.class ?
|
||||
DEFAULT_PROPERTY_SOURCE_FACTORY : BeanUtils.instantiate(factoryClass));
|
||||
DEFAULT_PROPERTY_SOURCE_FACTORY : BeanUtils.instantiateClass(factoryClass));
|
||||
|
||||
for (String location : locations) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
|
|||
if (ann == null) {
|
||||
return null;
|
||||
}
|
||||
T bean = BeanUtils.instantiate(beanClass);
|
||||
T bean = BeanUtils.instantiateClass(beanClass);
|
||||
AnnotationBeanUtils.copyPropertiesToBean(ann, bean);
|
||||
return bean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -72,7 +72,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean
|
|||
* @param methodNames an array of method names indicating the methods to use
|
||||
* @see #setMethodMappings
|
||||
*/
|
||||
public void setManagedMethods(String[] methodNames) {
|
||||
public void setManagedMethods(String... methodNames) {
|
||||
this.managedMethods = new HashSet<String>(Arrays.asList(methodNames));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ public abstract class BshScriptUtils {
|
|||
return clazz.newInstance();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Could not instantiate script class [" +
|
||||
clazz.getName() + "]. Root cause is " + ex);
|
||||
throw new IllegalStateException("Could not instantiate script class: " + clazz.getName(), ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -28,7 +28,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author Mark Fisher
|
||||
* @since 2.5
|
||||
*/
|
||||
public class ScriptingDefaultsParser implements BeanDefinitionParser {
|
||||
class ScriptingDefaultsParser implements BeanDefinitionParser {
|
||||
|
||||
private static final String REFRESH_CHECK_DELAY_ATTRIBUTE = "refresh-check-delay";
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public class ScriptingDefaultsParser implements BeanDefinitionParser {
|
|||
LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry());
|
||||
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
|
||||
if (StringUtils.hasText(refreshCheckDelay)) {
|
||||
bd.getPropertyValues().add("defaultRefreshCheckDelay", new Long(refreshCheckDelay));
|
||||
bd.getPropertyValues().add("defaultRefreshCheckDelay", Long.valueOf(refreshCheckDelay));
|
||||
}
|
||||
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
|
||||
if (StringUtils.hasText(proxyTargetClass)) {
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
|
|||
}
|
||||
catch (InstantiationException ex) {
|
||||
throw new ScriptCompilationException(
|
||||
scriptSource, "Could not instantiate Groovy script class: " + scriptClass.getName(), ex);
|
||||
scriptSource, "Unable to instantiate Groovy script class: " + scriptClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new ScriptCompilationException(
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -154,7 +154,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
|
|||
}
|
||||
catch (InstantiationException ex) {
|
||||
throw new ScriptCompilationException(
|
||||
scriptSource, "Could not instantiate script class: " + scriptClass.getName(), ex);
|
||||
scriptSource, "Unable to instantiate script class: " + scriptClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new ScriptCompilationException(
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -27,18 +27,19 @@ import static org.junit.Assert.*;
|
|||
* @author Adrian Colyer
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class AnnotationBindingTests {
|
||||
public class AnnotationBindingTests {
|
||||
|
||||
private AnnotatedTestBean testBean;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
testBean = (AnnotatedTestBean) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAnnotationBindingInAroundAdvice() {
|
||||
assertEquals("this value", testBean.doThis());
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -182,19 +182,19 @@ public class LocalStatelessSessionProxyFactoryBeanTests {
|
|||
}
|
||||
|
||||
|
||||
public static interface MyHome extends EJBLocalHome {
|
||||
public interface MyHome extends EJBLocalHome {
|
||||
|
||||
MyBusinessMethods create() throws CreateException;
|
||||
}
|
||||
|
||||
|
||||
public static interface MyBusinessMethods {
|
||||
public interface MyBusinessMethods {
|
||||
|
||||
int getValue();
|
||||
}
|
||||
|
||||
|
||||
public static interface MyEjb extends EJBLocalObject, MyBusinessMethods {
|
||||
public interface MyEjb extends EJBLocalObject, MyBusinessMethods {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -279,26 +279,25 @@ public class SimpleRemoteStatelessSessionProxyFactoryBeanTests extends SimpleRem
|
|||
}
|
||||
|
||||
|
||||
protected static interface MyHome extends EJBHome {
|
||||
protected interface MyHome extends EJBHome {
|
||||
|
||||
MyBusinessMethods create() throws CreateException, RemoteException;
|
||||
}
|
||||
|
||||
|
||||
protected static interface MyBusinessMethods {
|
||||
protected interface MyBusinessMethods {
|
||||
|
||||
int getValue() throws RemoteException;
|
||||
}
|
||||
|
||||
|
||||
protected static interface MyLocalBusinessMethods {
|
||||
protected interface MyLocalBusinessMethods {
|
||||
|
||||
int getValue();
|
||||
}
|
||||
|
||||
|
||||
protected static interface MyEjb extends EJBObject, MyBusinessMethods {
|
||||
|
||||
protected interface MyEjb extends EJBObject, MyBusinessMethods {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -218,7 +218,7 @@ public class FormattingConversionServiceTests {
|
|||
assertEquals(new LocalDate(2009, 11, 1), new LocalDate(dates.get(1)));
|
||||
assertEquals(new LocalDate(2009, 11, 2), new LocalDate(dates.get(2)));
|
||||
|
||||
Object model = BeanUtils.instantiate(modelClass);
|
||||
Object model = modelClass.newInstance();
|
||||
ConfigurablePropertyAccessor accessor = directFieldAccess ? PropertyAccessorFactory.forDirectFieldAccess(model) :
|
||||
PropertyAccessorFactory.forBeanPropertyAccess(model);
|
||||
accessor.setConversionService(formattingService);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss
|
|||
public void testWithFallThrough() throws Exception {
|
||||
MethodNameBasedMBeanInfoAssembler assembler =
|
||||
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
|
||||
assembler.setManagedMethods(new String[]{"getNickName", "setNickName"});
|
||||
assembler.setManagedMethods("getNickName", "setNickName");
|
||||
|
||||
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler
|
|||
@Override
|
||||
protected MBeanInfoAssembler getAssembler() {
|
||||
MethodNameBasedMBeanInfoAssembler assembler = new MethodNameBasedMBeanInfoAssembler();
|
||||
assembler.setManagedMethods(new String[] {"add", "myOperation", "getName", "setName", "getAge"});
|
||||
assembler.setManagedMethods("add", "myOperation", "getName", "setName", "getAge");
|
||||
return assembler;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ public class GroovyScriptFactoryTests {
|
|||
@Test
|
||||
public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
|
||||
ScriptSource script = mock(ScriptSource.class);
|
||||
final String badScript = "class Foo { public Foo(String foo) {}}";
|
||||
String badScript = "class Foo { public Foo(String foo) {}}";
|
||||
given(script.getScriptAsString()).willReturn(badScript);
|
||||
given(script.suggestedClassName()).willReturn("someName");
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
|
||||
|
|
@ -285,11 +285,10 @@ public class GroovyScriptFactoryTests {
|
|||
@Test
|
||||
public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
|
||||
ScriptSource script = mock(ScriptSource.class);
|
||||
final String badScript = "class Foo { protected Foo() {}}";
|
||||
String badScript = "class Foo { protected Foo() {} \n String toString() { 'X' }}";
|
||||
given(script.getScriptAsString()).willReturn(badScript);
|
||||
given(script.suggestedClassName()).willReturn("someName");
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
|
||||
+ badScript);
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript);
|
||||
try {
|
||||
factory.getScriptedObject(script);
|
||||
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
|
||||
|
|
@ -562,7 +561,7 @@ public class GroovyScriptFactoryTests {
|
|||
testMetaClass("org/springframework/scripting/groovy/calculators-with-xsd.xml");
|
||||
}
|
||||
|
||||
private void testMetaClass(final String xmlFile) {
|
||||
private void testMetaClass(String xmlFile) {
|
||||
// expect the exception we threw in the custom metaclass to show it got invoked
|
||||
try {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -203,7 +203,7 @@ public abstract class CollectionFactory {
|
|||
try {
|
||||
return (Collection<E>) collectionType.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not instantiate Collection type: " + collectionType.getName(), ex);
|
||||
}
|
||||
|
|
@ -318,7 +318,7 @@ public abstract class CollectionFactory {
|
|||
try {
|
||||
return (Map<K, V>) mapType.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Could not instantiate Map type: " + mapType.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -21,7 +21,6 @@ import java.io.InputStream;
|
|||
import java.io.NotSerializableException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -101,7 +100,7 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
|||
}
|
||||
}
|
||||
try {
|
||||
return Proxy.getProxyClass(this.classLoader, resolvedInterfaces);
|
||||
return ClassUtils.createCompositeInterface(resolvedInterfaces, this.classLoader);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new ClassNotFoundException(null, ex);
|
||||
|
|
@ -117,7 +116,7 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
|||
for (int i = 0; i < interfaces.length; i++) {
|
||||
resolvedInterfaces[i] = resolveFallbackIfPossible(interfaces[i], ex);
|
||||
}
|
||||
return Proxy.getProxyClass(getFallbackClassLoader(), resolvedInterfaces);
|
||||
return ClassUtils.createCompositeInterface(resolvedInterfaces, getFallbackClassLoader());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -139,8 +138,9 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
|||
|
||||
/**
|
||||
* Return the fallback ClassLoader to use when no ClassLoader was specified
|
||||
* and ObjectInputStream's own default ClassLoader failed.
|
||||
* <p>The default implementation simply returns {@code null}.
|
||||
* and ObjectInputStream's own default class loader failed.
|
||||
* <p>The default implementation simply returns {@code null}, indicating
|
||||
* that no specific fallback is available.
|
||||
*/
|
||||
protected ClassLoader getFallbackClassLoader() throws IOException {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
/**
|
||||
* Create a new, empty {@link AnnotationAttributes} instance for the
|
||||
* specified {@code annotationType}.
|
||||
* @param annotationType the type of annotation represented by this
|
||||
* @param annotationType the annotation type name represented by this
|
||||
* {@code AnnotationAttributes} instance; never {@code null}
|
||||
* @param classLoader the ClassLoader to try to load the annotation type on,
|
||||
* or {@code null} to just store the annotation type name
|
||||
|
|
|
|||
|
|
@ -1268,8 +1268,8 @@ public abstract class AnnotationUtils {
|
|||
(annotatedElement != null ? annotatedElement.toString() : "unknown element");
|
||||
throw new AnnotationConfigurationException(String.format(
|
||||
"In AnnotationAttributes for annotation [%s] declared on %s, " +
|
||||
"attribute '%s' and its alias '%s' are declared with values of [%s] and [%s], " +
|
||||
"but only one is permitted.", annotationType.getName(), elementAsString,
|
||||
"attribute '%s' and its alias '%s' are declared with values of [%s] and [%s], " +
|
||||
"but only one is permitted.", annotationType.getName(), elementAsString,
|
||||
attributeName, aliasedAttributeName, ObjectUtils.nullSafeToString(value),
|
||||
ObjectUtils.nullSafeToString(aliasedValue)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -72,7 +72,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource {
|
|||
}
|
||||
|
||||
/**
|
||||
* This implementation returns a File reference for the underlying class path
|
||||
* This implementation returns a File reference for the given URI-identified
|
||||
* resource, provided that it refers to a file in the file system.
|
||||
* @see org.springframework.util.ResourceUtils#getFile(java.net.URI, String)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -182,8 +182,8 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
return this.path.toFile();
|
||||
}
|
||||
catch (UnsupportedOperationException ex) {
|
||||
// only Paths on the default file system can be converted to a File
|
||||
// do exception translation for cases where conversion is not possible
|
||||
// Only paths on the default file system can be converted to a File:
|
||||
// Do exception translation for cases where conversion is not possible.
|
||||
throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -47,7 +47,7 @@ import java.net.URL;
|
|||
public interface Resource extends InputStreamSource {
|
||||
|
||||
/**
|
||||
* Return whether this resource actually exists in physical form.
|
||||
* Determine whether this resource actually exists in physical form.
|
||||
* <p>This method performs a definitive existence check, whereas the
|
||||
* existence of a {@code Resource} handle only guarantees a
|
||||
* valid descriptor handle.
|
||||
|
|
@ -55,8 +55,8 @@ public interface Resource extends InputStreamSource {
|
|||
boolean exists();
|
||||
|
||||
/**
|
||||
* Return whether the contents of this resource can be read,
|
||||
* e.g. via {@link #getInputStream()} or {@link #getFile()}.
|
||||
* Indicate whether the contents of this resource can be read via
|
||||
* {@link #getInputStream()}.
|
||||
* <p>Will be {@code true} for typical resource descriptors;
|
||||
* note that actual content reading may still fail when attempted.
|
||||
* However, a value of {@code false} is a definitive indication
|
||||
|
|
@ -66,8 +66,8 @@ public interface Resource extends InputStreamSource {
|
|||
boolean isReadable();
|
||||
|
||||
/**
|
||||
* Return whether this resource represents a handle with an open
|
||||
* stream. If true, the InputStream cannot be read multiple times,
|
||||
* Indicate whether this resource represents a handle with an open stream.
|
||||
* If {@code true}, the InputStream cannot be read multiple times,
|
||||
* and must be read and closed to avoid resource leaks.
|
||||
* <p>Will be {@code false} for typical resource descriptors.
|
||||
*/
|
||||
|
|
@ -84,6 +84,7 @@ public interface Resource extends InputStreamSource {
|
|||
* Return a URI handle for this resource.
|
||||
* @throws IOException if the resource cannot be resolved as URI,
|
||||
* i.e. if the resource is not available as descriptor
|
||||
* @since 2.5
|
||||
*/
|
||||
URI getURI() throws IOException;
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -61,6 +61,7 @@ public class UrlResource extends AbstractFileResolvingResource {
|
|||
* Create a new {@code UrlResource} based on the given URI object.
|
||||
* @param uri a URI
|
||||
* @throws MalformedURLException if the given URL path is not valid
|
||||
* @since 2.5
|
||||
*/
|
||||
public UrlResource(URI uri) throws MalformedURLException {
|
||||
Assert.notNull(uri, "URI must not be null");
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ public abstract class SpringFactoriesLoader {
|
|||
return (T) constructor.newInstance();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Cannot instantiate factory class: " + factoryClass.getName(), ex);
|
||||
throw new IllegalArgumentException("Unable to instantiate factory class: " + factoryClass.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -82,7 +82,7 @@ public class ToStringCreator {
|
|||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, byte value) {
|
||||
return append(fieldName, new Byte(value));
|
||||
return append(fieldName, Byte.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,7 +92,7 @@ public class ToStringCreator {
|
|||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, short value) {
|
||||
return append(fieldName, new Short(value));
|
||||
return append(fieldName, Short.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -102,7 +102,7 @@ public class ToStringCreator {
|
|||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, int value) {
|
||||
return append(fieldName, new Integer(value));
|
||||
return append(fieldName, Integer.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +112,7 @@ public class ToStringCreator {
|
|||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, long value) {
|
||||
return append(fieldName, new Long(value));
|
||||
return append(fieldName, Long.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -122,7 +122,7 @@ public class ToStringCreator {
|
|||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, float value) {
|
||||
return append(fieldName, new Float(value));
|
||||
return append(fieldName, Float.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,7 +132,7 @@ public class ToStringCreator {
|
|||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, double value) {
|
||||
return append(fieldName, new Double(value));
|
||||
return append(fieldName, Double.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -263,13 +263,16 @@ public class AutoPopulatingList<E> implements List<E>, Serializable {
|
|||
public ElementInstantiationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public ElementInstantiationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reflective implementation of the ElementFactory interface,
|
||||
* using {@code Class.newInstance()} on a given element class.
|
||||
* @see Class#newInstance()
|
||||
*/
|
||||
private static class ReflectiveElementFactory<E> implements ElementFactory<E>, Serializable {
|
||||
|
||||
|
|
@ -288,12 +291,12 @@ public class AutoPopulatingList<E> implements List<E>, Serializable {
|
|||
return this.elementClass.newInstance();
|
||||
}
|
||||
catch (InstantiationException ex) {
|
||||
throw new ElementInstantiationException("Unable to instantiate element class [" +
|
||||
this.elementClass.getName() + "]. Root cause is " + ex);
|
||||
throw new ElementInstantiationException(
|
||||
"Unable to instantiate element class: " + this.elementClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new ElementInstantiationException("Cannot access element class [" +
|
||||
this.elementClass.getName() + "]. Root cause is " + ex);
|
||||
throw new ElementInstantiationException(
|
||||
"Could not access element constructor: " + this.elementClass.getName(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,6 @@ public abstract class ClassUtils {
|
|||
*/
|
||||
public static Class<?> createCompositeInterface(Class<?>[] interfaces, ClassLoader classLoader) {
|
||||
Assert.notEmpty(interfaces, "Interfaces must not be empty");
|
||||
Assert.notNull(classLoader, "ClassLoader must not be null");
|
||||
return Proxy.getProxyClass(classLoader, interfaces);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -235,6 +235,7 @@ public abstract class ResourceUtils {
|
|||
* @return a corresponding File object
|
||||
* @throws FileNotFoundException if the URL cannot be resolved to
|
||||
* a file in the file system
|
||||
* @since 2.5
|
||||
*/
|
||||
public static File getFile(URI resourceUri) throws FileNotFoundException {
|
||||
return getFile(resourceUri, "URI");
|
||||
|
|
@ -249,6 +250,7 @@ public abstract class ResourceUtils {
|
|||
* @return a corresponding File object
|
||||
* @throws FileNotFoundException if the URL cannot be resolved to
|
||||
* a file in the file system
|
||||
* @since 2.5
|
||||
*/
|
||||
public static File getFile(URI resourceUri, String description) throws FileNotFoundException {
|
||||
Assert.notNull(resourceUri, "Resource URI must not be null");
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public class SerializableTypeWrapperTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void forTypeParamters() throws Exception {
|
||||
public void forTypeParameters() throws Exception {
|
||||
Type type = SerializableTypeWrapper.forTypeParameters(List.class)[0];
|
||||
assertThat(type.toString(), equalTo("E"));
|
||||
assertSerializable(type);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -75,10 +75,10 @@ public class CollectionToCollectionConverterTests {
|
|||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
assertTrue(conversionService.canConvert(sourceType, targetType));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> result = (List<String>) conversionService.convert(list, sourceType, targetType);
|
||||
List<Integer> result = (List<Integer>) conversionService.convert(list, sourceType, targetType);
|
||||
assertFalse(list.equals(result));
|
||||
assertEquals(9, result.get(0));
|
||||
assertEquals(37, result.get(1));
|
||||
assertEquals(9, result.get(0).intValue());
|
||||
assertEquals(37, result.get(1).intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -694,7 +694,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
newElements--;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.UNABLE_TO_GROW_COLLECTION);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ import org.springframework.util.StringUtils;
|
|||
* <p>To facilitate mapping between columns and fields that don't have matching names,
|
||||
* try using column aliases in the SQL statement like "select fname as first_name from customer".
|
||||
*
|
||||
* <p>For 'null' values read from the databasem, we will attempt to call the setter, but in the case of
|
||||
* <p>For 'null' values read from the database, we will attempt to call the setter, but in the case of
|
||||
* Java primitives, this causes a TypeMismatchException. This class can be configured (using the
|
||||
* primitivesDefaultedForNullValue property) to trap this exception and use the primitives default value.
|
||||
* Be aware that if you use the values from the generated bean to update the database the primitive value
|
||||
|
|
@ -274,7 +274,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
|
|||
@Override
|
||||
public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
|
||||
Assert.state(this.mappedClass != null, "Mapped class was not specified");
|
||||
T mappedObject = BeanUtils.instantiate(this.mappedClass);
|
||||
T mappedObject = BeanUtils.instantiateClass(this.mappedClass);
|
||||
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(mappedObject);
|
||||
initBeanWrapper(bw);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -161,9 +161,9 @@ public class ConnectionHolder extends ResourceHolderSupport {
|
|||
*/
|
||||
public boolean supportsSavepoints() throws SQLException {
|
||||
if (this.savepointsSupported == null) {
|
||||
this.savepointsSupported = new Boolean(getConnection().getMetaData().supportsSavepoints());
|
||||
this.savepointsSupported = getConnection().getMetaData().supportsSavepoints();
|
||||
}
|
||||
return this.savepointsSupported.booleanValue();
|
||||
return this.savepointsSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -192,7 +192,7 @@ public class SQLErrorCodes {
|
|||
try {
|
||||
this.customSqlExceptionTranslator = customTranslatorClass.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Unable to instantiate custom translator", ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -88,7 +88,7 @@ class JcaListenerContainerParser extends AbstractListenerContainerParser {
|
|||
|
||||
String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE);
|
||||
if (StringUtils.hasText(prefetch)) {
|
||||
properties.add("prefetchSize", new Integer(prefetch));
|
||||
properties.add("prefetchSize", Integer.valueOf(prefetch));
|
||||
}
|
||||
|
||||
return properties;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ import org.springframework.util.StringUtils;
|
|||
* </pre>
|
||||
*
|
||||
* <p>Note that the above examples aim to demonstrate the general idea of using
|
||||
* header accessors. The most likely usage however is through sub-classes.
|
||||
* header accessors. The most likely usage however is through subclasses.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@
|
|||
|
||||
package org.springframework.messaging.simp.stomp;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
|
@ -51,6 +46,14 @@ import org.springframework.util.MimeType;
|
|||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.notNull;
|
||||
import static org.mockito.Mockito.same;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultStompSession}.
|
||||
*
|
||||
|
|
@ -80,7 +83,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
this.sessionHandler = mock(StompSessionHandler.class);
|
||||
|
|
@ -96,7 +98,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void afterConnected() throws Exception {
|
||||
|
||||
assertFalse(this.session.isConnected());
|
||||
this.connectHeaders.setHost("my-host");
|
||||
this.connectHeaders.setHeartbeat(new long[] {11, 12});
|
||||
|
|
@ -122,7 +123,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void handleConnectedFrame() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -141,7 +141,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void heartbeatValues() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -164,7 +163,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void heartbeatNotSupportedByServer() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
verify(this.connection).send(any());
|
||||
|
||||
|
|
@ -181,7 +179,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void heartbeatTasks() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
verify(this.connection).send(any());
|
||||
|
||||
|
|
@ -217,7 +214,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void handleErrorFrame() throws Exception {
|
||||
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
|
||||
accessor.setContentType(new MimeType("text", "plain", UTF_8));
|
||||
accessor.addNativeHeader("foo", "bar");
|
||||
|
|
@ -236,7 +232,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void handleErrorFrameWithEmptyPayload() throws Exception {
|
||||
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
|
||||
accessor.addNativeHeader("foo", "bar");
|
||||
accessor.setLeaveMutable(true);
|
||||
|
|
@ -249,7 +244,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void handleErrorFrameWithConversionException() throws Exception {
|
||||
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
|
||||
accessor.setContentType(MimeTypeUtils.APPLICATION_JSON);
|
||||
accessor.addNativeHeader("foo", "bar");
|
||||
|
|
@ -269,7 +263,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void handleMessageFrame() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
|
||||
StompFrameHandler frameHandler = mock(StompFrameHandler.class);
|
||||
|
|
@ -296,7 +289,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void handleMessageFrameWithConversionException() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -344,7 +336,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void send() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -361,13 +352,12 @@ public class DefaultStompSessionTests {
|
|||
|
||||
assertEquals(destination, stompHeaders.getDestination());
|
||||
assertEquals(new MimeType("text", "plain", UTF_8), stompHeaders.getContentType());
|
||||
assertEquals(-1, stompHeaders.getContentLength()); // StompEncoder isn't involved
|
||||
assertEquals(-1, stompHeaders.getContentLength()); // StompEncoder isn't involved
|
||||
assertEquals(payload, new String(message.getPayload(), UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendWithReceipt() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -391,7 +381,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void sendWithConversionException() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -407,7 +396,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void sendWithExecutionException() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -426,7 +414,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void subscribe() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -446,7 +433,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void subscribeWithHeaders() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -473,7 +459,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void unsubscribe() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -493,7 +478,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void ack() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -511,7 +495,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void nack() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
@ -529,7 +512,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void receiptReceived() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
this.session.setTaskScheduler(mock(TaskScheduler.class));
|
||||
|
||||
|
|
@ -554,7 +536,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void receiptReceivedBeforeTaskAdded() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
this.session.setTaskScheduler(mock(TaskScheduler.class));
|
||||
|
||||
|
|
@ -579,7 +560,6 @@ public class DefaultStompSessionTests {
|
|||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void receiptNotReceived() throws Exception {
|
||||
|
||||
TaskScheduler taskScheduler = mock(TaskScheduler.class);
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
|
|
@ -611,7 +591,6 @@ public class DefaultStompSessionTests {
|
|||
|
||||
@Test
|
||||
public void disconnect() throws Exception {
|
||||
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -33,6 +33,7 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.messaging.Message;
|
||||
|
|
@ -48,9 +49,7 @@ import org.springframework.messaging.support.MessageBuilder;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link StompBrokerRelayMessageHandler} running against ActiveMQ.
|
||||
|
|
@ -59,13 +58,14 @@ import static org.junit.Assert.assertTrue;
|
|||
*/
|
||||
public class StompBrokerRelayMessageHandlerIntegrationTests {
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
|
||||
@Rule
|
||||
public final TestName testName = new TestName();
|
||||
|
||||
private static final Log logger = LogFactory.getLog(StompBrokerRelayMessageHandlerIntegrationTests.class);
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private StompBrokerRelayMessageHandler relay;
|
||||
|
||||
private BrokerService activeMQBroker;
|
||||
|
|
@ -142,9 +142,9 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
logger.debug("Broker stopped");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void publishSubscribe() throws Exception {
|
||||
|
||||
logger.debug("Starting test publishSubscribe()");
|
||||
|
||||
String sess1 = "sess1";
|
||||
|
|
@ -167,7 +167,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
this.responseHandler.expectMessages(send);
|
||||
}
|
||||
|
||||
@Test(expected=MessageDeliveryException.class)
|
||||
@Test(expected = MessageDeliveryException.class)
|
||||
public void messageDeliveryExceptionIfSystemSessionForwardFails() throws Exception {
|
||||
|
||||
logger.debug("Starting test messageDeliveryExceptionIfSystemSessionForwardFails()");
|
||||
|
|
@ -181,7 +181,6 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void brokerBecomingUnvailableTriggersErrorFrame() throws Exception {
|
||||
|
||||
logger.debug("Starting test brokerBecomingUnvailableTriggersErrorFrame()");
|
||||
|
||||
String sess1 = "sess1";
|
||||
|
|
@ -197,7 +196,6 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void brokerAvailabilityEventWhenStopped() throws Exception {
|
||||
|
||||
logger.debug("Starting test brokerAvailabilityEventWhenStopped()");
|
||||
|
||||
stopActiveMqBrokerAndAwait();
|
||||
|
|
@ -206,7 +204,6 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void relayReconnectsIfBrokerComesBackUp() throws Exception {
|
||||
|
||||
logger.debug("Starting test relayReconnectsIfBrokerComesBackUp()");
|
||||
|
||||
String sess1 = "sess1";
|
||||
|
|
@ -232,7 +229,6 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void disconnectWithReceipt() throws Exception {
|
||||
|
||||
logger.debug("Starting test disconnectWithReceipt()");
|
||||
|
||||
MessageExchange connect = MessageExchangeBuilder.connect("sess1").build();
|
||||
|
|
@ -270,6 +266,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestMessageHandler implements MessageHandler {
|
||||
|
||||
private final BlockingQueue<Message<?>> queue = new LinkedBlockingQueue<>();
|
||||
|
|
@ -283,17 +280,13 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
|
||||
public void expectMessages(MessageExchange... messageExchanges) throws InterruptedException {
|
||||
|
||||
List<MessageExchange> expectedMessages =
|
||||
new ArrayList<MessageExchange>(Arrays.<MessageExchange>asList(messageExchanges));
|
||||
|
||||
while (expectedMessages.size() > 0) {
|
||||
Message<?> message = this.queue.poll(10000, TimeUnit.MILLISECONDS);
|
||||
assertNotNull("Timed out waiting for messages, expected [" + expectedMessages + "]", message);
|
||||
|
||||
MessageExchange match = findMatch(expectedMessages, message);
|
||||
assertNotNull("Unexpected message=" + message + ", expected [" + expectedMessages + "]", match);
|
||||
|
||||
expectedMessages.remove(match);
|
||||
}
|
||||
}
|
||||
|
|
@ -308,6 +301,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Holds a message as well as expected and actual messages matched against expectations.
|
||||
*/
|
||||
|
|
@ -343,6 +337,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class MessageExchangeBuilder {
|
||||
|
||||
private final Message<?> message;
|
||||
|
|
@ -351,8 +346,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
|
||||
private final List<MessageMatcher> expected = new ArrayList<>();
|
||||
|
||||
|
||||
private MessageExchangeBuilder(Message<?> message) {
|
||||
public MessageExchangeBuilder(Message<?> message) {
|
||||
this.message = message;
|
||||
this.headers = StompHeaderAccessor.wrap(message);
|
||||
}
|
||||
|
|
@ -442,25 +436,24 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
private static interface MessageMatcher {
|
||||
|
||||
private interface MessageMatcher {
|
||||
|
||||
boolean match(Message<?> message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class StompFrameMessageMatcher implements MessageMatcher {
|
||||
|
||||
private final StompCommand command;
|
||||
|
||||
private final String sessionId;
|
||||
|
||||
|
||||
public StompFrameMessageMatcher(StompCommand command, String sessionId) {
|
||||
this.command = command;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean match(Message<?> message) {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
|
||||
|
|
@ -480,6 +473,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class StompReceiptFrameMessageMatcher extends StompFrameMessageMatcher {
|
||||
|
||||
private final String receiptId;
|
||||
|
|
@ -500,6 +494,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class StompMessageFrameMessageMatcher extends StompFrameMessageMatcher {
|
||||
|
||||
private final String subscriptionId;
|
||||
|
|
@ -508,7 +503,6 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
|
||||
private final Object payload;
|
||||
|
||||
|
||||
public StompMessageFrameMessageMatcher(String sessionId, String subscriptionId, String destination, Object payload) {
|
||||
super(StompCommand.MESSAGE, sessionId);
|
||||
this.subscriptionId = subscriptionId;
|
||||
|
|
@ -536,18 +530,17 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
|
|||
}
|
||||
|
||||
protected String getPayloadAsText() {
|
||||
return (this.payload instanceof byte[])
|
||||
? new String((byte[]) this.payload, UTF_8) : payload.toString();
|
||||
return (this.payload instanceof byte[]) ?
|
||||
new String((byte[]) this.payload, UTF_8) : this.payload.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static class StompConnectedFrameMessageMatcher extends StompFrameMessageMatcher {
|
||||
|
||||
private static class StompConnectedFrameMessageMatcher extends StompFrameMessageMatcher {
|
||||
|
||||
public StompConnectedFrameMessageMatcher(String sessionId) {
|
||||
super(StompCommand.CONNECTED, sessionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@ configurations {
|
|||
}
|
||||
dependencies {
|
||||
castor "org.codehaus.castor:castor-anttasks:1.4.1"
|
||||
castor "org.apache.velocity:velocity:1.7"
|
||||
jibx "org.jibx:jibx-bind:1.2.6"
|
||||
xjc "com.sun.xml.bind:jaxb-xjc:2.1.17"
|
||||
xmlbeans "org.apache.xmlbeans:xmlbeans:2.6.0"
|
||||
jibx "org.jibx:jibx-bind:1.2.6"
|
||||
jibx "bcel:bcel:5.1"
|
||||
}
|
||||
|
||||
ext.genSourcesDir = "${buildDir}/generated-sources"
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -18,6 +18,7 @@ package org.springframework.test.web.client;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
@ -43,6 +44,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||
*/
|
||||
public class MockMvcClientHttpRequestFactory implements ClientHttpRequestFactory {
|
||||
|
||||
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
private final MockMvc mockMvc;
|
||||
|
||||
|
||||
|
|
@ -50,6 +53,7 @@ public class MockMvcClientHttpRequestFactory implements ClientHttpRequestFactory
|
|||
this.mockMvc = mockMvc;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ClientHttpRequest createRequest(final URI uri, final HttpMethod httpMethod) throws IOException {
|
||||
return new MockClientHttpRequest(httpMethod, uri) {
|
||||
|
|
@ -73,7 +77,7 @@ public class MockMvcClientHttpRequestFactory implements ClientHttpRequestFactory
|
|||
return clientResponse;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
byte[] body = ex.toString().getBytes("UTF-8");
|
||||
byte[] body = ex.toString().getBytes(UTF8_CHARSET);
|
||||
return new MockClientHttpResponse(body, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -13,12 +13,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.web.client.response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
@ -38,6 +39,9 @@ import org.springframework.util.Assert;
|
|||
*/
|
||||
public class DefaultResponseCreator implements ResponseCreator {
|
||||
|
||||
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
|
||||
private byte[] content;
|
||||
|
||||
private Resource contentResource;
|
||||
|
|
@ -56,6 +60,7 @@ public class DefaultResponseCreator implements ResponseCreator {
|
|||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException {
|
||||
MockClientHttpResponse response;
|
||||
|
|
@ -74,13 +79,7 @@ public class DefaultResponseCreator implements ResponseCreator {
|
|||
* Set the body as a UTF-8 String.
|
||||
*/
|
||||
public DefaultResponseCreator body(String content) {
|
||||
try {
|
||||
this.content = content.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// should not happen, UTF-8 is always supported
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
this.content = content.getBytes(UTF8_CHARSET);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -78,6 +79,9 @@ import org.springframework.web.util.UriUtils;
|
|||
public class MockHttpServletRequestBuilder
|
||||
implements ConfigurableSmartRequestBuilder<MockHttpServletRequestBuilder>, Mergeable {
|
||||
|
||||
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
|
||||
private final String method;
|
||||
|
||||
private final URI url;
|
||||
|
|
@ -272,12 +276,7 @@ public class MockHttpServletRequestBuilder
|
|||
* @param content the body content
|
||||
*/
|
||||
public MockHttpServletRequestBuilder content(String content) {
|
||||
try {
|
||||
this.content = content.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// should never happen
|
||||
}
|
||||
this.content = content.getBytes(UTF8_CHARSET);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ package org.springframework.http;
|
|||
* @author Arjen Poutsma
|
||||
* @author Sebastien Deleuze
|
||||
* @author Brian Clozel
|
||||
* @since 3.0
|
||||
* @see HttpStatus.Series
|
||||
* @see <a href="http://www.iana.org/assignments/http-status-codes">HTTP Status Code Registry</a>
|
||||
* @see <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes">List of HTTP status codes - Wikipedia</a>
|
||||
|
|
|
|||
|
|
@ -725,7 +725,7 @@ public class Jackson2ObjectMapperBuilder {
|
|||
try {
|
||||
Class<? extends Module> jdk7Module = (Class<? extends Module>)
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.jdk7.Jdk7Module", this.moduleClassLoader);
|
||||
objectMapper.registerModule(BeanUtils.instantiate(jdk7Module));
|
||||
objectMapper.registerModule(BeanUtils.instantiateClass(jdk7Module));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// jackson-datatype-jdk7 not available
|
||||
|
|
@ -737,7 +737,7 @@ public class Jackson2ObjectMapperBuilder {
|
|||
try {
|
||||
Class<? extends Module> jdk8Module = (Class<? extends Module>)
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.jdk8.Jdk8Module", this.moduleClassLoader);
|
||||
objectMapper.registerModule(BeanUtils.instantiate(jdk8Module));
|
||||
objectMapper.registerModule(BeanUtils.instantiateClass(jdk8Module));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// jackson-datatype-jdk8 not available
|
||||
|
|
@ -749,7 +749,7 @@ public class Jackson2ObjectMapperBuilder {
|
|||
try {
|
||||
Class<? extends Module> javaTimeModule = (Class<? extends Module>)
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.jsr310.JavaTimeModule", this.moduleClassLoader);
|
||||
objectMapper.registerModule(BeanUtils.instantiate(javaTimeModule));
|
||||
objectMapper.registerModule(BeanUtils.instantiateClass(javaTimeModule));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// jackson-datatype-jsr310 not available
|
||||
|
|
@ -761,7 +761,7 @@ public class Jackson2ObjectMapperBuilder {
|
|||
try {
|
||||
Class<? extends Module> jodaModule = (Class<? extends Module>)
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.joda.JodaModule", this.moduleClassLoader);
|
||||
objectMapper.registerModule(BeanUtils.instantiate(jodaModule));
|
||||
objectMapper.registerModule(BeanUtils.instantiateClass(jodaModule));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// jackson-datatype-joda not available
|
||||
|
|
@ -773,7 +773,7 @@ public class Jackson2ObjectMapperBuilder {
|
|||
try {
|
||||
Class<? extends Module> kotlinModule = (Class<? extends Module>)
|
||||
ClassUtils.forName("com.fasterxml.jackson.module.kotlin.KotlinModule", this.moduleClassLoader);
|
||||
objectMapper.registerModule(BeanUtils.instantiate(kotlinModule));
|
||||
objectMapper.registerModule(BeanUtils.instantiateClass(kotlinModule));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// jackson-module-kotlin not available
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
@ -39,7 +39,6 @@ import org.springframework.http.converter.HttpMessageNotReadableException;
|
|||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
|
||||
/**
|
||||
* An {@code HttpMessageConverter} that reads and writes {@link com.google.protobuf.Message}s
|
||||
* using <a href="https://developers.google.com/protocol-buffers/">Google Protocol Buffers</a>.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -175,9 +175,8 @@ public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMe
|
|||
}
|
||||
catch (NullPointerException ex) {
|
||||
if (!isSupportDtd()) {
|
||||
throw new HttpMessageNotReadableException("NPE while unmarshalling. " +
|
||||
"This can happen on JDK 1.6 due to the presence of DTD " +
|
||||
"declarations, which are disabled.", ex);
|
||||
throw new HttpMessageNotReadableException("NPE while unmarshalling: " +
|
||||
"This can happen due to the presence of DTD declarations which are disabled.", ex);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
|
@ -191,14 +190,14 @@ public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMe
|
|||
|
||||
private SAXSource readSAXSource(InputStream body) throws IOException {
|
||||
try {
|
||||
XMLReader reader = XMLReaderFactory.createXMLReader();
|
||||
reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
reader.setFeature("http://xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
|
||||
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
if (!isProcessExternalEntities()) {
|
||||
reader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
}
|
||||
byte[] bytes = StreamUtils.copyToByteArray(body);
|
||||
return new SAXSource(reader, new InputSource(new ByteArrayInputStream(bytes)));
|
||||
return new SAXSource(xmlReader, new InputSource(new ByteArrayInputStream(bytes)));
|
||||
}
|
||||
catch (SAXException ex) {
|
||||
throw new HttpMessageNotReadableException("Could not parse document: " + ex.getMessage(), ex);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -77,6 +77,7 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
|||
this.path = pathToUse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the ServletContext for this resource.
|
||||
*/
|
||||
|
|
@ -91,7 +92,6 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
|||
return this.path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This implementation checks {@code ServletContext.getResource}.
|
||||
* @see javax.servlet.ServletContext#getResource(String)
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||
|
||||
private final boolean encoded;
|
||||
|
||||
|
||||
/**
|
||||
* Package-private constructor. All arguments are optional, and can be {@code null}.
|
||||
* @param scheme the scheme
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public abstract class HtmlUtils {
|
|||
* http://www.w3.org/TR/html4/sgml/entities.html
|
||||
* </a>
|
||||
* @param input the (unescaped) input string
|
||||
* @param encoding The name of a supported {@link java.nio.charset.Charset charset}
|
||||
* @param encoding the name of a supported {@link java.nio.charset.Charset charset}
|
||||
* @return the escaped string
|
||||
* @since 4.1.2
|
||||
*/
|
||||
|
|
@ -125,7 +125,7 @@ public abstract class HtmlUtils {
|
|||
* http://www.w3.org/TR/html4/sgml/entities.html
|
||||
* </a>
|
||||
* @param input the (unescaped) input string
|
||||
* @param encoding The name of a supported {@link java.nio.charset.Charset charset}
|
||||
* @param encoding the name of a supported {@link java.nio.charset.Charset charset}
|
||||
* @return the escaped string
|
||||
* @since 4.1.2
|
||||
*/
|
||||
|
|
@ -177,7 +177,7 @@ public abstract class HtmlUtils {
|
|||
* http://www.w3.org/TR/html4/sgml/entities.html
|
||||
* </a>
|
||||
* @param input the (unescaped) input string
|
||||
* @param encoding The name of a supported {@link java.nio.charset.Charset charset}
|
||||
* @param encoding the name of a supported {@link java.nio.charset.Charset charset}
|
||||
* @return the escaped string
|
||||
* @since 4.1.2
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -179,8 +179,8 @@ public class UrlPathHelper {
|
|||
String sanitizedPathWithinApp = getSanitizedPath(pathWithinApp);
|
||||
String path;
|
||||
|
||||
// if the app container sanitized the servletPath, check against the sanitized version
|
||||
if (servletPath.indexOf(sanitizedPathWithinApp) != -1) {
|
||||
// If the app container sanitized the servletPath, check against the sanitized version
|
||||
if (servletPath.contains(sanitizedPathWithinApp)) {
|
||||
path = getRemainingPath(sanitizedPathWithinApp, servletPath, false);
|
||||
}
|
||||
else {
|
||||
|
|
@ -485,8 +485,8 @@ public class UrlPathHelper {
|
|||
* @return the updated URI string
|
||||
*/
|
||||
public String removeSemicolonContent(String requestUri) {
|
||||
return this.removeSemicolonContent ?
|
||||
removeSemicolonContentInternal(requestUri) : removeJsessionid(requestUri);
|
||||
return (this.removeSemicolonContent ?
|
||||
removeSemicolonContentInternal(requestUri) : removeJsessionid(requestUri));
|
||||
}
|
||||
|
||||
private String removeSemicolonContentInternal(String requestUri) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -42,13 +42,13 @@ import static org.junit.Assert.assertTrue;
|
|||
*/
|
||||
public class AtomFeedHttpMessageConverterTests {
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private AtomFeedHttpMessageConverter converter;
|
||||
|
||||
private Charset utf8;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
utf8 = Charset.forName("UTF-8");
|
||||
converter = new AtomFeedHttpMessageConverter();
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
}
|
||||
|
|
@ -56,20 +56,20 @@ public class AtomFeedHttpMessageConverterTests {
|
|||
@Test
|
||||
public void canRead() {
|
||||
assertTrue(converter.canRead(Feed.class, new MediaType("application", "atom+xml")));
|
||||
assertTrue(converter.canRead(Feed.class, new MediaType("application", "atom+xml", utf8)));
|
||||
assertTrue(converter.canRead(Feed.class, new MediaType("application", "atom+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
assertTrue(converter.canWrite(Feed.class, new MediaType("application", "atom+xml")));
|
||||
assertTrue(converter.canWrite(Feed.class, new MediaType("application", "atom+xml", Charset.forName("UTF-8"))));
|
||||
assertTrue(converter.canWrite(Feed.class, new MediaType("application", "atom+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream("atom.xml");
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(is);
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "atom+xml", utf8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "atom+xml", UTF_8));
|
||||
Feed result = converter.read(Feed.class, inputMessage);
|
||||
assertEquals("title", result.getTitle());
|
||||
assertEquals("subtitle", result.getSubtitle().getValue());
|
||||
|
|
@ -106,12 +106,12 @@ public class AtomFeedHttpMessageConverterTests {
|
|||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
converter.write(feed, null, outputMessage);
|
||||
|
||||
assertEquals("Invalid content-type", new MediaType("application", "atom+xml", utf8),
|
||||
assertEquals("Invalid content-type", new MediaType("application", "atom+xml", UTF_8),
|
||||
outputMessage.getHeaders().getContentType());
|
||||
String expected = "<feed xmlns=\"http://www.w3.org/2005/Atom\">" + "<title>title</title>" +
|
||||
"<entry><id>id1</id><title>title1</title></entry>" +
|
||||
"<entry><id>id2</id><title>title2</title></entry></feed>";
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -42,34 +42,35 @@ import static org.junit.Assert.assertTrue;
|
|||
*/
|
||||
public class RssChannelHttpMessageConverterTests {
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private RssChannelHttpMessageConverter converter;
|
||||
|
||||
private Charset utf8;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
utf8 = Charset.forName("UTF-8");
|
||||
converter = new RssChannelHttpMessageConverter();
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
assertTrue(converter.canRead(Channel.class, new MediaType("application", "rss+xml")));
|
||||
assertTrue(converter.canRead(Channel.class, new MediaType("application", "rss+xml", utf8)));
|
||||
assertTrue(converter.canRead(Channel.class, new MediaType("application", "rss+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
assertTrue(converter.canWrite(Channel.class, new MediaType("application", "rss+xml")));
|
||||
assertTrue(converter.canWrite(Channel.class, new MediaType("application", "rss+xml", Charset.forName("UTF-8"))));
|
||||
assertTrue(converter.canWrite(Channel.class, new MediaType("application", "rss+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream("rss.xml");
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(is);
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "rss+xml", utf8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "rss+xml", UTF_8));
|
||||
Channel result = converter.read(Channel.class, inputMessage);
|
||||
assertEquals("title", result.getTitle());
|
||||
assertEquals("http://example.com", result.getLink());
|
||||
|
|
@ -106,14 +107,14 @@ public class RssChannelHttpMessageConverterTests {
|
|||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
converter.write(channel, null, outputMessage);
|
||||
|
||||
assertEquals("Invalid content-type", new MediaType("application", "rss+xml", utf8),
|
||||
assertEquals("Invalid content-type", new MediaType("application", "rss+xml", UTF_8),
|
||||
outputMessage.getHeaders().getContentType());
|
||||
String expected = "<rss version=\"2.0\">" +
|
||||
"<channel><title>title</title><link>http://example.com</link><description>description</description>" +
|
||||
"<item><title>title1</title></item>" +
|
||||
"<item><title>title2</title></item>" +
|
||||
"</channel></rss>";
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -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,7 +127,7 @@ public class JaxWsSupportTests {
|
|||
}
|
||||
catch (BeanCreationException ex) {
|
||||
if ("exporter".equals(ex.getBeanName()) && ex.getRootCause() instanceof ClassNotFoundException) {
|
||||
// ignore - probably running on JDK < 1.6 without the JAX-WS impl present
|
||||
// ignore - probably running on JDK without the JAX-WS impl present
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
|
|
@ -146,7 +146,7 @@ public class JaxWsSupportTests {
|
|||
|
||||
public OrderService myService;
|
||||
|
||||
@WebServiceRef(value=OrderServiceService.class, wsdlLocation = "http://localhost:9999/OrderService?wsdl")
|
||||
@WebServiceRef(value = OrderServiceService.class, wsdlLocation = "http://localhost:9999/OrderService?wsdl")
|
||||
public void setMyService(OrderService myService) {
|
||||
this.myService = myService;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
<!-- File containing all charcter entity references definied
|
||||
<!-- File containing all character entity references defined
|
||||
by the HTML 4.0 standard. -->
|
||||
<!-- Valuable informations and a complete description of the
|
||||
<!-- Valuable information and a complete description of the
|
||||
HTML 4.0 character set can be found at
|
||||
http://www.w3.org/TR/html4/charset.html.
|
||||
-->
|
||||
|
||||
|
||||
http://www.w3.org/TR/html4/charset.html. -->
|
||||
|
||||
<!-- Portions © International Organization for Standardization 1986
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public class PortletContextResource extends AbstractFileResolvingResource implem
|
|||
this.path = pathToUse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the PortletContext for this resource.
|
||||
*/
|
||||
|
|
@ -91,7 +92,6 @@ public class PortletContextResource extends AbstractFileResolvingResource implem
|
|||
return this.path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This implementation checks {@code PortletContext.getResource}.
|
||||
* @see javax.portlet.PortletContext#getResource(String)
|
||||
|
|
|
|||
|
|
@ -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,6 +46,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
|
|||
/** The default name of the exception attribute: "exception". */
|
||||
public static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception";
|
||||
|
||||
|
||||
private Properties exceptionMappings;
|
||||
|
||||
private Class<?>[] excludedExceptions;
|
||||
|
|
@ -108,7 +109,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
|
|||
public void setStatusCodes(Properties statusCodes) {
|
||||
for (Enumeration<?> enumeration = statusCodes.propertyNames(); enumeration.hasMoreElements();) {
|
||||
String viewName = (String) enumeration.nextElement();
|
||||
Integer statusCode = new Integer(statusCodes.getProperty(viewName));
|
||||
Integer statusCode = Integer.valueOf(statusCodes.getProperty(viewName));
|
||||
this.statusCodes.put(viewName, statusCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -78,13 +78,11 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
* @author Juergen Hoeller
|
||||
* @since 1.1.1
|
||||
* @see ServletForwardingController
|
||||
* @see org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor
|
||||
* @see org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
|
||||
*/
|
||||
public class ServletWrappingController extends AbstractController
|
||||
implements BeanNameAware, InitializingBean, DisposableBean {
|
||||
|
||||
private Class<?> servletClass;
|
||||
private Class<? extends Servlet> servletClass;
|
||||
|
||||
private String servletName;
|
||||
|
||||
|
|
@ -105,7 +103,7 @@ public class ServletWrappingController extends AbstractController
|
|||
* Needs to implement {@code javax.servlet.Servlet}.
|
||||
* @see javax.servlet.Servlet
|
||||
*/
|
||||
public void setServletClass(Class<?> servletClass) {
|
||||
public void setServletClass(Class<? extends Servlet> servletClass) {
|
||||
this.servletClass = servletClass;
|
||||
}
|
||||
|
||||
|
|
@ -142,12 +140,12 @@ public class ServletWrappingController extends AbstractController
|
|||
}
|
||||
if (!Servlet.class.isAssignableFrom(this.servletClass)) {
|
||||
throw new IllegalArgumentException("servletClass [" + this.servletClass.getName() +
|
||||
"] needs to implement interface [javax.servlet.Servlet]");
|
||||
"] needs to implement interface [javax.servlet.Servlet]");
|
||||
}
|
||||
if (this.servletName == null) {
|
||||
this.servletName = this.beanName;
|
||||
}
|
||||
this.servletInstance = (Servlet) this.servletClass.newInstance();
|
||||
this.servletInstance = this.servletClass.newInstance();
|
||||
this.servletInstance.init(new DelegatingServletConfig());
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +156,7 @@ public class ServletWrappingController extends AbstractController
|
|||
*/
|
||||
@Override
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
|
||||
this.servletInstance.service(request, response);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ public class MvcUriComponentsBuilder {
|
|||
try {
|
||||
proxy = proxyClass.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Unable to instantiate controller proxy using Objenesis, " +
|
||||
"and regular controller instantiation via default constructor fails as well", ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -73,7 +73,7 @@ import org.springframework.web.util.WebUtils;
|
|||
*/
|
||||
public class XsltView extends AbstractUrlBasedView {
|
||||
|
||||
private Class<?> transformerFactoryClass;
|
||||
private Class<? extends TransformerFactory> transformerFactoryClass;
|
||||
|
||||
private String sourceKey;
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public class XsltView extends AbstractUrlBasedView {
|
|||
* <p>The default constructor of the specified class will be called
|
||||
* to build the TransformerFactory for this view.
|
||||
*/
|
||||
public void setTransformerFactoryClass(Class<?> transformerFactoryClass) {
|
||||
public void setTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass) {
|
||||
Assert.isAssignable(TransformerFactory.class, transformerFactoryClass);
|
||||
this.transformerFactoryClass = transformerFactoryClass;
|
||||
}
|
||||
|
|
@ -195,10 +195,10 @@ public class XsltView extends AbstractUrlBasedView {
|
|||
* @see #setTransformerFactoryClass
|
||||
* @see #getTransformerFactory()
|
||||
*/
|
||||
protected TransformerFactory newTransformerFactory(Class<?> transformerFactoryClass) {
|
||||
protected TransformerFactory newTransformerFactory(Class<? extends TransformerFactory> transformerFactoryClass) {
|
||||
if (transformerFactoryClass != null) {
|
||||
try {
|
||||
return (TransformerFactory) transformerFactoryClass.newInstance();
|
||||
return transformerFactoryClass.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new TransformerFactoryConfigurationError(ex, "Could not instantiate TransformerFactory");
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -72,25 +72,23 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
|||
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
|
||||
private static final ClassLoader classLoader = AbstractHandshakeHandler.class.getClassLoader();
|
||||
|
||||
private static final boolean jettyWsPresent = ClassUtils.isPresent(
|
||||
"org.eclipse.jetty.websocket.server.WebSocketServerFactory", classLoader);
|
||||
"org.eclipse.jetty.websocket.server.WebSocketServerFactory", AbstractHandshakeHandler.class.getClassLoader());
|
||||
|
||||
private static final boolean tomcatWsPresent = ClassUtils.isPresent(
|
||||
"org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", classLoader);
|
||||
"org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", AbstractHandshakeHandler.class.getClassLoader());
|
||||
|
||||
private static final boolean undertowWsPresent = ClassUtils.isPresent(
|
||||
"io.undertow.websockets.jsr.ServerWebSocketContainer", classLoader);
|
||||
"io.undertow.websockets.jsr.ServerWebSocketContainer", AbstractHandshakeHandler.class.getClassLoader());
|
||||
|
||||
private static final boolean glassfishWsPresent = ClassUtils.isPresent(
|
||||
"org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", classLoader);
|
||||
"org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", AbstractHandshakeHandler.class.getClassLoader());
|
||||
|
||||
private static final boolean weblogicWsPresent = ClassUtils.isPresent(
|
||||
"weblogic.websocket.tyrus.TyrusServletWriter", classLoader);
|
||||
"weblogic.websocket.tyrus.TyrusServletWriter", AbstractHandshakeHandler.class.getClassLoader());
|
||||
|
||||
private static final boolean websphereWsPresent = ClassUtils.isPresent(
|
||||
"com.ibm.websphere.wsoc.WsWsocServerContainer", classLoader);
|
||||
"com.ibm.websphere.wsoc.WsWsocServerContainer", AbstractHandshakeHandler.class.getClassLoader());
|
||||
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
|
@ -146,7 +144,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
|||
}
|
||||
|
||||
try {
|
||||
Class<?> clazz = ClassUtils.forName(className, classLoader);
|
||||
Class<?> clazz = ClassUtils.forName(className, AbstractHandshakeHandler.class.getClassLoader());
|
||||
return (RequestUpgradeStrategy) clazz.newInstance();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue