Polishing (includes varargs for selected setters)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -120,9 +120,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
/** Non-null if after returning advice binds the return value */
|
||||
private String returningName = null;
|
||||
|
||||
private Class discoveredReturningType = Object.class;
|
||||
private Class<?> discoveredReturningType = Object.class;
|
||||
|
||||
private Class discoveredThrowingType = Object.class;
|
||||
private Class<?> discoveredThrowingType = Object.class;
|
||||
|
||||
/**
|
||||
* Index for thisJoinPoint argument (currently only
|
||||
@@ -238,7 +238,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
setArgumentNamesFromStringArray(tokens);
|
||||
}
|
||||
|
||||
public void setArgumentNamesFromStringArray(String[] args) {
|
||||
public void setArgumentNamesFromStringArray(String... args) {
|
||||
this.argumentNames = new String[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
this.argumentNames[i] = StringUtils.trimWhitespace(args[i]);
|
||||
@@ -251,7 +251,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
if (argumentNames != null) {
|
||||
if (aspectJAdviceMethod.getParameterTypes().length == argumentNames.length + 1) {
|
||||
// May need to add implicit join point arg name...
|
||||
Class firstArgType = aspectJAdviceMethod.getParameterTypes()[0];
|
||||
Class<?> firstArgType = aspectJAdviceMethod.getParameterTypes()[0];
|
||||
if (firstArgType == JoinPoint.class ||
|
||||
firstArgType == ProceedingJoinPoint.class ||
|
||||
firstArgType == JoinPoint.StaticPart.class) {
|
||||
@@ -290,7 +290,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
}
|
||||
|
||||
protected Class getDiscoveredReturningType() {
|
||||
protected Class<?> getDiscoveredReturningType() {
|
||||
return this.discoveredReturningType;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
}
|
||||
|
||||
protected Class getDiscoveredThrowingType() {
|
||||
protected Class<?> getDiscoveredThrowingType() {
|
||||
return this.discoveredThrowingType;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
|
||||
int numUnboundArgs = this.adviceInvocationArgumentCount;
|
||||
Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||
Class<?>[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
|
||||
numUnboundArgs--;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
this.argumentsIntrospected = true;
|
||||
}
|
||||
|
||||
private boolean maybeBindJoinPoint(Class candidateParameterType) {
|
||||
private boolean maybeBindJoinPoint(Class<?> candidateParameterType) {
|
||||
if (candidateParameterType.equals(JoinPoint.class)) {
|
||||
this.joinPointArgumentIndex = 0;
|
||||
return true;
|
||||
@@ -388,7 +388,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
}
|
||||
|
||||
private boolean maybeBindProceedingJoinPoint(Class candidateParameterType) {
|
||||
private boolean maybeBindProceedingJoinPoint(Class<?> candidateParameterType) {
|
||||
if (candidateParameterType.equals(ProceedingJoinPoint.class)) {
|
||||
if (!supportsProceedingJoinPoint()) {
|
||||
throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
|
||||
@@ -405,7 +405,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean maybeBindJoinPointStaticPart(Class candidateParameterType) {
|
||||
private boolean maybeBindJoinPointStaticPart(Class<?> candidateParameterType) {
|
||||
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
|
||||
this.joinPointStaticPartArgumentIndex = 0;
|
||||
return true;
|
||||
@@ -509,8 +509,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
numParametersToRemove++;
|
||||
}
|
||||
String[] pointcutParameterNames = new String[this.argumentNames.length - numParametersToRemove];
|
||||
Class[] pointcutParameterTypes = new Class[pointcutParameterNames.length];
|
||||
Class[] methodParameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||
Class<?>[] pointcutParameterTypes = new Class<?>[pointcutParameterNames.length];
|
||||
Class<?>[] methodParameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < this.argumentNames.length; i++) {
|
||||
@@ -678,7 +678,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
this.adviceMethod = adviceMethod;
|
||||
}
|
||||
|
||||
public boolean matches(Method method, Class targetClass) {
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
return !this.adviceMethod.equals(method);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,24 +39,24 @@ public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdv
|
||||
this.pointcut.setExpression(expression);
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return this.pointcut.getExpression();
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.pointcut.setLocation(location);
|
||||
}
|
||||
|
||||
public void setParameterTypes(Class[] types) {
|
||||
this.pointcut.setParameterTypes(types);
|
||||
}
|
||||
|
||||
public void setParameterNames(String[] names) {
|
||||
this.pointcut.setParameterNames(names);
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return this.pointcut.getLocation();
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return this.pointcut.getExpression();
|
||||
public void setParameterTypes(Class<?>[] types) {
|
||||
this.pointcut.setParameterTypes(types);
|
||||
}
|
||||
|
||||
public void setParameterNames(String... names) {
|
||||
this.pointcut.setParameterNames(names);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -133,7 +133,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
* @see #setInterfaces
|
||||
* @see AbstractSingletonProxyFactoryBean#setProxyInterfaces
|
||||
*/
|
||||
public void setProxyInterfaces(Class[] proxyInterfaces) throws ClassNotFoundException {
|
||||
public void setProxyInterfaces(Class<?>[] proxyInterfaces) throws ClassNotFoundException {
|
||||
setInterfaces(proxyInterfaces);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
* @see org.aopalliance.aop.Advice
|
||||
* @see org.springframework.aop.target.SingletonTargetSource
|
||||
*/
|
||||
public void setInterceptorNames(String[] interceptorNames) {
|
||||
public void setInterceptorNames(String... interceptorNames) {
|
||||
this.interceptorNames = interceptorNames;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
return this.singletonInstance.getClass();
|
||||
}
|
||||
}
|
||||
Class[] ifcs = getProxiedInterfaces();
|
||||
Class<?>[] ifcs = getProxiedInterfaces();
|
||||
if (ifcs.length == 1) {
|
||||
return ifcs[0];
|
||||
}
|
||||
@@ -292,7 +292,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
* @return the merged interface as Class
|
||||
* @see java.lang.reflect.Proxy#getProxyClass
|
||||
*/
|
||||
protected Class createCompositeInterface(Class[] interfaces) {
|
||||
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
|
||||
return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
this.targetSource = freshTargetSource();
|
||||
if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
|
||||
// Rely on AOP infrastructure to tell us what interfaces to proxy.
|
||||
Class targetClass = getTargetClass();
|
||||
Class<?> targetClass = getTargetClass();
|
||||
if (targetClass == null) {
|
||||
throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
|
||||
}
|
||||
@@ -396,7 +396,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
* @return {@code true} if it's an Advisor or Advice
|
||||
*/
|
||||
private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) {
|
||||
Class namedBeanClass = this.beanFactory.getType(beanName);
|
||||
Class<?> namedBeanClass = this.beanFactory.getType(beanName);
|
||||
if (namedBeanClass != null) {
|
||||
return (Advisor.class.isAssignableFrom(namedBeanClass) || Advice.class.isAssignableFrom(namedBeanClass));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -198,7 +198,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||
* Ordering is significant: The TargetSource returned from the first matching
|
||||
* TargetSourceCreator (that is, the first that returns non-null) will be used.
|
||||
*/
|
||||
public void setCustomTargetSourceCreators(TargetSourceCreator[] targetSourceCreators) {
|
||||
public void setCustomTargetSourceCreators(TargetSourceCreator... targetSourceCreators) {
|
||||
this.customTargetSourceCreators = targetSourceCreators;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||
* This is perfectly valid, if "specific" interceptors such as matching
|
||||
* Advisors are all we want.
|
||||
*/
|
||||
public void setInterceptorNames(String[] interceptorNames) {
|
||||
public void setInterceptorNames(String... interceptorNames) {
|
||||
this.interceptorNames = interceptorNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +60,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.BeanFactory#FACTORY_BEAN_PREFIX
|
||||
*/
|
||||
public void setBeanNames(String[] beanNames) {
|
||||
public void setBeanNames(String... beanNames) {
|
||||
Assert.notEmpty(beanNames, "'beanNames' must not be empty");
|
||||
this.beanNames = new ArrayList<String>(beanNames.length);
|
||||
for (String mappedName : beanNames) {
|
||||
@@ -73,7 +73,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||
* Identify as bean to proxy if the bean name is in the configured list of names.
|
||||
*/
|
||||
@Override
|
||||
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource targetSource) {
|
||||
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource) {
|
||||
if (this.beanNames != null) {
|
||||
for (String mappedName : this.beanNames) {
|
||||
if (FactoryBean.class.isAssignableFrom(beanClass)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
|
||||
* @see #setMappedNames
|
||||
*/
|
||||
public void setMappedName(String mappedName) {
|
||||
setMappedNames(new String[] {mappedName});
|
||||
setMappedNames(mappedName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
|
||||
* Matching will be the union of all these; if any match,
|
||||
* the pointcut matches.
|
||||
*/
|
||||
public void setMappedNames(String[] mappedNames) {
|
||||
public void setMappedNames(String... mappedNames) {
|
||||
this.mappedNames = new LinkedList<String>();
|
||||
if (mappedNames != null) {
|
||||
this.mappedNames.addAll(Arrays.asList(mappedNames));
|
||||
@@ -77,7 +77,8 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
|
||||
}
|
||||
|
||||
|
||||
public boolean matches(Method method, Class targetClass) {
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
for (String mappedName : this.mappedNames) {
|
||||
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,7 @@ public class NameMatchMethodPointcutAdvisor extends AbstractGenericPointcutAdvis
|
||||
* the pointcut matches.
|
||||
* @see NameMatchMethodPointcut#setMappedNames
|
||||
*/
|
||||
public void setMappedNames(String[] mappedNames) {
|
||||
public void setMappedNames(String... mappedNames) {
|
||||
this.pointcut.setMappedNames(mappedNames);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -98,7 +98,7 @@ public class RegexpMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor
|
||||
* @see #setPatterns
|
||||
*/
|
||||
public void setPattern(String pattern) {
|
||||
setPatterns(new String[] {pattern});
|
||||
setPatterns(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,7 @@ public class RegexpMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor
|
||||
* patterns matches, the pointcut matches.
|
||||
* @see AbstractRegexpMethodPointcut#setPatterns
|
||||
*/
|
||||
public void setPatterns(String[] patterns) {
|
||||
public void setPatterns(String... patterns) {
|
||||
this.patterns = patterns;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ import org.springframework.core.io.Resource;
|
||||
* <p>The mapping file should be in the following format, as specified by the
|
||||
* Java Activation Framework:
|
||||
*
|
||||
* <pre>
|
||||
* <pre class="code">
|
||||
* # map text/html to .htm and .html files
|
||||
* text/html html htm HTML HTM</pre>
|
||||
*
|
||||
@@ -93,7 +93,7 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali
|
||||
* Java Activation Framework, for example:<br>
|
||||
* {@code text/html html htm HTML HTM}
|
||||
*/
|
||||
public void setMappings(String[] mappings) {
|
||||
public void setMappings(String... mappings) {
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,6 +41,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@SuppressWarnings("serial")
|
||||
public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable {
|
||||
|
||||
@Override
|
||||
public Collection<CacheOperation> parseCacheAnnotations(AnnotatedElement ae) {
|
||||
Collection<CacheOperation> ops = null;
|
||||
|
||||
@@ -54,24 +55,25 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
|
||||
Collection<CacheEvict> evicts = getAnnotations(ae, CacheEvict.class);
|
||||
if (evicts != null) {
|
||||
ops = lazyInit(ops);
|
||||
for (CacheEvict e : evicts) {
|
||||
ops.add(parseEvictAnnotation(ae, e));
|
||||
for (CacheEvict evict : evicts) {
|
||||
ops.add(parseEvictAnnotation(ae, evict));
|
||||
}
|
||||
}
|
||||
Collection<CachePut> updates = getAnnotations(ae, CachePut.class);
|
||||
if (updates != null) {
|
||||
Collection<CachePut> puts = getAnnotations(ae, CachePut.class);
|
||||
if (puts != null) {
|
||||
ops = lazyInit(ops);
|
||||
for (CachePut p : updates) {
|
||||
ops.add(parseUpdateAnnotation(ae, p));
|
||||
for (CachePut put : puts) {
|
||||
ops.add(parsePutAnnotation(ae, put));
|
||||
}
|
||||
}
|
||||
Collection<Caching> caching = getAnnotations(ae, Caching.class);
|
||||
if (caching != null) {
|
||||
Collection<Caching> cachings = getAnnotations(ae, Caching.class);
|
||||
if (cachings != null) {
|
||||
ops = lazyInit(ops);
|
||||
for (Caching c : caching) {
|
||||
ops.addAll(parseCachingAnnotation(ae, c));
|
||||
for (Caching caching : cachings) {
|
||||
ops.addAll(parseCachingAnnotation(ae, caching));
|
||||
}
|
||||
}
|
||||
|
||||
return ops;
|
||||
}
|
||||
|
||||
@@ -80,34 +82,34 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
|
||||
}
|
||||
|
||||
CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, Cacheable caching) {
|
||||
CacheableOperation cuo = new CacheableOperation();
|
||||
cuo.setCacheNames(caching.value());
|
||||
cuo.setCondition(caching.condition());
|
||||
cuo.setUnless(caching.unless());
|
||||
cuo.setKey(caching.key());
|
||||
cuo.setName(ae.toString());
|
||||
return cuo;
|
||||
CacheableOperation op = new CacheableOperation();
|
||||
op.setCacheNames(caching.value());
|
||||
op.setCondition(caching.condition());
|
||||
op.setUnless(caching.unless());
|
||||
op.setKey(caching.key());
|
||||
op.setName(ae.toString());
|
||||
return op;
|
||||
}
|
||||
|
||||
CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, CacheEvict caching) {
|
||||
CacheEvictOperation ceo = new CacheEvictOperation();
|
||||
ceo.setCacheNames(caching.value());
|
||||
ceo.setCondition(caching.condition());
|
||||
ceo.setKey(caching.key());
|
||||
ceo.setCacheWide(caching.allEntries());
|
||||
ceo.setBeforeInvocation(caching.beforeInvocation());
|
||||
ceo.setName(ae.toString());
|
||||
return ceo;
|
||||
CacheEvictOperation op = new CacheEvictOperation();
|
||||
op.setCacheNames(caching.value());
|
||||
op.setCondition(caching.condition());
|
||||
op.setKey(caching.key());
|
||||
op.setCacheWide(caching.allEntries());
|
||||
op.setBeforeInvocation(caching.beforeInvocation());
|
||||
op.setName(ae.toString());
|
||||
return op;
|
||||
}
|
||||
|
||||
CacheOperation parseUpdateAnnotation(AnnotatedElement ae, CachePut caching) {
|
||||
CachePutOperation cuo = new CachePutOperation();
|
||||
cuo.setCacheNames(caching.value());
|
||||
cuo.setCondition(caching.condition());
|
||||
cuo.setUnless(caching.unless());
|
||||
cuo.setKey(caching.key());
|
||||
cuo.setName(ae.toString());
|
||||
return cuo;
|
||||
CacheOperation parsePutAnnotation(AnnotatedElement ae, CachePut caching) {
|
||||
CachePutOperation op = new CachePutOperation();
|
||||
op.setCacheNames(caching.value());
|
||||
op.setCondition(caching.condition());
|
||||
op.setUnless(caching.unless());
|
||||
op.setKey(caching.key());
|
||||
op.setName(ae.toString());
|
||||
return op;
|
||||
}
|
||||
|
||||
Collection<CacheOperation> parseCachingAnnotation(AnnotatedElement ae, Caching caching) {
|
||||
@@ -131,7 +133,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
|
||||
if (!ObjectUtils.isEmpty(updates)) {
|
||||
ops = lazyInit(ops);
|
||||
for (CachePut update : updates) {
|
||||
ops.add(parseUpdateAnnotation(ae, update));
|
||||
ops.add(parsePutAnnotation(ae, update));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,32 +23,29 @@ import java.util.Set;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class implementing {@link CacheOperation}.
|
||||
* Base class for cache operations.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @since 3.1
|
||||
*/
|
||||
public abstract class CacheOperation {
|
||||
|
||||
private Set<String> cacheNames = Collections.emptySet();
|
||||
private String condition = "";
|
||||
private String key = "";
|
||||
private String name = "";
|
||||
|
||||
private Set<String> cacheNames = Collections.emptySet();
|
||||
|
||||
public Set<String> getCacheNames() {
|
||||
return cacheNames;
|
||||
}
|
||||
private String key = "";
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
private String condition = "";
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
|
||||
public void setName(String name) {
|
||||
Assert.hasText(name);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setCacheName(String cacheName) {
|
||||
@@ -56,17 +53,16 @@ public abstract class CacheOperation {
|
||||
this.cacheNames = Collections.singleton(cacheName);
|
||||
}
|
||||
|
||||
public void setCacheNames(String[] cacheNames) {
|
||||
Assert.notEmpty(cacheNames);
|
||||
public void setCacheNames(String... cacheNames) {
|
||||
this.cacheNames = new LinkedHashSet<String>(cacheNames.length);
|
||||
for (String string : cacheNames) {
|
||||
this.cacheNames.add(string);
|
||||
for (String cacheName : cacheNames) {
|
||||
Assert.hasText(cacheName, "Cache name must be non-null if specified");
|
||||
this.cacheNames.add(cacheName);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
Assert.notNull(condition);
|
||||
this.condition = condition;
|
||||
public Set<String> getCacheNames() {
|
||||
return this.cacheNames;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
@@ -74,11 +70,20 @@ public abstract class CacheOperation {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
Assert.hasText(name);
|
||||
this.name = name;
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
Assert.notNull(condition);
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return this.condition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This implementation compares the {@code toString()} results.
|
||||
* @see #toString()
|
||||
@@ -113,17 +118,12 @@ public abstract class CacheOperation {
|
||||
* <p>Available to subclasses, for inclusion in their {@code toString()} result.
|
||||
*/
|
||||
protected StringBuilder getOperationDescription() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(getClass().getSimpleName());
|
||||
result.append("[");
|
||||
result.append(this.name);
|
||||
result.append("] caches=");
|
||||
result.append(this.cacheNames);
|
||||
result.append(" | key='");
|
||||
result.append(this.key);
|
||||
result.append("' | condition='");
|
||||
result.append(this.condition);
|
||||
result.append("'");
|
||||
StringBuilder result = new StringBuilder(getClass().getSimpleName());
|
||||
result.append("[").append(this.name);
|
||||
result.append("] caches=").append(this.cacheNames);
|
||||
result.append(" | key='").append(this.key);
|
||||
result.append("' | condition='").append(this.condition).append("'");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -167,7 +167,7 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
|
||||
* Set the name-matching patterns for determining autowire candidates.
|
||||
* @param autowireCandidatePatterns the patterns to match against
|
||||
*/
|
||||
public void setAutowireCandidatePatterns(String[] autowireCandidatePatterns) {
|
||||
public void setAutowireCandidatePatterns(String... autowireCandidatePatterns) {
|
||||
this.autowireCandidatePatterns = autowireCandidatePatterns;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry);
|
||||
}
|
||||
|
||||
return this.registry.getBeanDefinitionCount() - beanCountAtScanStart;
|
||||
return (this.registry.getBeanDefinitionCount() - beanCountAtScanStart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,7 @@ public class MethodExclusionMBeanInfoAssembler extends AbstractConfigurableMBean
|
||||
* that bean is found in the {@code ignoredMethodsMappings} property.
|
||||
* @see #setIgnoredMethodMappings(java.util.Properties)
|
||||
*/
|
||||
public void setIgnoredMethods(String[] ignoredMethodNames) {
|
||||
public void setIgnoredMethods(String... ignoredMethodNames) {
|
||||
this.ignoredMethods = new HashSet<String>(Arrays.asList(ignoredMethodNames));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class MethodExclusionMBeanInfoAssembler extends AbstractConfigurableMBean
|
||||
*/
|
||||
public void setIgnoredMethodMappings(Properties mappings) {
|
||||
this.ignoredMethodMappings = new HashMap<String, Set<String>>();
|
||||
for (Enumeration en = mappings.keys(); en.hasMoreElements();) {
|
||||
for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) {
|
||||
String beanKey = (String) en.nextElement();
|
||||
String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
|
||||
this.ignoredMethodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames)));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class ManagedNotification {
|
||||
/**
|
||||
* Set a list of notification types.
|
||||
*/
|
||||
public void setNotificationTypes(String[] notificationTypes) {
|
||||
public void setNotificationTypes(String... notificationTypes) {
|
||||
this.notificationTypes = notificationTypes;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
@@ -66,7 +65,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
private final Map<String, Object> singletonObjects = new HashMap<String, Object>();
|
||||
|
||||
/** Cache of the types of nonshareable resources: bean name --> bean type */
|
||||
private final Map<String, Class> resourceTypes = new HashMap<String, Class>();
|
||||
private final Map<String, Class<?>> resourceTypes = new HashMap<String, Class<?>>();
|
||||
|
||||
|
||||
public SimpleJndiBeanFactory() {
|
||||
@@ -74,16 +73,6 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a list of names of shareable JNDI resources,
|
||||
* which this factory is allowed to cache once obtained.
|
||||
* @param shareableResources the JNDI names
|
||||
* (typically within the "java:comp/env/" namespace)
|
||||
*/
|
||||
public void setShareableResources(String[] shareableResources) {
|
||||
this.shareableResources.addAll(Arrays.asList(shareableResources));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the name of a shareable JNDI resource,
|
||||
* which this factory is allowed to cache once obtained.
|
||||
@@ -94,6 +83,16 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
this.shareableResources.add(shareableResource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a list of names of shareable JNDI resources,
|
||||
* which this factory is allowed to cache once obtained.
|
||||
* @param shareableResources the JNDI names
|
||||
* (typically within the "java:comp/env/" namespace)
|
||||
*/
|
||||
public void setShareableResources(String... shareableResources) {
|
||||
this.shareableResources.addAll(Arrays.asList(shareableResources));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Implementation of BeanFactory interface
|
||||
@@ -157,8 +156,8 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
return !this.shareableResources.contains(name);
|
||||
}
|
||||
|
||||
public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
|
||||
Class type = getType(name);
|
||||
public boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException {
|
||||
Class<?> type = getType(name);
|
||||
return (targetType == null || (type != null && targetType.isAssignableFrom(type)));
|
||||
}
|
||||
|
||||
@@ -196,7 +195,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
}
|
||||
}
|
||||
|
||||
private Class doGetType(String name) throws NamingException {
|
||||
private Class<?> doGetType(String name) throws NamingException {
|
||||
if (isSingleton(name)) {
|
||||
Object jndiObject = doGetSingleton(name, null);
|
||||
return (jndiObject != null ? jndiObject.getClass() : null);
|
||||
@@ -208,7 +207,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
}
|
||||
else {
|
||||
Object jndiObject = lookup(name, null);
|
||||
Class type = (jndiObject != null ? jndiObject.getClass() : null);
|
||||
Class<?> type = (jndiObject != null ? jndiObject.getClass() : null);
|
||||
this.resourceTypes.put(name, type);
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,7 @@ public class PreparedStatementCreatorFactory {
|
||||
/** The SQL, which won't change when the parameters change */
|
||||
private final String sql;
|
||||
|
||||
/** List of SqlParameter objects. May not be {@code null}. */
|
||||
/** List of SqlParameter objects (may not be {@code null}) */
|
||||
private final List<SqlParameter> declaredParameters;
|
||||
|
||||
private int resultSetType = ResultSet.TYPE_FORWARD_ONLY;
|
||||
@@ -76,7 +76,7 @@ public class PreparedStatementCreatorFactory {
|
||||
* @param sql SQL to execute
|
||||
* @param types int array of JDBC types
|
||||
*/
|
||||
public PreparedStatementCreatorFactory(String sql, int[] types) {
|
||||
public PreparedStatementCreatorFactory(String sql, int... types) {
|
||||
this.sql = sql;
|
||||
this.declaredParameters = SqlParameter.sqlTypesToAnonymousParameterList(types);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class PreparedStatementCreatorFactory {
|
||||
/**
|
||||
* Set the column names of the auto-generated keys.
|
||||
*/
|
||||
public void setGeneratedKeysColumnNames(String[] names) {
|
||||
public void setGeneratedKeysColumnNames(String... names) {
|
||||
this.generatedKeysColumnNames = names;
|
||||
}
|
||||
|
||||
@@ -194,13 +194,13 @@ public class PreparedStatementCreatorFactory {
|
||||
|
||||
private final String actualSql;
|
||||
|
||||
private final List parameters;
|
||||
private final List<?> parameters;
|
||||
|
||||
public PreparedStatementCreatorImpl(List<?> parameters) {
|
||||
this(sql, parameters);
|
||||
}
|
||||
|
||||
public PreparedStatementCreatorImpl(String actualSql, List parameters) {
|
||||
public PreparedStatementCreatorImpl(String actualSql, List<?> parameters) {
|
||||
this.actualSql = actualSql;
|
||||
Assert.notNull(parameters, "Parameters List must not be null");
|
||||
this.parameters = parameters;
|
||||
@@ -281,7 +281,7 @@ public class PreparedStatementCreatorFactory {
|
||||
declaredParameter = declaredParameters.get(i);
|
||||
}
|
||||
if (in instanceof Collection && declaredParameter.getSqlType() != Types.ARRAY) {
|
||||
Collection entries = (Collection) in;
|
||||
Collection<?> entries = (Collection<?>) in;
|
||||
for (Object entry : entries) {
|
||||
if (entry instanceof Object[]) {
|
||||
Object[] valueArray = ((Object[])entry);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -177,7 +177,7 @@ public class SqlParameter {
|
||||
* Convert a list of JDBC types, as defined in {@code java.sql.Types},
|
||||
* to a List of SqlParameter objects as used in this package.
|
||||
*/
|
||||
public static List<SqlParameter> sqlTypesToAnonymousParameterList(int[] types) {
|
||||
public static List<SqlParameter> sqlTypesToAnonymousParameterList(int... types) {
|
||||
List<SqlParameter> result = new LinkedList<SqlParameter>();
|
||||
if (types != null) {
|
||||
for (int type : types) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -239,7 +238,7 @@ public class TableMetaDataContext {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
// for parameter source lookups we need to provide caseinsensitive lookup support since the
|
||||
// database metadata is not necessarily providing case sensitive column names
|
||||
Map caseInsensitiveParameterNames =
|
||||
Map<String, String> caseInsensitiveParameterNames =
|
||||
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
|
||||
for (String column : this.tableColumns) {
|
||||
if (parameterSource.hasValue(column)) {
|
||||
@@ -259,7 +258,7 @@ public class TableMetaDataContext {
|
||||
if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
|
||||
values.add(
|
||||
SqlParameterSourceUtils.getTypedValue(parameterSource,
|
||||
(String) caseInsensitiveParameterNames.get(lowerCaseName)));
|
||||
caseInsensitiveParameterNames.get(lowerCaseName)));
|
||||
}
|
||||
else {
|
||||
values.add(null);
|
||||
@@ -292,7 +291,7 @@ public class TableMetaDataContext {
|
||||
* Build the insert string based on configuration and metadata information
|
||||
* @return the insert string to be used
|
||||
*/
|
||||
public String createInsertString(String[] generatedKeyNames) {
|
||||
public String createInsertString(String... generatedKeyNames) {
|
||||
HashSet<String> keys = new HashSet<String>(generatedKeyNames.length);
|
||||
for (String key : generatedKeyNames) {
|
||||
keys.add(key.toUpperCase());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -179,21 +179,6 @@ public abstract class AbstractJdbcInsert {
|
||||
return Collections.unmodifiableList(this.declaredColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of any generated keys
|
||||
*/
|
||||
public String[] getGeneratedKeyNames() {
|
||||
return this.generatedKeyNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the names of any generated keys
|
||||
*/
|
||||
public void setGeneratedKeyNames(String[] generatedKeyNames) {
|
||||
checkIfConfigurationModificationIsAllowed();
|
||||
this.generatedKeyNames = generatedKeyNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the name of a single generated key column
|
||||
*/
|
||||
@@ -203,14 +188,31 @@ public abstract class AbstractJdbcInsert {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether the parameter metadata for the call should be used. The default is true.
|
||||
* Set the names of any generated keys
|
||||
*/
|
||||
public void setGeneratedKeyNames(String... generatedKeyNames) {
|
||||
checkIfConfigurationModificationIsAllowed();
|
||||
this.generatedKeyNames = generatedKeyNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of any generated keys
|
||||
*/
|
||||
public String[] getGeneratedKeyNames() {
|
||||
return this.generatedKeyNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether the parameter metadata for the call should be used.
|
||||
* The default is {@code true}.
|
||||
*/
|
||||
public void setAccessTableColumnMetaData(boolean accessTableColumnMetaData) {
|
||||
this.tableMetaDataContext.setAccessTableColumnMetaData(accessTableColumnMetaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether the default for including synonyms should be changed. The default is false.
|
||||
* Specify whether the default for including synonyms should be changed.
|
||||
* The default is {@code false}.
|
||||
*/
|
||||
public void setOverrideIncludeSynonymsDefault(boolean override) {
|
||||
this.tableMetaDataContext.setOverrideIncludeSynonymsDefault(override);
|
||||
@@ -311,7 +313,7 @@ public abstract class AbstractJdbcInsert {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check whether we are allowd to make any configuration changes at this time.
|
||||
* Method to check whether we are allowed to make any configuration changes at this time.
|
||||
* If the class has been compiled, then no further changes to the configuration are allowed.
|
||||
*/
|
||||
protected void checkIfConfigurationModificationIsAllowed() {
|
||||
@@ -449,12 +451,12 @@ public abstract class AbstractJdbcInsert {
|
||||
"The getGeneratedKeys feature is not supported by this database");
|
||||
}
|
||||
if (getGeneratedKeyNames().length < 1) {
|
||||
throw new InvalidDataAccessApiUsageException("Generated Key Name(s) not specificed. " +
|
||||
throw new InvalidDataAccessApiUsageException("Generated Key Name(s) not specified. " +
|
||||
"Using the generated keys features requires specifying the name(s) of the generated column(s)");
|
||||
}
|
||||
if (getGeneratedKeyNames().length > 1) {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"Current database only supports retreiving the key for a single column. There are " +
|
||||
"Current database only supports retrieving the key for a single column. There are " +
|
||||
getGeneratedKeyNames().length + " columns specified: " + Arrays.asList(getGeneratedKeyNames()));
|
||||
}
|
||||
// This is a hack to be able to get the generated key from a database that doesn't support
|
||||
@@ -542,10 +544,10 @@ public abstract class AbstractJdbcInsert {
|
||||
* @param batch array of Maps with parameter names and values to be used in batch insert
|
||||
* @return array of number of rows affected
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected int[] doExecuteBatch(Map<String, Object>[] batch) {
|
||||
checkCompiled();
|
||||
List<Object>[] batchValues = new ArrayList[batch.length];
|
||||
List[] batchValues = new ArrayList[batch.length];
|
||||
int i = 0;
|
||||
for (Map<String, Object> args : batch) {
|
||||
List<Object> values = matchInParameterValuesWithInsertColumns(args);
|
||||
@@ -559,10 +561,10 @@ public abstract class AbstractJdbcInsert {
|
||||
* @param batch array of SqlParameterSource with parameter names and values to be used in insert
|
||||
* @return array of number of rows affected
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected int[] doExecuteBatch(SqlParameterSource[] batch) {
|
||||
checkCompiled();
|
||||
List<Object>[] batchValues = new ArrayList[batch.length];
|
||||
List[] batchValues = new ArrayList[batch.length];
|
||||
int i = 0;
|
||||
for (SqlParameterSource parameterSource : batch) {
|
||||
List<Object> values = matchInParameterValuesWithInsertColumns(parameterSource);
|
||||
@@ -611,9 +613,9 @@ public abstract class AbstractJdbcInsert {
|
||||
}
|
||||
|
||||
/**
|
||||
* Match the provided in parameter values with regitered parameters and parameters defined
|
||||
* Match the provided in parameter values with registered parameters and parameters defined
|
||||
* via metadata processing.
|
||||
* @param parameterSource the parameter vakues provided as a {@link SqlParameterSource}
|
||||
* @param parameterSource the parameter values provided as a {@link SqlParameterSource}
|
||||
* @return Map with parameter names and values
|
||||
*/
|
||||
protected List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -210,7 +210,7 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||
* Set the column names of the auto-generated keys.
|
||||
* @see java.sql.Connection#prepareStatement(String, String[])
|
||||
*/
|
||||
public void setGeneratedKeysColumnNames(String[] names) {
|
||||
public void setGeneratedKeysColumnNames(String... names) {
|
||||
if (isCompiled()) {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"The column names for the generated keys must be set before the operation is compiled");
|
||||
@@ -400,7 +400,7 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||
*/
|
||||
protected void validateNamedParameters(Map<String, ?> parameters) throws InvalidDataAccessApiUsageException {
|
||||
checkCompiled();
|
||||
Map paramsToUse = (parameters != null ? parameters : Collections.emptyMap());
|
||||
Map<String, ?> paramsToUse = (parameters != null ? parameters : Collections.<String, Object> emptyMap());
|
||||
int declaredInParameters = 0;
|
||||
for (SqlParameter param : this.declaredParameters) {
|
||||
if (param.isInputValueProvided()) {
|
||||
|
||||
@@ -91,6 +91,9 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
* support nested transactions! Hence, do not expect Hibernate access code to
|
||||
* semantically participate in a nested transaction.</i>
|
||||
*
|
||||
* <p><b>NOTE: Hibernate 4.2+ is strongly recommended for efficient transaction
|
||||
* management with Spring, in particular for transactional Spring JDBC access.</b>
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
* @see #setSessionFactory
|
||||
@@ -434,7 +437,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
|
||||
throw new InvalidIsolationLevelException(
|
||||
"HibernateTransactionManager is not allowed to support custom isolation levels: " +
|
||||
"make sure that its 'prepareConnection' flag is on (the default) and that the " +
|
||||
"Hibernate connection release mode is set to 'on_close' (SpringTransactionFactory's default).");
|
||||
"Hibernate connection release mode is set to 'on_close' (the default for JDBC).");
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Not preparing JDBC Connection of Hibernate Session [" + session + "]");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,8 +70,8 @@ public class SpringSessionContext implements CurrentSessionContext {
|
||||
else if (value instanceof SessionHolder) {
|
||||
SessionHolder sessionHolder = (SessionHolder) value;
|
||||
Session session = sessionHolder.getSession();
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive() &&
|
||||
!sessionHolder.isSynchronizedWithTransaction()) {
|
||||
if (!sessionHolder.isSynchronizedWithTransaction() &&
|
||||
TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.registerSynchronization(
|
||||
new SpringSessionSynchronization(sessionHolder, this.sessionFactory));
|
||||
sessionHolder.setSynchronizedWithTransaction(true);
|
||||
|
||||
@@ -217,7 +217,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
|
||||
* The DataSource should match the one used by the JPA EntityManagerFactory:
|
||||
* for example, you could specify the same JNDI DataSource for both.
|
||||
* <p>If the EntityManagerFactory uses a known DataSource as connection factory,
|
||||
* the DataSource will be autodetected: You can still explictly specify the
|
||||
* the DataSource will be autodetected: You can still explicitly specify the
|
||||
* DataSource, but you don't need to in this case.
|
||||
* <p>A transactional JDBC Connection for this DataSource will be provided to
|
||||
* application code accessing this DataSource directly via DataSourceUtils
|
||||
@@ -259,7 +259,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
|
||||
* Set the JPA dialect to use for this transaction manager.
|
||||
* Used for vendor-specific transaction management and JDBC connection exposure.
|
||||
* <p>If the EntityManagerFactory uses a known JpaDialect, it will be autodetected:
|
||||
* You can still explictly specify the DataSource, but you don't need to in this case.
|
||||
* You can still explicitly specify the DataSource, but you don't need to in this case.
|
||||
* <p>The dialect object can be used to retrieve the underlying JDBC connection
|
||||
* and thus allows for exposing JPA transactions as JDBC transactions.
|
||||
* @see EntityManagerFactoryInfo#getJpaDialect()
|
||||
|
||||
@@ -229,7 +229,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
||||
* <p>Setting either this property, {@link #setContextPath "contextPath"}
|
||||
* or {@link #setClassesToBeBound "classesToBeBound"} is required.
|
||||
*/
|
||||
public void setPackagesToScan(String[] packagesToScan) {
|
||||
public void setPackagesToScan(String... packagesToScan) {
|
||||
this.packagesToScan = packagesToScan;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,15 +23,15 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@code ContextConfigurationAttributes} encapsulates the context
|
||||
* configuration attributes declared on a test class via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
* {@code ContextConfigurationAttributes} encapsulates the context configuration
|
||||
* attributes declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
@@ -45,13 +45,11 @@ public class ContextConfigurationAttributes {
|
||||
|
||||
private final Class<?> declaringClass;
|
||||
|
||||
private String[] locations;
|
||||
|
||||
private Class<?>[] classes;
|
||||
|
||||
private final boolean inheritLocations;
|
||||
private String[] locations;
|
||||
|
||||
private final Class<? extends ContextLoader> contextLoaderClass;
|
||||
private final boolean inheritLocations;
|
||||
|
||||
private final Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers;
|
||||
|
||||
@@ -59,34 +57,8 @@ public class ContextConfigurationAttributes {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Class<? extends ContextLoader> contextLoaderClass;
|
||||
|
||||
/**
|
||||
* Resolve resource locations from the {@link ContextConfiguration#locations() locations}
|
||||
* and {@link ContextConfiguration#value() value} attributes of the supplied
|
||||
* {@link ContextConfiguration} annotation.
|
||||
*
|
||||
* @throws IllegalStateException if both the locations and value attributes have been declared
|
||||
*/
|
||||
private static String[] resolveLocations(Class<?> declaringClass, ContextConfiguration contextConfiguration) {
|
||||
Assert.notNull(declaringClass, "declaringClass must not be null");
|
||||
|
||||
String[] locations = contextConfiguration.locations();
|
||||
String[] valueLocations = contextConfiguration.value();
|
||||
|
||||
if (!ObjectUtils.isEmpty(valueLocations) && !ObjectUtils.isEmpty(locations)) {
|
||||
String msg = String.format("Test class [%s] has been configured with @ContextConfiguration's 'value' %s "
|
||||
+ "and 'locations' %s attributes. Only one declaration of resource "
|
||||
+ "locations is permitted per @ContextConfiguration annotation.", declaringClass.getName(),
|
||||
ObjectUtils.nullSafeToString(valueLocations), ObjectUtils.nullSafeToString(locations));
|
||||
logger.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
else if (!ObjectUtils.isEmpty(valueLocations)) {
|
||||
locations = valueLocations;
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new {@link ContextConfigurationAttributes} instance for the
|
||||
@@ -97,8 +69,26 @@ public class ContextConfigurationAttributes {
|
||||
*/
|
||||
public ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration) {
|
||||
this(declaringClass, resolveLocations(declaringClass, contextConfiguration), contextConfiguration.classes(),
|
||||
contextConfiguration.inheritLocations(), contextConfiguration.initializers(),
|
||||
contextConfiguration.inheritInitializers(), contextConfiguration.name(), contextConfiguration.loader());
|
||||
contextConfiguration.inheritLocations(), contextConfiguration.initializers(),
|
||||
contextConfiguration.inheritInitializers(), contextConfiguration.name(), contextConfiguration.loader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new {@link ContextConfigurationAttributes} instance for the
|
||||
* supplied {@link AnnotationAttributes} (parsed from a
|
||||
* {@link ContextConfiguration @ContextConfiguration} annotation) and
|
||||
* the {@linkplain Class test class} that declared them.
|
||||
* @param declaringClass the test class that declared {@code @ContextConfiguration}
|
||||
* @param annAttrs the annotation attributes from which to retrieve the attributes
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ContextConfigurationAttributes(Class<?> declaringClass, AnnotationAttributes annAttrs) {
|
||||
this(declaringClass,
|
||||
resolveLocations(declaringClass, annAttrs.getStringArray("locations"), annAttrs.getStringArray("value")),
|
||||
annAttrs.getClassArray("classes"), annAttrs.getBoolean("inheritLocations"),
|
||||
(Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[]) annAttrs.getClassArray("initializers"),
|
||||
annAttrs.getBoolean("inheritInitializers"), annAttrs.getString("name"),
|
||||
(Class<? extends ContextLoader>) annAttrs.getClass("loader"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,14 +96,13 @@ public class ContextConfigurationAttributes {
|
||||
* {@linkplain Class test class} that declared the
|
||||
* {@link ContextConfiguration @ContextConfiguration} annotation and its
|
||||
* corresponding attributes.
|
||||
*
|
||||
* @param declaringClass the test class that declared {@code @ContextConfiguration}
|
||||
* @param locations the resource locations declared via {@code @ContextConfiguration}
|
||||
* @param classes the annotated classes declared via {@code @ContextConfiguration}
|
||||
* @param inheritLocations the {@code inheritLocations} flag declared via {@code @ContextConfiguration}
|
||||
* @param contextLoaderClass the {@code ContextLoader} class declared via {@code @ContextConfiguration}
|
||||
* @throws IllegalArgumentException if the {@code declaringClass} or {@code contextLoaderClass} is
|
||||
* {@code null}, or if the {@code locations} and {@code classes} are both non-empty
|
||||
* {@code null}
|
||||
* @deprecated as of Spring 3.2, use
|
||||
* {@link #ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, String, Class)}
|
||||
* instead
|
||||
@@ -121,6 +110,7 @@ public class ContextConfigurationAttributes {
|
||||
@Deprecated
|
||||
public ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes,
|
||||
boolean inheritLocations, Class<? extends ContextLoader> contextLoaderClass) {
|
||||
|
||||
this(declaringClass, locations, classes, inheritLocations, null, true, null, contextLoaderClass);
|
||||
}
|
||||
|
||||
@@ -129,7 +119,6 @@ public class ContextConfigurationAttributes {
|
||||
* {@linkplain Class test class} that declared the
|
||||
* {@link ContextConfiguration @ContextConfiguration} annotation and its
|
||||
* corresponding attributes.
|
||||
*
|
||||
* @param declaringClass the test class that declared {@code @ContextConfiguration}
|
||||
* @param locations the resource locations declared via {@code @ContextConfiguration}
|
||||
* @param classes the annotated classes declared via {@code @ContextConfiguration}
|
||||
@@ -138,14 +127,15 @@ public class ContextConfigurationAttributes {
|
||||
* @param inheritInitializers the {@code inheritInitializers} flag declared via {@code @ContextConfiguration}
|
||||
* @param contextLoaderClass the {@code ContextLoader} class declared via {@code @ContextConfiguration}
|
||||
* @throws IllegalArgumentException if the {@code declaringClass} or {@code contextLoaderClass} is
|
||||
* {@code null}, or if the {@code locations} and {@code classes} are both non-empty
|
||||
* {@code null}
|
||||
*/
|
||||
public ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes,
|
||||
boolean inheritLocations,
|
||||
public ContextConfigurationAttributes(
|
||||
Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations,
|
||||
Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers,
|
||||
boolean inheritInitializers, Class<? extends ContextLoader> contextLoaderClass) {
|
||||
|
||||
this(declaringClass, locations, classes, inheritLocations, initializers, inheritInitializers, null,
|
||||
contextLoaderClass);
|
||||
contextLoaderClass);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +143,6 @@ public class ContextConfigurationAttributes {
|
||||
* {@linkplain Class test class} that declared the
|
||||
* {@link ContextConfiguration @ContextConfiguration} annotation and its
|
||||
* corresponding attributes.
|
||||
*
|
||||
* @param declaringClass the test class that declared {@code @ContextConfiguration}
|
||||
* @param locations the resource locations declared via {@code @ContextConfiguration}
|
||||
* @param classes the annotated classes declared via {@code @ContextConfiguration}
|
||||
@@ -163,24 +152,23 @@ public class ContextConfigurationAttributes {
|
||||
* @param name the name of level in the context hierarchy, or {@code null} if not applicable
|
||||
* @param contextLoaderClass the {@code ContextLoader} class declared via {@code @ContextConfiguration}
|
||||
* @throws IllegalArgumentException if the {@code declaringClass} or {@code contextLoaderClass} is
|
||||
* {@code null}, or if the {@code locations} and {@code classes} are both non-empty
|
||||
* {@code null}
|
||||
*/
|
||||
public ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes,
|
||||
boolean inheritLocations,
|
||||
public ContextConfigurationAttributes(
|
||||
Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations,
|
||||
Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers,
|
||||
boolean inheritInitializers, String name, Class<? extends ContextLoader> contextLoaderClass) {
|
||||
|
||||
Assert.notNull(declaringClass, "declaringClass must not be null");
|
||||
Assert.notNull(contextLoaderClass, "contextLoaderClass must not be null");
|
||||
|
||||
if (!ObjectUtils.isEmpty(locations) && !ObjectUtils.isEmpty(classes)) {
|
||||
String msg = String.format(
|
||||
"Test class [%s] has been configured with @ContextConfiguration's 'locations' (or 'value') %s "
|
||||
+ "and 'classes' %s attributes. Only one declaration of resources "
|
||||
+ "is permitted per @ContextConfiguration annotation.", declaringClass.getName(),
|
||||
ObjectUtils.nullSafeToString(locations), ObjectUtils.nullSafeToString(classes));
|
||||
logger.error(msg);
|
||||
throw new IllegalArgumentException(msg);
|
||||
if (!ObjectUtils.isEmpty(locations) && !ObjectUtils.isEmpty(classes) && logger.isDebugEnabled()) {
|
||||
logger.debug(String.format(
|
||||
"Test class [%s] has been configured with @ContextConfiguration's 'locations' (or 'value') %s " +
|
||||
"and 'classes' %s attributes. Most SmartContextLoader implementations support " +
|
||||
"only one declaration of resources per @ContextConfiguration annotation.",
|
||||
declaringClass.getName(), ObjectUtils.nullSafeToString(locations),
|
||||
ObjectUtils.nullSafeToString(classes)));
|
||||
}
|
||||
|
||||
this.declaringClass = declaringClass;
|
||||
@@ -189,77 +177,112 @@ public class ContextConfigurationAttributes {
|
||||
this.inheritLocations = inheritLocations;
|
||||
this.initializers = initializers;
|
||||
this.inheritInitializers = inheritInitializers;
|
||||
this.name = StringUtils.hasText(name) ? name : null;
|
||||
this.name = (StringUtils.hasText(name) ? name : null);
|
||||
this.contextLoaderClass = contextLoaderClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve resource locations from the {@link ContextConfiguration#locations() locations}
|
||||
* and {@link ContextConfiguration#value() value} attributes of the supplied
|
||||
* {@link ContextConfiguration} annotation.
|
||||
* @throws IllegalStateException if both the locations and value attributes have been declared
|
||||
*/
|
||||
private static String[] resolveLocations(Class<?> declaringClass, ContextConfiguration contextConfiguration) {
|
||||
return resolveLocations(declaringClass, contextConfiguration.locations(), contextConfiguration.value());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve resource locations from the supplied {@code locations} and
|
||||
* {@code value} arrays, which correspond to attributes of the same names in
|
||||
* the {@link ContextConfiguration} annotation.
|
||||
* @throws IllegalStateException if both the locations and value attributes have been declared
|
||||
*/
|
||||
private static String[] resolveLocations(Class<?> declaringClass, String[] locations, String[] value) {
|
||||
Assert.notNull(declaringClass, "declaringClass must not be null");
|
||||
if (!ObjectUtils.isEmpty(value) && !ObjectUtils.isEmpty(locations)) {
|
||||
throw new IllegalStateException(String.format("Test class [%s] has been configured with " +
|
||||
"@ContextConfiguration's 'value' %s and 'locations' %s attributes. Only one declaration " +
|
||||
"of resource locations is permitted per @ContextConfiguration annotation.",
|
||||
declaringClass.getName(), ObjectUtils.nullSafeToString(value), ObjectUtils.nullSafeToString(locations)));
|
||||
}
|
||||
else if (!ObjectUtils.isEmpty(value)) {
|
||||
locations = value;
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the {@linkplain Class class} that declared the
|
||||
* {@link ContextConfiguration @ContextConfiguration} annotation.
|
||||
*
|
||||
* @return the declaring class; never {@code null}
|
||||
* @return the declaring class (never {@code null})
|
||||
*/
|
||||
public Class<?> getDeclaringClass() {
|
||||
return declaringClass;
|
||||
return this.declaringClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the <em>processed</em> annotated classes, effectively overriding the
|
||||
* original value declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
* @see #getClasses()
|
||||
*/
|
||||
public void setClasses(Class<?>... classes) {
|
||||
this.classes = classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the annotated classes that were declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
* <p>Note: this is a mutable property. The returned value may therefore
|
||||
* represent a <em>processed</em> value that does not match the original value
|
||||
* declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
* @return the annotated classes; potentially {@code null} or <em>empty</em>
|
||||
* @see ContextConfiguration#classes
|
||||
* @see #setClasses(Class[])
|
||||
*/
|
||||
public Class<?>[] getClasses() {
|
||||
return this.classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this {@code ContextConfigurationAttributes} instance has
|
||||
* class-based resources.
|
||||
* @return {@code true} if the {@link #getClasses() classes} array is not empty
|
||||
* @see #hasResources()
|
||||
* @see #hasLocations()
|
||||
*/
|
||||
public boolean hasClasses() {
|
||||
return !ObjectUtils.isEmpty(getClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the <em>processed</em> resource locations, effectively overriding the
|
||||
* original value declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
* @see #getLocations()
|
||||
*/
|
||||
public void setLocations(String... locations) {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resource locations that were declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* <p>Note: this is a mutable property. The returned value may therefore
|
||||
* represent a <em>processed</em> value that does not match the original value
|
||||
* declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the resource locations; potentially {@code null} or <em>empty</em>
|
||||
* @see ContextConfiguration#value
|
||||
* @see ContextConfiguration#locations
|
||||
* @see #setLocations(String[])
|
||||
*/
|
||||
public String[] getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the <em>processed</em> resource locations, effectively overriding the
|
||||
* original value declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @see #getLocations()
|
||||
*/
|
||||
public void setLocations(String[] locations) {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the annotated classes that were declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* <p>Note: this is a mutable property. The returned value may therefore
|
||||
* represent a <em>processed</em> value that does not match the original value
|
||||
* declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the annotated classes; potentially {@code null} or <em>empty</em>
|
||||
* @see ContextConfiguration#classes
|
||||
* @see #setClasses(Class[])
|
||||
*/
|
||||
public Class<?>[] getClasses() {
|
||||
return classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the <em>processed</em> annotated classes, effectively overriding the
|
||||
* original value declared via {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @see #getClasses()
|
||||
*/
|
||||
public void setClasses(Class<?>[] classes) {
|
||||
this.classes = classes;
|
||||
return this.locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this {@code ContextConfigurationAttributes} instance has
|
||||
* path-based resource locations.
|
||||
*
|
||||
* @return {@code true} if the {@link #getLocations() locations} array is not empty
|
||||
* @see #hasResources()
|
||||
* @see #hasClasses()
|
||||
@@ -268,79 +291,51 @@ public class ContextConfigurationAttributes {
|
||||
return !ObjectUtils.isEmpty(getLocations());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this {@code ContextConfigurationAttributes} instance has
|
||||
* class-based resources.
|
||||
*
|
||||
* @return {@code true} if the {@link #getClasses() classes} array is not empty
|
||||
* @see #hasResources()
|
||||
* @see #hasLocations()
|
||||
*/
|
||||
public boolean hasClasses() {
|
||||
return !ObjectUtils.isEmpty(getClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this {@code ContextConfigurationAttributes} instance has
|
||||
* either path-based resource locations or class-based resources.
|
||||
*
|
||||
* @return {@code true} if either the {@link #getLocations() locations}
|
||||
* or the {@link #getClasses() classes} array is not empty
|
||||
* @see #hasLocations()
|
||||
* @see #hasClasses()
|
||||
*/
|
||||
public boolean hasResources() {
|
||||
return hasLocations() || hasClasses();
|
||||
return (hasLocations() || hasClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code inheritLocations} flag that was declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the {@code inheritLocations} flag
|
||||
* @see ContextConfiguration#inheritLocations
|
||||
*/
|
||||
public boolean isInheritLocations() {
|
||||
return inheritLocations;
|
||||
return this.inheritLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code ApplicationContextInitializer} classes that were declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the {@code ApplicationContextInitializer} classes
|
||||
* @since 3.2
|
||||
*/
|
||||
public Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] getInitializers() {
|
||||
return initializers;
|
||||
return this.initializers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code inheritInitializers} flag that was declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the {@code inheritInitializers} flag
|
||||
* @since 3.2
|
||||
*/
|
||||
public boolean isInheritInitializers() {
|
||||
return inheritInitializers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code ContextLoader} class that was declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the {@code ContextLoader} class
|
||||
* @see ContextConfiguration#loader
|
||||
*/
|
||||
public Class<? extends ContextLoader> getContextLoaderClass() {
|
||||
return contextLoaderClass;
|
||||
return this.inheritInitializers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the context hierarchy level that was declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
* @return the name of the context hierarchy level or {@code null} if not applicable
|
||||
* @see ContextConfiguration#name()
|
||||
* @since 3.2.2
|
||||
@@ -350,24 +345,16 @@ public class ContextConfigurationAttributes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique hash code for all properties of this
|
||||
* {@code ContextConfigurationAttributes} instance excluding the
|
||||
* {@linkplain #getName() name}.
|
||||
* Get the {@code ContextLoader} class that was declared via
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
* @return the {@code ContextLoader} class
|
||||
* @see ContextConfiguration#loader
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + declaringClass.hashCode();
|
||||
result = prime * result + Arrays.hashCode(locations);
|
||||
result = prime * result + Arrays.hashCode(classes);
|
||||
result = prime * result + (inheritLocations ? 1231 : 1237);
|
||||
result = prime * result + Arrays.hashCode(initializers);
|
||||
result = prime * result + (inheritInitializers ? 1231 : 1237);
|
||||
result = prime * result + contextLoaderClass.hashCode();
|
||||
return result;
|
||||
public Class<? extends ContextLoader> getContextLoaderClass() {
|
||||
return this.contextLoaderClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the supplied object is equal to this
|
||||
* {@code ContextConfigurationAttributes} instance by comparing both object's
|
||||
@@ -380,56 +367,36 @@ public class ContextConfigurationAttributes {
|
||||
* {@link #getContextLoaderClass() ContextLoader class}.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ContextConfigurationAttributes)) {
|
||||
if (!(other instanceof ContextConfigurationAttributes)) {
|
||||
return false;
|
||||
}
|
||||
ContextConfigurationAttributes otherAttr = (ContextConfigurationAttributes) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.declaringClass, otherAttr.declaringClass) &&
|
||||
Arrays.equals(this.classes, otherAttr.classes)) &&
|
||||
Arrays.equals(this.locations, otherAttr.locations) &&
|
||||
this.inheritLocations == otherAttr.inheritLocations &&
|
||||
Arrays.equals(this.initializers, otherAttr.initializers) &&
|
||||
this.inheritInitializers == otherAttr.inheritInitializers &&
|
||||
ObjectUtils.nullSafeEquals(this.name, otherAttr.name) &&
|
||||
ObjectUtils.nullSafeEquals(this.contextLoaderClass, otherAttr.contextLoaderClass);
|
||||
}
|
||||
|
||||
final ContextConfigurationAttributes that = (ContextConfigurationAttributes) obj;
|
||||
|
||||
if (this.declaringClass == null) {
|
||||
if (that.declaringClass != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.declaringClass.equals(that.declaringClass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arrays.equals(this.locations, that.locations)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arrays.equals(this.classes, that.classes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.inheritLocations != that.inheritLocations) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arrays.equals(this.initializers, that.initializers)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.inheritInitializers != that.inheritInitializers) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.contextLoaderClass == null) {
|
||||
if (that.contextLoaderClass != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.contextLoaderClass.equals(that.contextLoaderClass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
/**
|
||||
* Generate a unique hash code for all properties of this
|
||||
* {@code ContextConfigurationAttributes} instance excluding the
|
||||
* {@linkplain #getName() name}.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.declaringClass.hashCode();
|
||||
result = 31 * result + Arrays.hashCode(this.classes);
|
||||
result = 31 * result + Arrays.hashCode(this.locations);
|
||||
result = 31 * result + Arrays.hashCode(this.initializers);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,16 +405,16 @@ public class ContextConfigurationAttributes {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)//
|
||||
.append("declaringClass", declaringClass.getName())//
|
||||
.append("locations", ObjectUtils.nullSafeToString(locations))//
|
||||
.append("classes", ObjectUtils.nullSafeToString(classes))//
|
||||
.append("inheritLocations", inheritLocations)//
|
||||
.append("initializers", ObjectUtils.nullSafeToString(initializers))//
|
||||
.append("inheritInitializers", inheritInitializers)//
|
||||
.append("name", name)//
|
||||
.append("contextLoaderClass", contextLoaderClass.getName())//
|
||||
.toString();
|
||||
return new ToStringCreator(this)
|
||||
.append("declaringClass", this.declaringClass.getName())
|
||||
.append("classes", ObjectUtils.nullSafeToString(this.classes))
|
||||
.append("locations", ObjectUtils.nullSafeToString(this.locations))
|
||||
.append("inheritLocations", this.inheritLocations)
|
||||
.append("initializers", ObjectUtils.nullSafeToString(this.initializers))
|
||||
.append("inheritInitializers", this.inheritInitializers)
|
||||
.append("name", this.name)
|
||||
.append("contextLoaderClass", this.contextLoaderClass.getName())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -1269,6 +1269,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
this.logger = LogFactory.getLog(getClass());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Holder for suspended resources.
|
||||
* Used internally by {@code suspend} and {@code resume}.
|
||||
@@ -1276,10 +1277,15 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
protected static class SuspendedResourcesHolder {
|
||||
|
||||
private final Object suspendedResources;
|
||||
|
||||
private List<TransactionSynchronization> suspendedSynchronizations;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
private Integer isolationLevel;
|
||||
|
||||
private boolean wasActive;
|
||||
|
||||
private SuspendedResourcesHolder(Object suspendedResources) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.portlet.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletResponse;
|
||||
@@ -41,7 +40,7 @@ public class UserRoleAuthorizationInterceptor extends HandlerInterceptorAdapter
|
||||
* Set the roles that this interceptor should treat as authorized.
|
||||
* @param authorizedRoles array of role names
|
||||
*/
|
||||
public final void setAuthorizedRoles(String[] authorizedRoles) {
|
||||
public final void setAuthorizedRoles(String... authorizedRoles) {
|
||||
this.authorizedRoles = authorizedRoles;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ public class UserRoleAuthorizationInterceptor extends HandlerInterceptorAdapter
|
||||
* Set the roles that this interceptor should treat as authorized.
|
||||
* @param authorizedRoles array of role names
|
||||
*/
|
||||
public final void setAuthorizedRoles(String[] authorizedRoles) {
|
||||
public final void setAuthorizedRoles(String... authorizedRoles) {
|
||||
this.authorizedRoles = authorizedRoles;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -124,7 +124,7 @@ public class ParameterMethodNameResolver implements MethodNameResolver {
|
||||
* can be considered a logical name only.
|
||||
* @see #setParamName
|
||||
*/
|
||||
public void setMethodParamNames(String[] methodParamNames) {
|
||||
public void setMethodParamNames(String... methodParamNames) {
|
||||
this.methodParamNames = methodParamNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
|
||||
private Set<String> excludedPackages = Collections.singleton("org.springframework.web.servlet.mvc");
|
||||
|
||||
private Set<Class> excludedClasses = Collections.emptySet();
|
||||
private Set<Class<?>> excludedClasses = Collections.emptySet();
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
* e.g. a {@link org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping},
|
||||
* alongside this ControllerClassNameHandlerMapping for application controllers.
|
||||
*/
|
||||
public void setExcludedPackages(String[] excludedPackages) {
|
||||
public void setExcludedPackages(String... excludedPackages) {
|
||||
this.excludedPackages = (excludedPackages != null) ?
|
||||
new HashSet<String>(Arrays.asList(excludedPackages)) : new HashSet<String>();
|
||||
}
|
||||
@@ -69,9 +69,9 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
* Specify controller classes that should be excluded from this mapping.
|
||||
* Any such classes will simply be ignored by this HandlerMapping.
|
||||
*/
|
||||
public void setExcludedClasses(Class[] excludedClasses) {
|
||||
public void setExcludedClasses(Class<?>... excludedClasses) {
|
||||
this.excludedClasses = (excludedClasses != null) ?
|
||||
new HashSet<Class>(Arrays.asList(excludedClasses)) : new HashSet<Class>();
|
||||
new HashSet<Class<?>>(Arrays.asList(excludedClasses)) : new HashSet<Class<?>>();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
*/
|
||||
@Override
|
||||
protected String[] determineUrlsForHandler(String beanName) {
|
||||
Class beanClass = getApplicationContext().getType(beanName);
|
||||
Class<?> beanClass = getApplicationContext().getType(beanName);
|
||||
if (isEligibleForMapping(beanName, beanClass)) {
|
||||
return buildUrlsForHandler(beanName, beanClass);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
* @see #setExcludedPackages
|
||||
* @see #setExcludedClasses
|
||||
*/
|
||||
protected boolean isEligibleForMapping(String beanName, Class beanClass) {
|
||||
protected boolean isEligibleForMapping(String beanName, Class<?> beanClass) {
|
||||
if (beanClass == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Excluding controller bean '" + beanName + "' from class name mapping " +
|
||||
@@ -131,7 +131,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
* that is supported by this mapping strategy.
|
||||
* @param beanClass the class to introspect
|
||||
*/
|
||||
protected boolean isControllerType(Class beanClass) {
|
||||
protected boolean isControllerType(Class<?> beanClass) {
|
||||
return this.predicate.isControllerType(beanClass);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
* that dispatches to multiple action methods.
|
||||
* @param beanClass the class to introspect
|
||||
*/
|
||||
protected boolean isMultiActionControllerType(Class beanClass) {
|
||||
protected boolean isMultiActionControllerType(Class<?> beanClass) {
|
||||
return this.predicate.isMultiActionControllerType(beanClass);
|
||||
}
|
||||
|
||||
@@ -151,6 +151,6 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
|
||||
* @param beanClass the type of the bean
|
||||
* @return the URLs determined for the bean
|
||||
*/
|
||||
protected abstract String[] buildUrlsForHandler(String beanName, Class beanClass);
|
||||
protected abstract String[] buildUrlsForHandler(String beanName, Class<?> beanClass);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -120,7 +120,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
|
||||
* <p>Default is GET, HEAD and POST for simple form controller types;
|
||||
* unrestricted for general controllers and interceptors.
|
||||
*/
|
||||
public final void setSupportedMethods(String[] methods) {
|
||||
public final void setSupportedMethods(String... methods) {
|
||||
if (methods != null) {
|
||||
this.supportedMethods = new HashSet<String>(Arrays.asList(methods));
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether 'must-revaliate' is added to every Cache-Control header.
|
||||
* Return whether 'must-revalidate' is added to every Cache-Control header.
|
||||
*/
|
||||
public boolean isAlwaysMustRevalidate() {
|
||||
return alwaysMustRevalidate;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AbstractTemplateViewResolver extends UrlBasedViewResolver {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return AbstractTemplateView.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to add path variables in the model or not.
|
||||
* Specify whether to add path variables to the model or not.
|
||||
* <p>Path variables are commonly bound to URI template variables through the {@code @PathVariable}
|
||||
* annotation. They're are effectively URI template variables with type conversion applied to
|
||||
* them to derive typed Object values. Such values are frequently needed in views for
|
||||
@@ -233,14 +233,14 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||
* <p>Path variables added to the model override static attributes (see {@link #setAttributes(Properties)})
|
||||
* but not attributes already present in the model.
|
||||
* <p>By default this flag is set to {@code true}. Concrete view types can override this.
|
||||
* @param exposePathVariables {@code true} to expose path variables, and {@code false} otherwise.
|
||||
* @param exposePathVariables {@code true} to expose path variables, and {@code false} otherwise
|
||||
*/
|
||||
public void setExposePathVariables(boolean exposePathVariables) {
|
||||
this.exposePathVariables = exposePathVariables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the flag indicating whether path variables should be added to the model or not.
|
||||
* Return whether to add path variables to the model or not.
|
||||
*/
|
||||
public boolean isExposePathVariables() {
|
||||
return this.exposePathVariables;
|
||||
@@ -273,12 +273,13 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> pathVars = (this.exposePathVariables ?
|
||||
(Map<String, Object>) request.getAttribute(View.PATH_VARIABLES) : null);
|
||||
(Map<String, Object>) request.getAttribute(View.PATH_VARIABLES) : null);
|
||||
|
||||
// Consolidate static and dynamic model attributes.
|
||||
int size = this.staticAttributes.size();
|
||||
size += (model != null) ? model.size() : 0;
|
||||
size += (pathVars != null) ? pathVars.size() : 0;
|
||||
size += (model != null ? model.size() : 0);
|
||||
size += (pathVars != null ? pathVars.size() : 0);
|
||||
|
||||
Map<String, Object> mergedModel = new LinkedHashMap<String, Object>(size);
|
||||
mergedModel.putAll(this.staticAttributes);
|
||||
if (pathVars != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -156,7 +156,7 @@ public class InternalResourceView extends AbstractUrlBasedView {
|
||||
* the {@link #setExposeContextBeansAsAttributes "exposeContextBeansAsAttributes"}
|
||||
* flag on but do not list specific bean names for this property.
|
||||
*/
|
||||
public void setExposedContextBeanNames(String[] exposedContextBeanNames) {
|
||||
public void setExposedContextBeanNames(String... exposedContextBeanNames) {
|
||||
this.exposedContextBeanNames = new HashSet<String>(Arrays.asList(exposedContextBeanNames));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,22 +63,22 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
|
||||
* is present.
|
||||
*/
|
||||
public InternalResourceViewResolver() {
|
||||
Class viewClass = requiredViewClass();
|
||||
Class<?> viewClass = requiredViewClass();
|
||||
if (viewClass.equals(InternalResourceView.class) && jstlPresent) {
|
||||
viewClass = JstlView.class;
|
||||
}
|
||||
setViewClass(viewClass);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This resolver requires {@link InternalResourceView}.
|
||||
*/
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return InternalResourceView.class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify whether to always include the view rather than forward to it.
|
||||
* <p>Default is "false". Switch this flag on to enforce the use of a
|
||||
@@ -86,7 +86,7 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
|
||||
* @see InternalResourceView#setAlwaysInclude
|
||||
*/
|
||||
public void setAlwaysInclude(boolean alwaysInclude) {
|
||||
this.alwaysInclude = Boolean.valueOf(alwaysInclude);
|
||||
this.alwaysInclude = alwaysInclude;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,7 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
|
||||
* attributes.
|
||||
* @see InternalResourceView#setExposedContextBeanNames
|
||||
*/
|
||||
public void setExposedContextBeanNames(String[] exposedContextBeanNames) {
|
||||
public void setExposedContextBeanNames(String... exposedContextBeanNames) {
|
||||
this.exposedContextBeanNames = exposedContextBeanNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -129,7 +129,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
|
||||
* @see #setBasename
|
||||
* @see java.util.ResourceBundle#getBundle(String)
|
||||
*/
|
||||
public void setBasenames(String[] basenames) {
|
||||
public void setBasenames(String... basenames) {
|
||||
this.basenames = basenames;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -100,14 +100,12 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
public static final String FORWARD_URL_PREFIX = "forward:";
|
||||
|
||||
|
||||
private Class viewClass;
|
||||
private Class<?> viewClass;
|
||||
|
||||
private String prefix = "";
|
||||
|
||||
private String suffix = "";
|
||||
|
||||
private String[] viewNames = null;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private boolean redirectContextRelative = true;
|
||||
@@ -116,20 +114,23 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
|
||||
private String requestContextAttribute;
|
||||
|
||||
private int order = Integer.MAX_VALUE;
|
||||
|
||||
/** Map of static attributes, keyed by attribute name (String) */
|
||||
private final Map<String, Object> staticAttributes = new HashMap<String, Object>();
|
||||
|
||||
private Boolean exposePathVariables;
|
||||
|
||||
private String[] viewNames;
|
||||
|
||||
private int order = Integer.MAX_VALUE;
|
||||
|
||||
|
||||
/**
|
||||
* Set the view class that should be used to create views.
|
||||
* @param viewClass class that is assignable to the required view class
|
||||
* (by default, AbstractUrlBasedView)
|
||||
* @see AbstractUrlBasedView
|
||||
*/
|
||||
public void setViewClass(Class viewClass) {
|
||||
public void setViewClass(Class<?> viewClass) {
|
||||
if (viewClass == null || !requiredViewClass().isAssignableFrom(viewClass)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Given view class [" + (viewClass != null ? viewClass.getName() : null) +
|
||||
@@ -141,7 +142,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
/**
|
||||
* Return the view class to be used to create views.
|
||||
*/
|
||||
protected Class getViewClass() {
|
||||
protected Class<?> getViewClass() {
|
||||
return this.viewClass;
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
* This implementation returns AbstractUrlBasedView.
|
||||
* @see AbstractUrlBasedView
|
||||
*/
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return AbstractUrlBasedView.class;
|
||||
}
|
||||
|
||||
@@ -303,6 +304,29 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
return this.staticAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether views resolved by this resolver should add path variables to the model or not.
|
||||
* <p>>The default setting is to let each View decide (see {@link AbstractView#setExposePathVariables}.
|
||||
* However, you can use this property to override that.
|
||||
* @param exposePathVariables
|
||||
* <ul>
|
||||
* <li>{@code true} - all Views resolved by this resolver will expose path variables
|
||||
* <li>{@code false} - no Views resolved by this resolver will expose path variables
|
||||
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
|
||||
* <ul>
|
||||
* @see AbstractView#setExposePathVariables
|
||||
*/
|
||||
public void setExposePathVariables(Boolean exposePathVariables) {
|
||||
this.exposePathVariables = exposePathVariables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether views resolved by this resolver should add path variables to the model or not.
|
||||
*/
|
||||
protected Boolean getExposePathVariables() {
|
||||
return this.exposePathVariables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view names (or name patterns) that can be handled by this
|
||||
* {@link org.springframework.web.servlet.ViewResolver}. View names can contain
|
||||
@@ -310,7 +334,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
* view name 'myReport'.
|
||||
* @see #canHandle
|
||||
*/
|
||||
public void setViewNames(String[] viewNames) {
|
||||
public void setViewNames(String... viewNames) {
|
||||
this.viewNames = viewNames;
|
||||
}
|
||||
|
||||
@@ -338,22 +362,6 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
return this.order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether views resolved by this resolver should add path variables the model or not.
|
||||
* The default setting is to allow each View decide (see {@link AbstractView#setExposePathVariables(boolean)}.
|
||||
* However, you can use this property to override that.
|
||||
* @param exposePathVariables
|
||||
* <ul>
|
||||
* <li>{@code true} - all Views resolved by this resolver will expose path variables
|
||||
* <li>{@code false} - no Views resolved by this resolver will expose path variables
|
||||
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
|
||||
* <ul>
|
||||
* @see AbstractView#setExposePathVariables(boolean)
|
||||
*/
|
||||
public void setExposePathVariables(Boolean exposePathVariables) {
|
||||
this.exposePathVariables = exposePathVariables;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initApplicationContext() {
|
||||
super.initApplicationContext();
|
||||
@@ -362,6 +370,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This implementation returns just the view name,
|
||||
* as this ViewResolver doesn't support localized resolution.
|
||||
@@ -459,15 +468,20 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
|
||||
AbstractUrlBasedView view = (AbstractUrlBasedView) BeanUtils.instantiateClass(getViewClass());
|
||||
view.setUrl(getPrefix() + viewName + getSuffix());
|
||||
|
||||
String contentType = getContentType();
|
||||
if (contentType != null) {
|
||||
view.setContentType(contentType);
|
||||
}
|
||||
|
||||
view.setRequestContextAttribute(getRequestContextAttribute());
|
||||
view.setAttributesMap(getAttributesMap());
|
||||
if (this.exposePathVariables != null) {
|
||||
|
||||
Boolean exposePathVariables = getExposePathVariables();
|
||||
if (exposePathVariables != null) {
|
||||
view.setExposePathVariables(exposePathVariables);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FreeMarkerViewResolver extends AbstractTemplateViewResolver {
|
||||
* Requires {@link FreeMarkerView}.
|
||||
*/
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return FreeMarkerView.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -215,7 +215,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
* <p>The name specified in the list should correspond to an attribute in the
|
||||
* model Map, and to a sub-report data source parameter in your report file.
|
||||
* If you pass in {@code JRDataSource} objects as model attributes,
|
||||
* specifing this list of keys is not required.
|
||||
* specifying this list of keys is not required.
|
||||
* <p>If you specify a list of sub-report data keys, it is required to also
|
||||
* specify a {@code reportDataKey} for the main report, to avoid confusion
|
||||
* between the data source objects for the various reports involved.
|
||||
@@ -226,7 +226,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
* @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
|
||||
* @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
|
||||
*/
|
||||
public void setSubReportDataKeys(String[] subReportDataKeys) {
|
||||
public void setSubReportDataKeys(String... subReportDataKeys) {
|
||||
this.subReportDataKeys = subReportDataKeys;
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
String fieldName = fqFieldName.substring(index + 1);
|
||||
|
||||
try {
|
||||
Class cls = ClassUtils.forName(className, getApplicationContext().getClassLoader());
|
||||
Class<?> cls = ClassUtils.forName(className, getApplicationContext().getClassLoader());
|
||||
Field field = cls.getField(fieldName);
|
||||
|
||||
if (JRExporterParameter.class.isAssignableFrom(field.getType())) {
|
||||
@@ -534,7 +534,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
* {@link #renderReport} method that should be implemented by the subclass.
|
||||
* @param model the model map, as passed in for view rendering. Must contain
|
||||
* a report data value that can be converted to a {@code JRDataSource},
|
||||
* acccording to the rules of the {@link #fillReport} method.
|
||||
* according to the rules of the {@link #fillReport} method.
|
||||
*/
|
||||
@Override
|
||||
protected void renderMergedOutputModel(
|
||||
@@ -637,7 +637,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Collection values = model.values();
|
||||
Collection<?> values = model.values();
|
||||
jrDataSource = CollectionUtils.findValueOfType(values, JRDataSource.class);
|
||||
if (jrDataSource == null) {
|
||||
JRDataSourceProvider provider = CollectionUtils.findValueOfType(values, JRDataSourceProvider.class);
|
||||
@@ -705,7 +705,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
*/
|
||||
private void populateHeaders(HttpServletResponse response) {
|
||||
// Apply the headers to the response.
|
||||
for (Enumeration en = this.headers.propertyNames(); en.hasMoreElements();) {
|
||||
for (Enumeration<?> en = this.headers.propertyNames(); en.hasMoreElements();) {
|
||||
String key = (String) en.nextElement();
|
||||
response.addHeader(key, this.headers.getProperty(key));
|
||||
}
|
||||
@@ -795,8 +795,8 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
* <p>Default value types are: {@code java.util.Collection} and {@code Object} array.
|
||||
* @return the value types in prioritized order
|
||||
*/
|
||||
protected Class[] getReportDataTypes() {
|
||||
return new Class[] {Collection.class, Object[].class};
|
||||
protected Class<?>[] getReportDataTypes() {
|
||||
return new Class<?>[] {Collection.class, Object[].class};
|
||||
}
|
||||
|
||||
|
||||
@@ -813,12 +813,12 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
|
||||
|
||||
/**
|
||||
* Subclasses should implement this method to perform the actual rendering process.
|
||||
* <p>Note that the content type has not been set yet: Implementors should build
|
||||
* <p>Note that the content type has not been set yet: Implementers should build
|
||||
* a content type String and set it via {@code response.setContentType}.
|
||||
* If necessary, this can include a charset clause for a specific encoding.
|
||||
* The latter will only be necessary for textual output onto a Writer, and only
|
||||
* in case of the encoding being specified in the JasperReports exporter parameters.
|
||||
* <p><b>WARNING:</b> Implementors should not use {@code response.setCharacterEncoding}
|
||||
* <p><b>WARNING:</b> Implementers should not use {@code response.setCharacterEncoding}
|
||||
* unless they are willing to depend on Servlet API 2.4 or higher. Prefer a
|
||||
* concatenated content type String with a charset clause instead.
|
||||
* @param populatedReport the populated {@code JasperPrint} to render
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ public class JasperReportsViewResolver extends UrlBasedViewResolver {
|
||||
* Requires the view class to be a subclass of {@link AbstractJasperReportsView}.
|
||||
*/
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return AbstractJasperReportsView.class;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class JasperReportsViewResolver extends UrlBasedViewResolver {
|
||||
* Set the {@code subReportDataKeys} the view class should use.
|
||||
* @see AbstractJasperReportsView#setSubReportDataKeys
|
||||
*/
|
||||
public void setSubReportDataKeys(String[] subReportDataKeys) {
|
||||
public void setSubReportDataKeys(String... subReportDataKeys) {
|
||||
this.subReportDataKeys = subReportDataKeys;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TilesViewResolver extends UrlBasedViewResolver {
|
||||
* Requires {@link TilesView}.
|
||||
*/
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return TilesView.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class VelocityLayoutViewResolver extends VelocityViewResolver {
|
||||
* @see VelocityLayoutView
|
||||
*/
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return VelocityLayoutView.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class VelocityViewResolver extends AbstractTemplateViewResolver {
|
||||
* Requires {@link VelocityView}.
|
||||
*/
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
protected Class<?> requiredViewClass() {
|
||||
return VelocityView.class;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class VelocityViewResolver extends AbstractTemplateViewResolver {
|
||||
* to automatically load a Velocity Tools toolbox definition file and expose
|
||||
* all defined tools in the specified scopes. If no config location is
|
||||
* specified, no toolbox will be loaded and exposed.
|
||||
* <p>The specfied location string needs to refer to a ServletContext
|
||||
* <p>The specified location string needs to refer to a ServletContext
|
||||
* resource, as expected by ServletToolboxManager which is part of
|
||||
* the view package of Velocity Tools.
|
||||
* <p><b>Note:</b> Specifying a toolbox config location will lead to
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.servlet.view.xslt;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.xml.transform.ErrorListener;
|
||||
import javax.xml.transform.URIResolver;
|
||||
|
||||
@@ -49,10 +48,15 @@ public class XsltViewResolver extends UrlBasedViewResolver {
|
||||
|
||||
|
||||
public XsltViewResolver() {
|
||||
setViewClass(XsltView.class);
|
||||
setViewClass(requiredViewClass());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<?> requiredViewClass() {
|
||||
return XsltView.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the model attribute that represents the XSLT Source.
|
||||
* If not specified, the model map will be searched for a matching value type.
|
||||
@@ -117,11 +121,6 @@ public class XsltViewResolver extends UrlBasedViewResolver {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class requiredViewClass() {
|
||||
return XsltView.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
|
||||
XsltView view = (XsltView) super.buildView(viewName);
|
||||
|
||||
Reference in New Issue
Block a user