Backport selected refinements from the nullability efforts
Issue: SPR-15656
This commit is contained in:
parent
18a3322d2f
commit
9fdc4404a5
|
|
@ -1,5 +1,5 @@
|
|||
/*<
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -34,9 +34,8 @@ public interface TargetSource extends TargetClassAware {
|
|||
|
||||
/**
|
||||
* Return the type of targets returned by this {@link TargetSource}.
|
||||
* <p>Can return {@code null}, although certain usages of a
|
||||
* {@code TargetSource} might just work with a predetermined
|
||||
* target class.
|
||||
* <p>Can return {@code null}, although certain usages of a {@code TargetSource}
|
||||
* might just work with a predetermined target class.
|
||||
* @return the type of targets returned by this {@link TargetSource}
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -44,9 +43,8 @@ public interface TargetSource extends TargetClassAware {
|
|||
|
||||
/**
|
||||
* Will all calls to {@link #getTarget()} return the same object?
|
||||
* <p>In that case, there will be no need to invoke
|
||||
* {@link #releaseTarget(Object)}, and the AOP framework can cache
|
||||
* the return value of {@link #getTarget()}.
|
||||
* <p>In that case, there will be no need to invoke {@link #releaseTarget(Object)},
|
||||
* and the AOP framework can cache the return value of {@link #getTarget()}.
|
||||
* @return {@code true} if the target is immutable
|
||||
* @see #getTarget
|
||||
*/
|
||||
|
|
@ -55,14 +53,15 @@ public interface TargetSource extends TargetClassAware {
|
|||
/**
|
||||
* Return a target instance. Invoked immediately before the
|
||||
* AOP framework calls the "target" of an AOP method invocation.
|
||||
* @return the target object, which contains the joinpoint
|
||||
* @return the target object which contains the joinpoint,
|
||||
* or {@code null} if there is no actual target instance
|
||||
* @throws Exception if the target object can't be resolved
|
||||
*/
|
||||
Object getTarget() throws Exception;
|
||||
|
||||
/**
|
||||
* Release the given target object obtained from the
|
||||
* {@link #getTarget()} method.
|
||||
* {@link #getTarget()} method, if any.
|
||||
* @param target object obtained from a call to {@link #getTarget()}
|
||||
* @throws Exception if the object can't be released
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -103,8 +103,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
|||
private final AspectInstanceFactory aspectInstanceFactory;
|
||||
|
||||
/**
|
||||
* The name of the aspect (ref bean) in which this advice was defined (used
|
||||
* when determining advice precedence so that we can determine
|
||||
* The name of the aspect (ref bean) in which this advice was defined
|
||||
* (used when determining advice precedence so that we can determine
|
||||
* whether two pieces of advice come from the same aspect).
|
||||
*/
|
||||
private String aspectName;
|
||||
|
|
@ -118,13 +118,13 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
|||
* This will be non-null if the creator of this advice object knows the argument names
|
||||
* and sets them explicitly
|
||||
*/
|
||||
private String[] argumentNames = null;
|
||||
private String[] argumentNames;
|
||||
|
||||
/** Non-null if after throwing advice binds the thrown value */
|
||||
private String throwingName = null;
|
||||
private String throwingName;
|
||||
|
||||
/** Non-null if after returning advice binds the return value */
|
||||
private String returningName = null;
|
||||
private String returningName;
|
||||
|
||||
private Class<?> discoveredReturningType = Object.class;
|
||||
|
||||
|
|
@ -295,8 +295,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
|||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Returning name '" + name +
|
||||
"' is neither a valid argument name nor the fully-qualified name of a Java type on the classpath. " +
|
||||
"Root cause: " + ex);
|
||||
"' is neither a valid argument name nor the fully-qualified " +
|
||||
"name of a Java type on the classpath. Root cause: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -329,8 +329,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
|||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Throwing name '" + name +
|
||||
"' is neither a valid argument name nor the fully-qualified name of a Java type on the classpath. " +
|
||||
"Root cause: " + ex);
|
||||
"' is neither a valid argument name nor the fully-qualified " +
|
||||
"name of a Java type on the classpath. Root cause: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -113,6 +113,7 @@ import org.springframework.util.StringUtils;
|
|||
* returning {@code null} in the case that the parameter names cannot be discovered.
|
||||
*
|
||||
* @author Adrian Colyer
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
*/
|
||||
public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscoverer {
|
||||
|
|
@ -154,23 +155,17 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
|||
}
|
||||
|
||||
|
||||
/** The pointcut expression associated with the advice, as a simple String */
|
||||
private String pointcutExpression;
|
||||
|
||||
private boolean raiseExceptions;
|
||||
|
||||
/**
|
||||
* If the advice is afterReturning, and binds the return value, this is the parameter name used.
|
||||
*/
|
||||
/** If the advice is afterReturning, and binds the return value, this is the parameter name used */
|
||||
private String returningName;
|
||||
|
||||
/**
|
||||
* If the advice is afterThrowing, and binds the thrown value, this is the parameter name used.
|
||||
*/
|
||||
/** If the advice is afterThrowing, and binds the thrown value, this is the parameter name used */
|
||||
private String throwingName;
|
||||
|
||||
/**
|
||||
* The pointcut expression associated with the advice, as a simple String.
|
||||
*/
|
||||
private String pointcutExpression;
|
||||
|
||||
private Class<?>[] argumentTypes;
|
||||
|
||||
private String[] parameterNameBindings;
|
||||
|
|
@ -186,6 +181,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
|||
this.pointcutExpression = pointcutExpression;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicate whether {@link IllegalArgumentException} and {@link AmbiguousBindingException}
|
||||
* must be thrown as appropriate in the case of failing to deduce advice parameter names.
|
||||
|
|
@ -213,6 +209,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
|||
this.throwingName = throwingName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deduce the parameter names for an advice method.
|
||||
* <p>See the {@link AspectJAdviceParameterNameDiscoverer class level javadoc}
|
||||
|
|
@ -474,7 +471,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
|||
* If the token starts meets Java identifier conventions, it's in.
|
||||
*/
|
||||
private String maybeExtractVariableName(String candidateToken) {
|
||||
if (candidateToken == null || candidateToken.equals("")) {
|
||||
if (!StringUtils.hasLength(candidateToken)) {
|
||||
return null;
|
||||
}
|
||||
if (Character.isJavaIdentifierStart(candidateToken.charAt(0)) &&
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -454,10 +454,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
|||
}
|
||||
|
||||
Advisor[] advisors = buildAdvisors(beanName, specificInterceptors);
|
||||
for (Advisor advisor : advisors) {
|
||||
proxyFactory.addAdvisor(advisor);
|
||||
}
|
||||
|
||||
proxyFactory.addAdvisors(advisors);
|
||||
proxyFactory.setTargetSource(targetSource);
|
||||
customizeProxyFactory(proxyFactory);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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 org.springframework.aop.ClassFilter;
|
|||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Convenient class for building up pointcuts. All methods return
|
||||
|
|
@ -188,21 +187,14 @@ public class ComposablePointcut implements Pointcut, Serializable {
|
|||
if (!(other instanceof ComposablePointcut)) {
|
||||
return false;
|
||||
}
|
||||
ComposablePointcut that = (ComposablePointcut) other;
|
||||
return ObjectUtils.nullSafeEquals(that.classFilter, this.classFilter) &&
|
||||
ObjectUtils.nullSafeEquals(that.methodMatcher, this.methodMatcher);
|
||||
ComposablePointcut otherPointcut = (ComposablePointcut) other;
|
||||
return (this.classFilter.equals(otherPointcut.classFilter) &&
|
||||
this.methodMatcher.equals(otherPointcut.methodMatcher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 17;
|
||||
if (this.classFilter != null) {
|
||||
code = 37 * code + this.classFilter.hashCode();
|
||||
}
|
||||
if (this.methodMatcher != null) {
|
||||
code = 37 * code + this.methodMatcher.hashCode();
|
||||
}
|
||||
return code;
|
||||
return this.classFilter.hashCode() * 37 + this.methodMatcher.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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 org.springframework.aop.ClassFilter;
|
|||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Simple Pointcut that looks for a specific Java 5 annotation
|
||||
|
|
@ -46,16 +45,15 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
|||
* @param classAnnotationType the annotation type to look for at the class level
|
||||
*/
|
||||
public AnnotationMatchingPointcut(Class<? extends Annotation> classAnnotationType) {
|
||||
this.classFilter = new AnnotationClassFilter(classAnnotationType);
|
||||
this.methodMatcher = MethodMatcher.TRUE;
|
||||
this(classAnnotationType, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnnotationMatchingPointcut for the given annotation type.
|
||||
* @param classAnnotationType the annotation type to look for at the class level
|
||||
* @param checkInherited whether to explicitly check the superclasses and
|
||||
* interfaces for the annotation type as well (even if the annotation type
|
||||
* is not marked as inherited itself)
|
||||
* @param checkInherited whether to also check the superclasses and interfaces
|
||||
* as well as meta-annotations for the annotation type
|
||||
* @see AnnotationClassFilter#AnnotationClassFilter(Class, boolean)
|
||||
*/
|
||||
public AnnotationMatchingPointcut(Class<? extends Annotation> classAnnotationType, boolean checkInherited) {
|
||||
this.classFilter = new AnnotationClassFilter(classAnnotationType, checkInherited);
|
||||
|
|
@ -109,21 +107,14 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
|||
if (!(other instanceof AnnotationMatchingPointcut)) {
|
||||
return false;
|
||||
}
|
||||
AnnotationMatchingPointcut that = (AnnotationMatchingPointcut) other;
|
||||
return ObjectUtils.nullSafeEquals(that.classFilter, this.classFilter) &&
|
||||
ObjectUtils.nullSafeEquals(that.methodMatcher, this.methodMatcher);
|
||||
AnnotationMatchingPointcut otherPointcut = (AnnotationMatchingPointcut) other;
|
||||
return (this.classFilter.equals(otherPointcut.classFilter) &&
|
||||
this.methodMatcher.equals(otherPointcut.methodMatcher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 17;
|
||||
if (this.classFilter != null) {
|
||||
code = 37 * code + this.classFilter.hashCode();
|
||||
}
|
||||
if (this.methodMatcher != null) {
|
||||
code = 37 * code + this.methodMatcher.hashCode();
|
||||
}
|
||||
return code;
|
||||
return this.classFilter.hashCode() * 37 + this.methodMatcher.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -81,8 +81,6 @@ public interface PropertyAccessor {
|
|||
* (may be a nested path and/or an indexed/mapped property)
|
||||
* @return the property type for the particular property,
|
||||
* or {@code null} if not determinable
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
|
|
@ -95,8 +93,8 @@ public interface PropertyAccessor {
|
|||
* (may be a nested path and/or an indexed/mapped property)
|
||||
* @return the property type for the particular property,
|
||||
* or {@code null} if not determinable
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -158,6 +158,22 @@ public interface BeanFactory {
|
|||
*/
|
||||
<T> T getBean(String name, Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
* overriding the specified default arguments (if any) in the bean definition.
|
||||
* @param name the name of the bean to retrieve
|
||||
* @param args arguments to use when creating a bean instance using explicit arguments
|
||||
* (only applied when creating a new instance as opposed to retrieving an existing one)
|
||||
* @return an instance of the bean
|
||||
* @throws NoSuchBeanDefinitionException if there is no such bean definition
|
||||
* @throws BeanDefinitionStoreException if arguments have been given but
|
||||
* the affected bean isn't a prototype
|
||||
* @throws BeansException if the bean could not be created
|
||||
* @since 2.5
|
||||
*/
|
||||
Object getBean(String name, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return the bean instance that uniquely matches the given object type, if any.
|
||||
* <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
|
||||
|
|
@ -175,22 +191,6 @@ public interface BeanFactory {
|
|||
*/
|
||||
<T> T getBean(Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
* overriding the specified default arguments (if any) in the bean definition.
|
||||
* @param name the name of the bean to retrieve
|
||||
* @param args arguments to use when creating a bean instance using explicit arguments
|
||||
* (only applied when creating a new instance as opposed to retrieving an existing one)
|
||||
* @return an instance of the bean
|
||||
* @throws NoSuchBeanDefinitionException if there is no such bean definition
|
||||
* @throws BeanDefinitionStoreException if arguments have been given but
|
||||
* the affected bean isn't a prototype
|
||||
* @throws BeansException if the bean could not be created
|
||||
* @since 2.5
|
||||
*/
|
||||
Object getBean(String name, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -281,15 +281,15 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
|||
@SuppressWarnings("unchecked")
|
||||
protected Constructor<Exception> determineServiceLocatorExceptionConstructor(Class<? extends Exception> exceptionClass) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class, Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class, Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex2) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex3) {
|
||||
throw new IllegalArgumentException(
|
||||
|
|
@ -357,7 +357,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
|||
return System.identityHashCode(proxy);
|
||||
}
|
||||
else if (ReflectionUtils.isToStringMethod(method)) {
|
||||
return "Service locator: " + serviceLocatorInterface.getName();
|
||||
return "Service locator: " + serviceLocatorInterface;
|
||||
}
|
||||
else {
|
||||
return invokeServiceLocatorMethod(method, args);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -37,6 +37,13 @@ public class ReaderContext {
|
|||
private final SourceExtractor sourceExtractor;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new {@code ReaderContext}.
|
||||
* @param resource the XML bean definition resource
|
||||
* @param problemReporter the problem reporter in use
|
||||
* @param eventListener the event listener in use
|
||||
* @param sourceExtractor the source extractor in use
|
||||
*/
|
||||
public ReaderContext(Resource resource, ProblemReporter problemReporter,
|
||||
ReaderEventListener eventListener, SourceExtractor sourceExtractor) {
|
||||
|
||||
|
|
@ -51,83 +58,150 @@ public class ReaderContext {
|
|||
}
|
||||
|
||||
|
||||
// Errors and warnings
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source) {
|
||||
fatal(message, source, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source, Throwable ex) {
|
||||
fatal(message, source, null, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source, ParseState parseState) {
|
||||
fatal(message, source, parseState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source, ParseState parseState, Throwable cause) {
|
||||
Location location = new Location(getResource(), source);
|
||||
this.problemReporter.fatal(new Problem(message, location, parseState, cause));
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source) {
|
||||
error(message, source, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source, Throwable ex) {
|
||||
error(message, source, null, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source, ParseState parseState) {
|
||||
error(message, source, parseState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source, ParseState parseState, Throwable cause) {
|
||||
Location location = new Location(getResource(), source);
|
||||
this.problemReporter.error(new Problem(message, location, parseState, cause));
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source) {
|
||||
warning(message, source, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source, Throwable ex) {
|
||||
warning(message, source, null, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source, ParseState parseState) {
|
||||
warning(message, source, parseState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source, ParseState parseState, Throwable cause) {
|
||||
Location location = new Location(getResource(), source);
|
||||
this.problemReporter.warning(new Problem(message, location, parseState, cause));
|
||||
}
|
||||
|
||||
|
||||
// Explicit parse events
|
||||
|
||||
/**
|
||||
* Fire an defaults-registered event.
|
||||
*/
|
||||
public void fireDefaultsRegistered(DefaultsDefinition defaultsDefinition) {
|
||||
this.eventListener.defaultsRegistered(defaultsDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an component-registered event.
|
||||
*/
|
||||
public void fireComponentRegistered(ComponentDefinition componentDefinition) {
|
||||
this.eventListener.componentRegistered(componentDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an alias-registered event.
|
||||
*/
|
||||
public void fireAliasRegistered(String beanName, String alias, Object source) {
|
||||
this.eventListener.aliasRegistered(new AliasDefinition(beanName, alias, source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an import-processed event.
|
||||
*/
|
||||
public void fireImportProcessed(String importedResource, Object source) {
|
||||
this.eventListener.importProcessed(new ImportDefinition(importedResource, source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an import-processed event.
|
||||
*/
|
||||
public void fireImportProcessed(String importedResource, Resource[] actualResources, Object source) {
|
||||
this.eventListener.importProcessed(new ImportDefinition(importedResource, actualResources, source));
|
||||
}
|
||||
|
||||
|
||||
// Source extraction
|
||||
|
||||
/**
|
||||
* Return the source extractor in use.
|
||||
*/
|
||||
public SourceExtractor getSourceExtractor() {
|
||||
return this.sourceExtractor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the source extractor for the given source object.
|
||||
* @param sourceCandidate the original source object
|
||||
* @return the source object to store, or {@code null} for none.
|
||||
* @see #getSourceExtractor()
|
||||
* @see SourceExtractor#extractSource
|
||||
*/
|
||||
public Object extractSource(Object sourceCandidate) {
|
||||
return this.sourceExtractor.extractSource(sourceCandidate, this.resource);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -62,7 +62,7 @@ public class BeanDefinitionDefaults {
|
|||
}
|
||||
|
||||
public void setInitMethodName(String initMethodName) {
|
||||
this.initMethodName = (StringUtils.hasText(initMethodName)) ? initMethodName : null;
|
||||
this.initMethodName = (StringUtils.hasText(initMethodName) ? initMethodName : null);
|
||||
}
|
||||
|
||||
public String getInitMethodName() {
|
||||
|
|
@ -70,7 +70,7 @@ public class BeanDefinitionDefaults {
|
|||
}
|
||||
|
||||
public void setDestroyMethodName(String destroyMethodName) {
|
||||
this.destroyMethodName = (StringUtils.hasText(destroyMethodName)) ? destroyMethodName : null;
|
||||
this.destroyMethodName = (StringUtils.hasText(destroyMethodName) ? destroyMethodName : null);
|
||||
}
|
||||
|
||||
public String getDestroyMethodName() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -96,8 +96,7 @@ public class ResourceBundleEditor extends PropertyEditorSupport {
|
|||
}
|
||||
String localeString = name.substring(separator + 1);
|
||||
Locale locale = StringUtils.parseLocaleString(localeString);
|
||||
setValue((StringUtils.hasText(localeString)) ? ResourceBundle.getBundle(baseName, locale) :
|
||||
ResourceBundle.getBundle(baseName));
|
||||
setValue(locale != null ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -110,8 +110,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T process(MutableEntry<Object, Object> entry, Object... arguments)
|
||||
throws EntryProcessorException {
|
||||
public T process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
|
||||
Callable<T> valueLoader = (Callable<T>) arguments[0];
|
||||
if (entry.exists()) {
|
||||
return (T) fromStoreValue(entry.getValue());
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
|||
protected Object execute(CacheOperationInvoker invoker, Object target, Method method, Object[] args) {
|
||||
// Check whether aspect is enabled to cope with cases where the AJ is pulled in automatically
|
||||
if (this.initialized) {
|
||||
Class<?> targetClass = getTargetClass(target);
|
||||
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
|
||||
JCacheOperation<?> operation = getCacheOperationSource().getCacheOperation(method, targetClass);
|
||||
if (operation != null) {
|
||||
CacheOperationInvocationContext<?> context =
|
||||
|
|
@ -114,14 +114,6 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
|||
(JCacheOperation<Annotation>) operation, target, args);
|
||||
}
|
||||
|
||||
private Class<?> getTargetClass(Object target) {
|
||||
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
|
||||
if (targetClass == null && target != null) {
|
||||
targetClass = target.getClass();
|
||||
}
|
||||
return targetClass;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
|
||||
CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -35,26 +35,26 @@ import java.util.Date;
|
|||
*/
|
||||
public interface MailMessage {
|
||||
|
||||
public void setFrom(String from) throws MailParseException;
|
||||
void setFrom(String from) throws MailParseException;
|
||||
|
||||
public void setReplyTo(String replyTo) throws MailParseException;
|
||||
void setReplyTo(String replyTo) throws MailParseException;
|
||||
|
||||
public void setTo(String to) throws MailParseException;
|
||||
void setTo(String to) throws MailParseException;
|
||||
|
||||
public void setTo(String[] to) throws MailParseException;
|
||||
void setTo(String[] to) throws MailParseException;
|
||||
|
||||
public void setCc(String cc) throws MailParseException;
|
||||
void setCc(String cc) throws MailParseException;
|
||||
|
||||
public void setCc(String[] cc) throws MailParseException;
|
||||
void setCc(String[] cc) throws MailParseException;
|
||||
|
||||
public void setBcc(String bcc) throws MailParseException;
|
||||
void setBcc(String bcc) throws MailParseException;
|
||||
|
||||
public void setBcc(String[] bcc) throws MailParseException;
|
||||
void setBcc(String[] bcc) throws MailParseException;
|
||||
|
||||
public void setSentDate(Date sentDate) throws MailParseException;
|
||||
void setSentDate(Date sentDate) throws MailParseException;
|
||||
|
||||
public void setSubject(String subject) throws MailParseException;
|
||||
void setSubject(String subject) throws MailParseException;
|
||||
|
||||
public void setText(String text) throws MailParseException;
|
||||
void setText(String text) throws MailParseException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -68,10 +68,9 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
|||
/**
|
||||
* Copy constructor for creating a new {@code SimpleMailMessage} from the state
|
||||
* of an existing {@code SimpleMailMessage} instance.
|
||||
* @throws IllegalArgumentException if the supplied message is {@code null}
|
||||
*/
|
||||
public SimpleMailMessage(SimpleMailMessage original) {
|
||||
Assert.notNull(original, "The 'original' message argument cannot be null");
|
||||
Assert.notNull(original, "'original' message argument must not be null");
|
||||
this.from = original.getFrom();
|
||||
this.replyTo = original.getReplyTo();
|
||||
if (original.getTo() != null) {
|
||||
|
|
@ -104,7 +103,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
|||
}
|
||||
|
||||
public String getReplyTo() {
|
||||
return replyTo;
|
||||
return this.replyTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -132,7 +131,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
|||
}
|
||||
|
||||
public String[] getCc() {
|
||||
return cc;
|
||||
return this.cc;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,7 +145,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
|||
}
|
||||
|
||||
public String[] getBcc() {
|
||||
return bcc;
|
||||
return this.bcc;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -155,7 +154,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
|||
}
|
||||
|
||||
public Date getSentDate() {
|
||||
return sentDate;
|
||||
return this.sentDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -201,16 +201,16 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
|||
|
||||
private static void registerCacheAdvisor(Element element, ParserContext parserContext) {
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME)) {
|
||||
Object eleSource = parserContext.extractSource(element);
|
||||
Object source = parserContext.extractSource(element);
|
||||
|
||||
// Create the CacheOperationSource definition.
|
||||
BeanDefinition sourceDef = createJCacheOperationSourceBeanDefinition(element, eleSource);
|
||||
BeanDefinition sourceDef = createJCacheOperationSourceBeanDefinition(element, source);
|
||||
String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);
|
||||
|
||||
// Create the CacheInterceptor definition.
|
||||
RootBeanDefinition interceptorDef =
|
||||
new RootBeanDefinition("org.springframework.cache.jcache.interceptor.JCacheInterceptor");
|
||||
interceptorDef.setSource(eleSource);
|
||||
interceptorDef.setSource(source);
|
||||
interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
interceptorDef.getPropertyValues().add("cacheOperationSource", new RuntimeBeanReference(sourceName));
|
||||
parseErrorHandler(element, interceptorDef);
|
||||
|
|
@ -219,7 +219,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
|||
// Create the CacheAdvisor definition.
|
||||
RootBeanDefinition advisorDef = new RootBeanDefinition(
|
||||
"org.springframework.cache.jcache.interceptor.BeanFactoryJCacheOperationSourceAdvisor");
|
||||
advisorDef.setSource(eleSource);
|
||||
advisorDef.setSource(source);
|
||||
advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
advisorDef.getPropertyValues().add("cacheOperationSource", new RuntimeBeanReference(sourceName));
|
||||
advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
|
||||
|
|
@ -228,7 +228,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
|||
}
|
||||
parserContext.getRegistry().registerBeanDefinition(CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME, advisorDef);
|
||||
|
||||
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
|
||||
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);
|
||||
compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
|
||||
compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
|
||||
compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -196,7 +196,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
|||
|
||||
private String method;
|
||||
|
||||
private String[] caches = null;
|
||||
private String[] caches;
|
||||
|
||||
Props(Element root) {
|
||||
String defaultCache = root.getAttribute("cache");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -164,7 +164,6 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
|||
* @see SimpleCacheResolver
|
||||
*/
|
||||
public void setCacheResolver(CacheResolver cacheResolver) {
|
||||
Assert.notNull(cacheResolver, "CacheResolver must not be null");
|
||||
this.cacheResolver = cacheResolver;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -140,9 +140,6 @@ class CacheOperationExpressionEvaluator extends CachedExpressionEvaluator {
|
|||
Method targetMethod = this.targetMethodCache.get(methodKey);
|
||||
if (targetMethod == null) {
|
||||
targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
|
||||
if (targetMethod == null) {
|
||||
targetMethod = method;
|
||||
}
|
||||
this.targetMethodCache.put(methodKey, targetMethod);
|
||||
}
|
||||
return targetMethod;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2010-2012 the original author or authors.
|
||||
* Copyright 2010-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -35,6 +35,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
|
|||
* of the Spring reference documentation for more information.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
* @see org.springframework.aop.framework.ProxyFactoryBean
|
||||
* @see CacheInterceptor
|
||||
|
|
@ -44,9 +45,16 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean {
|
|||
|
||||
private final CacheInterceptor cachingInterceptor = new CacheInterceptor();
|
||||
|
||||
private Pointcut pointcut;
|
||||
private Pointcut pointcut = Pointcut.TRUE;
|
||||
|
||||
|
||||
/**
|
||||
* Set the sources used to find cache operations.
|
||||
*/
|
||||
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) {
|
||||
this.cachingInterceptor.setCacheOperationSources(cacheOperationSources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a pointcut, i.e a bean that can cause conditional invocation
|
||||
* of the CacheInterceptor depending on method and attributes passed.
|
||||
|
|
@ -61,18 +69,7 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean {
|
|||
@Override
|
||||
protected Object createMainInterceptor() {
|
||||
this.cachingInterceptor.afterPropertiesSet();
|
||||
if (this.pointcut == null) {
|
||||
// Rely on default pointcut.
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return new DefaultPointcutAdvisor(this.pointcut, this.cachingInterceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sources used to find cache operations.
|
||||
*/
|
||||
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) {
|
||||
this.cachingInterceptor.setCacheOperationSources(cacheOperationSources);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -19,10 +19,10 @@ package org.springframework.cache.support;
|
|||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A no operation {@link Cache} implementation suitable
|
||||
* for disabling caching.
|
||||
* A no operation {@link Cache} implementation suitable for disabling caching.
|
||||
*
|
||||
* <p>Will simply accept any items into the cache not actually storing them.
|
||||
*
|
||||
|
|
@ -34,20 +34,25 @@ public class NoOpCache implements Cache {
|
|||
|
||||
private final String name;
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@link NoOpCache} instance with the specified name
|
||||
* @param name the name of the cache
|
||||
*/
|
||||
public NoOpCache(String name) {
|
||||
Assert.notNull(name, "Cache name must not be null");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
public Object getNativeCache() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -70,16 +75,6 @@ public class NoOpCache implements Cache {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNativeCache() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
}
|
||||
|
|
@ -89,4 +84,12 @@ public class NoOpCache implements Cache {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ class ComponentScanAnnotationParser {
|
|||
public ComponentScanAnnotationParser(Environment environment, ResourceLoader resourceLoader,
|
||||
BeanNameGenerator beanNameGenerator, BeanDefinitionRegistry registry) {
|
||||
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.environment = environment;
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.beanNameGenerator = beanNameGenerator;
|
||||
this.registry = registry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -121,7 +121,7 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware,
|
|||
}
|
||||
|
||||
|
||||
public static enum SpecificPlatform {
|
||||
public enum SpecificPlatform {
|
||||
|
||||
WEBLOGIC("weblogic.management.Helper") {
|
||||
@Override
|
||||
|
|
@ -146,7 +146,7 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware,
|
|||
|
||||
private final String identifyingClass;
|
||||
|
||||
private SpecificPlatform(String identifyingClass) {
|
||||
SpecificPlatform(String identifyingClass) {
|
||||
this.identifyingClass = identifyingClass;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -68,8 +68,8 @@ class EventExpressionEvaluator extends CachedExpressionEvaluator {
|
|||
public boolean condition(String conditionExpression,
|
||||
AnnotatedElementKey elementKey, EvaluationContext evalContext) {
|
||||
|
||||
return getExpression(this.conditionCache, elementKey, conditionExpression)
|
||||
.getValue(evalContext, boolean.class);
|
||||
return getExpression(this.conditionCache, elementKey, conditionExpression).getValue(
|
||||
evalContext, boolean.class);
|
||||
}
|
||||
|
||||
private Method getTargetMethod(Class<?> targetClass, Method method) {
|
||||
|
|
@ -77,9 +77,6 @@ class EventExpressionEvaluator extends CachedExpressionEvaluator {
|
|||
Method targetMethod = this.targetMethodCache.get(methodKey);
|
||||
if (targetMethod == null) {
|
||||
targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
|
||||
if (targetMethod == null) {
|
||||
targetMethod = method;
|
||||
}
|
||||
this.targetMethodCache.put(methodKey, targetMethod);
|
||||
}
|
||||
return targetMethod;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -64,15 +64,14 @@ public class EventPublicationInterceptor
|
|||
*/
|
||||
public void setApplicationEventClass(Class<?> applicationEventClass) {
|
||||
if (ApplicationEvent.class == applicationEventClass ||
|
||||
!ApplicationEvent.class.isAssignableFrom(applicationEventClass)) {
|
||||
throw new IllegalArgumentException("applicationEventClass needs to extend ApplicationEvent");
|
||||
!ApplicationEvent.class.isAssignableFrom(applicationEventClass)) {
|
||||
throw new IllegalArgumentException("'applicationEventClass' needs to extend ApplicationEvent");
|
||||
}
|
||||
try {
|
||||
this.applicationEventClassConstructor =
|
||||
applicationEventClass.getConstructor(new Class<?>[] {Object.class});
|
||||
this.applicationEventClassConstructor = applicationEventClass.getConstructor(Object.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new IllegalArgumentException("applicationEventClass [" +
|
||||
throw new IllegalArgumentException("ApplicationEvent class [" +
|
||||
applicationEventClass.getName() + "] does not have the required Object constructor: " + ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +84,7 @@ public class EventPublicationInterceptor
|
|||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (this.applicationEventClassConstructor == null) {
|
||||
throw new IllegalArgumentException("applicationEventClass is required");
|
||||
throw new IllegalArgumentException("Property 'applicationEventClass' is required");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +94,7 @@ public class EventPublicationInterceptor
|
|||
Object retVal = invocation.proceed();
|
||||
|
||||
ApplicationEvent event = (ApplicationEvent)
|
||||
this.applicationEventClassConstructor.newInstance(new Object[] {invocation.getThis()});
|
||||
this.applicationEventClassConstructor.newInstance(invocation.getThis());
|
||||
this.applicationEventPublisher.publishEvent(event);
|
||||
|
||||
return retVal;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -75,12 +75,8 @@ public class GenericApplicationListenerAdapter implements GenericApplicationList
|
|||
|
||||
@Override
|
||||
public boolean supportsSourceType(Class<?> sourceType) {
|
||||
if (this.delegate instanceof SmartApplicationListener) {
|
||||
return ((SmartApplicationListener) this.delegate).supportsSourceType(sourceType);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return !(this.delegate instanceof SmartApplicationListener) ||
|
||||
((SmartApplicationListener) this.delegate).supportsSourceType(sourceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -91,17 +87,13 @@ public class GenericApplicationListenerAdapter implements GenericApplicationList
|
|||
|
||||
static ResolvableType resolveDeclaredEventType(Class<?> listenerType) {
|
||||
ResolvableType resolvableType = ResolvableType.forClass(listenerType).as(ApplicationListener.class);
|
||||
if (resolvableType == null || !resolvableType.hasGenerics()) {
|
||||
return null;
|
||||
}
|
||||
return resolvableType.getGeneric();
|
||||
return (resolvableType.hasGenerics() ? resolvableType.getGeneric() : null);
|
||||
}
|
||||
|
||||
private static ResolvableType resolveDeclaredEventType(ApplicationListener<ApplicationEvent> listener) {
|
||||
ResolvableType declaredEventType = resolveDeclaredEventType(listener.getClass());
|
||||
if (declaredEventType == null || declaredEventType.isAssignableFrom(
|
||||
ResolvableType.forClass(ApplicationEvent.class))) {
|
||||
|
||||
Class<?> targetClass = AopUtils.getTargetClass(listener);
|
||||
if (targetClass != listener.getClass()) {
|
||||
declaredEventType = resolveDeclaredEventType(targetClass);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -75,6 +75,9 @@ public final class AnnotatedElementKey implements Comparable<AnnotatedElementKey
|
|||
public int compareTo(AnnotatedElementKey other) {
|
||||
int result = this.element.toString().compareTo(other.element.toString());
|
||||
if (result == 0 && this.targetClass != null) {
|
||||
if (other.targetClass == null) {
|
||||
return 1;
|
||||
}
|
||||
result = this.targetClass.getName().compareTo(other.targetClass.getName());
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -68,27 +68,6 @@ public class MapAccessor implements CompilablePropertyAccessor {
|
|||
map.put(name, newValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown from {@code read} in order to reset a cached
|
||||
* PropertyAccessor, allowing other accessors to have a try.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static class MapAccessException extends AccessException {
|
||||
|
||||
private final String key;
|
||||
|
||||
public MapAccessException(String key) {
|
||||
super(null);
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "Map does not contain a value for key '" + this.key + "'";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompilable() {
|
||||
return true;
|
||||
|
|
@ -112,4 +91,25 @@ public class MapAccessor implements CompilablePropertyAccessor {
|
|||
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "get","(Ljava/lang/Object;)Ljava/lang/Object;",true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown from {@code read} in order to reset a cached
|
||||
* PropertyAccessor, allowing other accessors to have a try.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static class MapAccessException extends AccessException {
|
||||
|
||||
private final String key;
|
||||
|
||||
public MapAccessException(String key) {
|
||||
super(null);
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "Map does not contain a value for key '" + this.key + "'";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -160,7 +160,7 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
|
|||
}
|
||||
return expr.getValue(sec);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new BeanExpressionException("Expression parsing failed", ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -96,11 +96,6 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getCodes() {
|
||||
return this.codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default code of this resolvable, that is,
|
||||
* the last one in the codes array.
|
||||
|
|
@ -109,6 +104,11 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
|
|||
return (this.codes != null && this.codes.length > 0 ? this.codes[this.codes.length - 1] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCodes() {
|
||||
return this.codes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return this.arguments;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -40,6 +40,7 @@ public class MessageSourceAccessor {
|
|||
|
||||
private final Locale defaultLocale;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MessageSourceAccessor, using LocaleContextHolder's locale
|
||||
* as default locale.
|
||||
|
|
@ -61,6 +62,7 @@ public class MessageSourceAccessor {
|
|||
this.defaultLocale = defaultLocale;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the default locale to use if no explicit locale has been given.
|
||||
* <p>The default implementation returns the default locale passed into the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -67,12 +67,12 @@ public class SimpleThreadScope implements Scope {
|
|||
@Override
|
||||
public Object get(String name, ObjectFactory<?> objectFactory) {
|
||||
Map<String, Object> scope = this.threadScope.get();
|
||||
Object object = scope.get(name);
|
||||
if (object == null) {
|
||||
object = objectFactory.getObject();
|
||||
scope.put(name, object);
|
||||
Object scopedObject = scope.get(name);
|
||||
if (scopedObject == null) {
|
||||
scopedObject = objectFactory.getObject();
|
||||
scope.put(name, scopedObject);
|
||||
}
|
||||
return object;
|
||||
return scopedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -72,7 +72,7 @@ public class CurrencyStyleFormatter extends AbstractNumberFormatter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the pattern to use to format number values.
|
||||
* Specify the pattern to use to format number values.
|
||||
* If not specified, the default DecimalFormat pattern is used.
|
||||
* @see java.text.DecimalFormat#applyPattern(String)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -56,7 +56,7 @@ public class NumberStyleFormatter extends AbstractNumberFormatter {
|
|||
|
||||
|
||||
/**
|
||||
* Sets the pattern to use to format number values.
|
||||
* Specify the pattern to use to format number values.
|
||||
* If not specified, the default DecimalFormat pattern is used.
|
||||
* @see java.text.DecimalFormat#applyPattern(String)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -48,10 +48,20 @@ public class GlassFishLoadTimeWeaver implements LoadTimeWeaver {
|
|||
private final Method copyMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link GlassFishLoadTimeWeaver} class using
|
||||
* the default {@link ClassLoader class loader}.
|
||||
* @see org.springframework.util.ClassUtils#getDefaultClassLoader()
|
||||
*/
|
||||
public GlassFishLoadTimeWeaver() {
|
||||
this(ClassUtils.getDefaultClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link GlassFishLoadTimeWeaver} class using
|
||||
* the supplied {@link ClassLoader}.
|
||||
* @param classLoader the {@code ClassLoader} to delegate to for weaving
|
||||
*/
|
||||
public GlassFishLoadTimeWeaver(ClassLoader classLoader) {
|
||||
Assert.notNull(classLoader, "ClassLoader must not be null");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -41,9 +41,7 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
|
|||
|
||||
|
||||
/**
|
||||
* Creates a new {@link WebLogicClassPreProcessorAdapter}.
|
||||
* @param transformer the {@link ClassFileTransformer} to be adapted
|
||||
* (must not be {@code null})
|
||||
* Construct a new {@link WebLogicClassPreProcessorAdapter}.
|
||||
*/
|
||||
public WebLogicClassPreProcessorAdapter(ClassFileTransformer transformer, ClassLoader loader) {
|
||||
this.transformer = transformer;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -25,7 +25,7 @@ import org.springframework.util.ClassUtils;
|
|||
|
||||
/**
|
||||
* {@link LoadTimeWeaver} implementation for WebSphere's instrumentable ClassLoader.
|
||||
* Compatible with WebSphere 7 as well as 8.
|
||||
* Compatible with WebSphere 7 as well as 8 and 9.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @since 3.1
|
||||
|
|
@ -48,7 +48,6 @@ public class WebSphereLoadTimeWeaver implements LoadTimeWeaver {
|
|||
* Create a new instance of the {@link WebSphereLoadTimeWeaver} class using
|
||||
* the supplied {@link ClassLoader}.
|
||||
* @param classLoader the {@code ClassLoader} to delegate to for weaving
|
||||
* (must not be {@code null})
|
||||
*/
|
||||
public WebSphereLoadTimeWeaver(ClassLoader classLoader) {
|
||||
Assert.notNull(classLoader, "ClassLoader must not be null");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -60,21 +60,14 @@ import org.springframework.util.StringUtils;
|
|||
public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanInfoAssembler
|
||||
implements BeanClassLoaderAware, InitializingBean {
|
||||
|
||||
/**
|
||||
* Stores the array of interfaces to use for creating the management interface.
|
||||
*/
|
||||
private Class<?>[] managedInterfaces;
|
||||
|
||||
/**
|
||||
* Stores the mappings of bean keys to an array of {@code Class}es.
|
||||
*/
|
||||
/** Mappings of bean keys to an array of classes */
|
||||
private Properties interfaceMappings;
|
||||
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
/**
|
||||
* Stores the mappings of bean keys to an array of {@code Class}es.
|
||||
*/
|
||||
/** Mappings of bean keys to an array of classes */
|
||||
private Map<String, Class<?>[]> resolvedInterfaceMappings;
|
||||
|
||||
|
||||
|
|
@ -86,7 +79,7 @@ public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanI
|
|||
* Each entry <strong>MUST</strong> be an interface.
|
||||
* @see #setInterfaceMappings
|
||||
*/
|
||||
public void setManagedInterfaces(Class<?>[] managedInterfaces) {
|
||||
public void setManagedInterfaces(Class<?>... managedInterfaces) {
|
||||
if (managedInterfaces != null) {
|
||||
for (Class<?> ifc : managedInterfaces) {
|
||||
if (!ifc.isInterface()) {
|
||||
|
|
@ -103,7 +96,7 @@ public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanI
|
|||
* <p>The property key should match the bean key and the property value should match
|
||||
* the list of interface names. When searching for interfaces for a bean, Spring
|
||||
* will check these mappings first.
|
||||
* @param mappings the mappins of bean keys to interface names
|
||||
* @param mappings the mappings of bean keys to interface names
|
||||
*/
|
||||
public void setInterfaceMappings(Properties mappings) {
|
||||
this.interfaceMappings = mappings;
|
||||
|
|
@ -230,13 +223,11 @@ public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanI
|
|||
}
|
||||
}
|
||||
|
||||
if (ifaces != null) {
|
||||
for (Class<?> ifc : ifaces) {
|
||||
for (Method ifcMethod : ifc.getMethods()) {
|
||||
if (ifcMethod.getName().equals(method.getName()) &&
|
||||
Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) {
|
||||
return true;
|
||||
}
|
||||
for (Class<?> ifc : ifaces) {
|
||||
for (Method ifcMethod : ifc.getMethods()) {
|
||||
if (ifcMethod.getName().equals(method.getName()) &&
|
||||
Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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,18 +34,17 @@ import org.springframework.jmx.export.metadata.ManagedNotification;
|
|||
import org.springframework.jmx.export.metadata.ManagedOperation;
|
||||
import org.springframework.jmx.export.metadata.ManagedOperationParameter;
|
||||
import org.springframework.jmx.export.metadata.ManagedResource;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link MBeanInfoAssembler}
|
||||
* interface that reads the management interface information from source level metadata.
|
||||
* Implementation of the {@link MBeanInfoAssembler} interface that reads
|
||||
* the management interface information from source level metadata.
|
||||
*
|
||||
* <p>Uses the {@link JmxAttributeSource} strategy interface, so that
|
||||
* metadata can be read using any supported implementation. Out of the box,
|
||||
* Spring provides an implementation based on JDK 1.5+ annotations,
|
||||
* Spring provides an implementation based on annotations:
|
||||
* {@code AnnotationJmxAttributeSource}.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
|
|
@ -339,9 +338,9 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
|||
}
|
||||
else {
|
||||
ManagedAttribute gma =
|
||||
(getter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(getter);
|
||||
(getter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(getter);
|
||||
ManagedAttribute sma =
|
||||
(setter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(setter);
|
||||
(setter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(setter);
|
||||
populateAttributeDescriptor(desc,gma,sma);
|
||||
}
|
||||
}
|
||||
|
|
@ -384,8 +383,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
|||
desc.setField(FIELD_METRIC_CATEGORY, metric.getCategory());
|
||||
}
|
||||
|
||||
String metricType = (metric.getMetricType() == null) ? MetricType.GAUGE.toString() : metric.getMetricType().toString();
|
||||
desc.setField(FIELD_METRIC_TYPE, metricType);
|
||||
desc.setField(FIELD_METRIC_TYPE, metric.getMetricType().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -18,6 +18,7 @@ package org.springframework.jmx.export.metadata;
|
|||
|
||||
import javax.management.modelmbean.ModelMBeanNotificationInfo;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -34,16 +35,16 @@ public abstract class JmxMetadataUtils {
|
|||
* {@link javax.management.modelmbean.ModelMBeanNotificationInfo}.
|
||||
*/
|
||||
public static ModelMBeanNotificationInfo convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) {
|
||||
String[] notifTypes = notificationInfo.getNotificationTypes();
|
||||
if (ObjectUtils.isEmpty(notifTypes)) {
|
||||
throw new IllegalArgumentException("Must specify at least one notification type");
|
||||
}
|
||||
|
||||
String name = notificationInfo.getName();
|
||||
if (!StringUtils.hasText(name)) {
|
||||
throw new IllegalArgumentException("Must specify notification name");
|
||||
}
|
||||
|
||||
String[] notifTypes = notificationInfo.getNotificationTypes();
|
||||
if (notifTypes == null || notifTypes.length == 0) {
|
||||
throw new IllegalArgumentException("Must specify at least one notification type");
|
||||
}
|
||||
|
||||
String description = notificationInfo.getDescription();
|
||||
return new ModelMBeanNotificationInfo(notifTypes, name, description);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +17,7 @@
|
|||
package org.springframework.jmx.export.metadata;
|
||||
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Metadata that indicates to expose a given bean property as a JMX attribute,
|
||||
|
|
@ -74,6 +75,7 @@ public class ManagedMetric extends AbstractJmxAttribute {
|
|||
* A description of how this metric's values change over time.
|
||||
*/
|
||||
public void setMetricType(MetricType metricType) {
|
||||
Assert.notNull(metricType, "MetricType must not be null");
|
||||
this.metricType = metricType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -105,17 +105,14 @@ public class KeyNamingStrategy implements ObjectNamingStrategy, InitializingBean
|
|||
* Merges the {@code Properties} configured in the {@code mappings} and
|
||||
* {@code mappingLocations} into the final {@code Properties} instance
|
||||
* used for {@code ObjectName} resolution.
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws IOException {
|
||||
this.mergedMappings = new Properties();
|
||||
|
||||
CollectionUtils.mergePropertiesIntoMap(this.mappings, this.mergedMappings);
|
||||
|
||||
if (this.mappingLocations != null) {
|
||||
for (int i = 0; i < this.mappingLocations.length; i++) {
|
||||
Resource location = this.mappingLocations[i];
|
||||
for (Resource location : this.mappingLocations) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Loading JMX object name mappings file from " + location);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -18,18 +18,19 @@ package org.springframework.jmx.support;
|
|||
|
||||
/**
|
||||
* Represents how the measurement values of a {@code ManagedMetric} will change over time.
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
* @since 3.0
|
||||
*/
|
||||
public enum MetricType {
|
||||
|
||||
/**
|
||||
* The measurement values may go up or down over time
|
||||
* The measurement values may go up or down over time.
|
||||
*/
|
||||
GAUGE,
|
||||
|
||||
/**
|
||||
* The measurement values will always increase
|
||||
* The measurement values will always increase.
|
||||
*/
|
||||
COUNTER
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -73,7 +73,7 @@ public class NotificationListenerHolder {
|
|||
|
||||
/**
|
||||
* Return the {@link javax.management.NotificationFilter} associated
|
||||
* with the encapsulated {@link #getNotificationFilter() NotificationFilter}.
|
||||
* with the encapsulated {@link #getNotificationListener() NotificationListener}.
|
||||
* <p>May be {@code null}.
|
||||
*/
|
||||
public NotificationFilter getNotificationFilter() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -154,7 +154,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
|
|||
* Provide an {@link ErrorHandler} strategy.
|
||||
*/
|
||||
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||
Assert.notNull(errorHandler, "'errorHandler' must not be null");
|
||||
Assert.notNull(errorHandler, "ErrorHandler must not be null");
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +166,8 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
|
|||
return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger);
|
||||
}
|
||||
else {
|
||||
ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
|
||||
ErrorHandler errorHandler =
|
||||
(this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
|
||||
return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
|
||||
}
|
||||
}
|
||||
|
|
@ -248,9 +249,9 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
|
|||
return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
|
||||
@Override
|
||||
public Date getNextRunTime(LastExecution le, Date taskScheduledTime) {
|
||||
return trigger.nextExecutionTime(le != null ?
|
||||
return (trigger.nextExecutionTime(le != null ?
|
||||
new SimpleTriggerContext(le.getScheduledStart(), le.getRunStart(), le.getRunEnd()) :
|
||||
new SimpleTriggerContext());
|
||||
new SimpleTriggerContext()));
|
||||
}
|
||||
@Override
|
||||
public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -196,29 +196,30 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac
|
|||
* Perform a shutdown on the underlying ExecutorService.
|
||||
* @see java.util.concurrent.ExecutorService#shutdown()
|
||||
* @see java.util.concurrent.ExecutorService#shutdownNow()
|
||||
* @see #awaitTerminationIfNecessary()
|
||||
*/
|
||||
public void shutdown() {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Shutting down ExecutorService" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
|
||||
}
|
||||
if (this.waitForTasksToCompleteOnShutdown) {
|
||||
this.executor.shutdown();
|
||||
if (this.executor != null) {
|
||||
if (this.waitForTasksToCompleteOnShutdown) {
|
||||
this.executor.shutdown();
|
||||
}
|
||||
else {
|
||||
this.executor.shutdownNow();
|
||||
}
|
||||
awaitTerminationIfNecessary(this.executor);
|
||||
}
|
||||
else {
|
||||
this.executor.shutdownNow();
|
||||
}
|
||||
awaitTerminationIfNecessary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the executor to terminate, according to the value of the
|
||||
* {@link #setAwaitTerminationSeconds "awaitTerminationSeconds"} property.
|
||||
*/
|
||||
private void awaitTerminationIfNecessary() {
|
||||
private void awaitTerminationIfNecessary(ExecutorService executor) {
|
||||
if (this.awaitTerminationSeconds > 0) {
|
||||
try {
|
||||
if (!this.executor.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS)) {
|
||||
if (!executor.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS)) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Timed out while waiting for executor" +
|
||||
(this.beanName != null ? " '" + this.beanName + "'" : "") + " to terminate");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -67,10 +67,10 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
|||
|
||||
private volatile boolean removeOnCancelPolicy = false;
|
||||
|
||||
private volatile ScheduledExecutorService scheduledExecutor;
|
||||
|
||||
private volatile ErrorHandler errorHandler;
|
||||
|
||||
private volatile ScheduledExecutorService scheduledExecutor;
|
||||
|
||||
|
||||
/**
|
||||
* Set the ScheduledExecutorService's pool size.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -116,7 +116,8 @@ public class PeriodicTrigger implements Trigger {
|
|||
return false;
|
||||
}
|
||||
PeriodicTrigger other = (PeriodicTrigger) obj;
|
||||
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay && this.period == other.period);
|
||||
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay &&
|
||||
this.period == other.period);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -271,8 +271,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
|
|||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ex instanceof BeanCreationException
|
||||
&& ((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
|
||||
if (ex instanceof BeanCreationException &&
|
||||
((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Could not determine scripted object type for bean '" + beanName + "': "
|
||||
+ ex.getMessage());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -112,6 +112,14 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
|||
this.prefix = (prefix != null ? prefix : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the prefix to be applied to any code built by this resolver.
|
||||
* <p>Returns an empty String in case of no prefix.
|
||||
*/
|
||||
protected String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the format for message codes built by this resolver.
|
||||
* <p>The default is {@link Format#PREFIX_ERROR_CODE}.
|
||||
|
|
@ -119,15 +127,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
|||
* @see Format
|
||||
*/
|
||||
public void setMessageCodeFormatter(MessageCodeFormatter formatter) {
|
||||
this.formatter = (formatter == null ? DEFAULT_FORMATTER : formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the prefix to be applied to any code built by this resolver.
|
||||
* <p>Returns an empty String in case of no prefix.
|
||||
*/
|
||||
protected String getPrefix() {
|
||||
return this.prefix;
|
||||
this.formatter = (formatter != null ? formatter : DEFAULT_FORMATTER);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
|||
* object/field-specific code, a field-specific code, a plain error code.
|
||||
* <p>Arrays, Lists and Maps are resolved both for specific elements and
|
||||
* the whole collection.
|
||||
* <p>See the {@link DefaultMessageCodesResolver class level Javadoc} for
|
||||
* <p>See the {@link DefaultMessageCodesResolver class level javadoc} for
|
||||
* details on the generated codes.
|
||||
* @return the list of codes
|
||||
*/
|
||||
|
|
@ -208,14 +208,10 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
|||
|
||||
/**
|
||||
* Common message code formats.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Chris Beams
|
||||
* @since 3.2
|
||||
* @see MessageCodeFormatter
|
||||
* @see DefaultMessageCodesResolver#setMessageCodeFormatter(MessageCodeFormatter)
|
||||
*/
|
||||
public static enum Format implements MessageCodeFormatter {
|
||||
public enum Format implements MessageCodeFormatter {
|
||||
|
||||
/**
|
||||
* Prefix the error code at the beginning of the generated message code. e.g.:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -62,8 +62,7 @@ public class FieldError extends ObjectError {
|
|||
* @param arguments the array of arguments to be used to resolve this message
|
||||
* @param defaultMessage the default message to be used to resolve this message
|
||||
*/
|
||||
public FieldError(
|
||||
String objectName, String field, Object rejectedValue, boolean bindingFailure,
|
||||
public FieldError(String objectName, String field, Object rejectedValue, boolean bindingFailure,
|
||||
String[] codes, Object[] arguments, String defaultMessage) {
|
||||
|
||||
super(objectName, codes, arguments, defaultMessage);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -27,9 +27,9 @@ import org.springframework.util.Assert;
|
|||
* how a message code list is built for an {@code ObjectError}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 10.03.2003
|
||||
* @see FieldError
|
||||
* @see DefaultMessageCodesResolver
|
||||
* @since 10.03.2003
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ObjectError extends DefaultMessageSourceResolvable {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -75,7 +75,7 @@ public final class MethodClassKey implements Comparable<MethodClassKey> {
|
|||
int result = this.method.getName().compareTo(other.method.getName());
|
||||
if (result == 0) {
|
||||
result = this.method.toString().compareTo(other.method.toString());
|
||||
if (result == 0 && this.targetClass != null) {
|
||||
if (result == 0 && this.targetClass != null && other.targetClass != null) {
|
||||
result = this.targetClass.getName().compareTo(other.targetClass.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -24,7 +24,7 @@ package org.springframework.core;
|
|||
*
|
||||
* <p>Users of this interface should be careful in complex hierarchy scenarios, especially
|
||||
* when the generic type signature of the class changes in sub-classes. It is always
|
||||
* possible to return {@code null} to fallback on a default behaviour.
|
||||
* possible to return {@code null} to fallback on a default behavior.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.2
|
||||
|
|
|
|||
|
|
@ -35,19 +35,19 @@ import org.springframework.util.ConcurrentReferenceHashMap;
|
|||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Internal utility class that can be used to obtain wrapped {@link Serializable} variants
|
||||
* of {@link java.lang.reflect.Type}s.
|
||||
* Internal utility class that can be used to obtain wrapped {@link Serializable}
|
||||
* variants of {@link java.lang.reflect.Type}s.
|
||||
*
|
||||
* <p>{@link #forField(Field) Fields} or {@link #forMethodParameter(MethodParameter)
|
||||
* MethodParameters} can be used as the root source for a serializable type. Alternatively
|
||||
* the {@link #forGenericSuperclass(Class) superclass},
|
||||
* MethodParameters} can be used as the root source for a serializable type.
|
||||
* Alternatively the {@link #forGenericSuperclass(Class) superclass},
|
||||
* {@link #forGenericInterfaces(Class) interfaces} or {@link #forTypeParameters(Class)
|
||||
* type parameters} or a regular {@link Class} can also be used as source.
|
||||
*
|
||||
* <p>The returned type will either be a {@link Class} or a serializable proxy of
|
||||
* {@link GenericArrayType}, {@link ParameterizedType}, {@link TypeVariable} or
|
||||
* {@link WildcardType}. With the exception of {@link Class} (which is final) calls to
|
||||
* methods that return further {@link Type}s (for example
|
||||
* {@link WildcardType}. With the exception of {@link Class} (which is final) calls
|
||||
* to methods that return further {@link Type}s (for example
|
||||
* {@link GenericArrayType#getGenericComponentType()}) will be automatically wrapped.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
|
|
|
|||
|
|
@ -1441,8 +1441,8 @@ public class AnnotatedElementUtils {
|
|||
* <p>If this method returns {@code true}, then {@link #getAggregatedResults()}
|
||||
* must return a non-null value.
|
||||
* @return {@code true} if this processor supports aggregated results
|
||||
* @see #getAggregatedResults
|
||||
* @since 4.3
|
||||
* @see #getAggregatedResults
|
||||
*/
|
||||
boolean aggregates();
|
||||
|
||||
|
|
@ -1453,10 +1453,9 @@ public class AnnotatedElementUtils {
|
|||
* responsible for asking this processor if it {@link #aggregates} results
|
||||
* and then adding the post-processed results to the list returned by this
|
||||
* method.
|
||||
* @return the list of results aggregated by this processor
|
||||
* (never {@code null} unless {@link #aggregates} returns {@code false})
|
||||
* @see #aggregates
|
||||
* @return the list of results aggregated by this processor (never {@code null})
|
||||
* @since 4.3
|
||||
* @see #aggregates
|
||||
*/
|
||||
List<T> getAggregatedResults();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -243,10 +243,9 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the value stored under the specified {@code attributeName} as a
|
||||
* boolean.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* Get the value stored under the specified {@code attributeName} as a boolean.
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
* if it is not of the expected type
|
||||
|
|
@ -256,10 +255,9 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the value stored under the specified {@code attributeName} as a
|
||||
* number.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* Get the value stored under the specified {@code attributeName} as a number.
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
* if it is not of the expected type
|
||||
|
|
@ -270,10 +268,9 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the value stored under the specified {@code attributeName} as an
|
||||
* enum.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* Get the value stored under the specified {@code attributeName} as an enum.
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
* if it is not of the expected type
|
||||
|
|
@ -284,10 +281,9 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the value stored under the specified {@code attributeName} as a
|
||||
* class.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* Get the value stored under the specified {@code attributeName} as a class.
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
* if it is not of the expected type
|
||||
|
|
@ -300,11 +296,10 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
/**
|
||||
* Get the value stored under the specified {@code attributeName} as an
|
||||
* array of classes.
|
||||
* <p>If the value stored under the specified {@code attributeName} is
|
||||
* a class, it will be wrapped in a single-element array before
|
||||
* returning it.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* <p>If the value stored under the specified {@code attributeName} is a class,
|
||||
* it will be wrapped in a single-element array before returning it.
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
* if it is not of the expected type
|
||||
|
|
@ -361,8 +356,8 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
/**
|
||||
* Get the annotation of type {@code annotationType} stored under the
|
||||
* specified {@code attributeName}.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @param annotationType the expected annotation type; never {@code null}
|
||||
* @return the annotation
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
|
|
@ -381,8 +376,8 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
* a single-element array before returning it.
|
||||
* <p>Note: if you expect an actual array of annotations, invoke
|
||||
* {@link #getAnnotationArray(String, Class)} instead.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @return the array of {@code AnnotationAttributes}
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
* if it is not of the expected type
|
||||
|
|
@ -397,8 +392,8 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
* <p>If the value stored under the specified {@code attributeName} is
|
||||
* an {@code Annotation}, it will be wrapped in a single-element array
|
||||
* before returning it.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @param annotationType the expected annotation type; never {@code null}
|
||||
* @return the annotation array
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
|
|
@ -419,8 +414,8 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
* component type of the expected array type, the single element will be
|
||||
* wrapped in a single-element array of the appropriate type before
|
||||
* returning it.
|
||||
* @param attributeName the name of the attribute to get; never
|
||||
* {@code null} or empty
|
||||
* @param attributeName the name of the attribute to get;
|
||||
* never {@code null} or empty
|
||||
* @param expectedType the expected type; never {@code null}
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the attribute does not exist or
|
||||
|
|
|
|||
|
|
@ -207,8 +207,8 @@ public final class Property {
|
|||
}
|
||||
|
||||
private void addAnnotationsToMap(
|
||||
Map<Class<? extends Annotation>, Annotation> annotationMap,
|
||||
AnnotatedElement object) {
|
||||
Map<Class<? extends Annotation>, Annotation> annotationMap, AnnotatedElement object) {
|
||||
|
||||
if (object != null) {
|
||||
for (Annotation annotation : object.getAnnotations()) {
|
||||
annotationMap.put(annotation.annotationType(), annotation);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -112,6 +112,10 @@ final class ByteBufferConverter implements ConditionalGenericConverter {
|
|||
byte[] bytes = (byte[]) (source instanceof byte[] ? source :
|
||||
this.conversionService.convert(source, sourceType, BYTE_ARRAY_TYPE));
|
||||
|
||||
if (bytes == null) {
|
||||
return ByteBuffer.wrap(new byte[0]);
|
||||
}
|
||||
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(bytes.length);
|
||||
byteBuffer.put(bytes);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -40,10 +40,12 @@ final class CollectionToArrayConverter implements ConditionalGenericConverter {
|
|||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public CollectionToArrayConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(Collection.class, Object[].class));
|
||||
|
|
@ -51,7 +53,8 @@ final class CollectionToArrayConverter implements ConditionalGenericConverter {
|
|||
|
||||
@Override
|
||||
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return ConversionUtils.canConvertElements(sourceType.getElementTypeDescriptor(), targetType.getElementTypeDescriptor(), this.conversionService);
|
||||
return ConversionUtils.canConvertElements(sourceType.getElementTypeDescriptor(),
|
||||
targetType.getElementTypeDescriptor(), this.conversionService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,7 +66,8 @@ final class CollectionToArrayConverter implements ConditionalGenericConverter {
|
|||
Object array = Array.newInstance(targetType.getElementTypeDescriptor().getType(), sourceCollection.size());
|
||||
int i = 0;
|
||||
for (Object sourceElement : sourceCollection) {
|
||||
Object targetElement = this.conversionService.convert(sourceElement, sourceType.elementTypeDescriptor(sourceElement), targetType.getElementTypeDescriptor());
|
||||
Object targetElement = this.conversionService.convert( sourceElement,
|
||||
sourceType.elementTypeDescriptor(sourceElement), targetType.getElementTypeDescriptor());
|
||||
Array.set(array, i++, targetElement);
|
||||
}
|
||||
return array;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -50,10 +50,9 @@ abstract class ReadOnlySystemAttributesMap implements Map<String, String> {
|
|||
public String get(Object key) {
|
||||
if (!(key instanceof String)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Type of key [" + (key != null ? key.getClass().getName() : "null") +
|
||||
"] must be java.lang.String.");
|
||||
"Type of key [" + key.getClass().getName() + "] must be java.lang.String");
|
||||
}
|
||||
return this.getSystemAttribute((String) key);
|
||||
return getSystemAttribute((String) key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link Resource} implementation for a given byte array.
|
||||
* <p>Creates a {@link ByteArrayInputStream} for the given byte array.
|
||||
|
|
@ -58,9 +60,7 @@ public class ByteArrayResource extends AbstractResource {
|
|||
* @param description where the byte array comes from
|
||||
*/
|
||||
public ByteArrayResource(byte[] byteArray, String description) {
|
||||
if (byteArray == null) {
|
||||
throw new IllegalArgumentException("Byte array must not be null");
|
||||
}
|
||||
Assert.notNull(byteArray, "Byte array must not be null");
|
||||
this.byteArray = byteArray;
|
||||
this.description = (description != null ? description : "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -46,10 +46,10 @@ public abstract class VfsUtils {
|
|||
private static final String VFS3_PKG = "org.jboss.vfs.";
|
||||
private static final String VFS_NAME = "VFS";
|
||||
|
||||
private static Method VFS_METHOD_GET_ROOT_URL = null;
|
||||
private static Method VFS_METHOD_GET_ROOT_URI = null;
|
||||
private static Method VFS_METHOD_GET_ROOT_URL;
|
||||
private static Method VFS_METHOD_GET_ROOT_URI;
|
||||
|
||||
private static Method VIRTUAL_FILE_METHOD_EXISTS = null;
|
||||
private static Method VIRTUAL_FILE_METHOD_EXISTS;
|
||||
private static Method VIRTUAL_FILE_METHOD_GET_INPUT_STREAM;
|
||||
private static Method VIRTUAL_FILE_METHOD_GET_SIZE;
|
||||
private static Method VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED;
|
||||
|
|
@ -62,8 +62,8 @@ public abstract class VfsUtils {
|
|||
protected static Class<?> VIRTUAL_FILE_VISITOR_INTERFACE;
|
||||
protected static Method VIRTUAL_FILE_METHOD_VISIT;
|
||||
|
||||
private static Field VISITOR_ATTRIBUTES_FIELD_RECURSE = null;
|
||||
private static Method GET_PHYSICAL_FILE = null;
|
||||
private static Field VISITOR_ATTRIBUTES_FIELD_RECURSE;
|
||||
private static Method GET_PHYSICAL_FILE;
|
||||
|
||||
static {
|
||||
ClassLoader loader = VfsUtils.class.getClassLoader();
|
||||
|
|
@ -90,7 +90,7 @@ public abstract class VfsUtils {
|
|||
Class<?> visitorAttributesClass = loader.loadClass(VFS3_PKG + "VisitorAttributes");
|
||||
VISITOR_ATTRIBUTES_FIELD_RECURSE = ReflectionUtils.findField(visitorAttributesClass, "RECURSE");
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Could not detect JBoss VFS infrastructure", ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -404,12 +404,6 @@ public class FastByteArrayOutputStream extends OutputStream {
|
|||
else if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (len < 0) {
|
||||
throw new IllegalArgumentException("len must be 0 or greater: " + len);
|
||||
}
|
||||
else if (off < 0) {
|
||||
throw new IllegalArgumentException("off must be 0 or greater: " + off);
|
||||
}
|
||||
else {
|
||||
if (this.currentBuffer == null) {
|
||||
// This stream doesn't have any data in it...
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -122,8 +122,8 @@ public class MethodInvoker {
|
|||
* Set arguments for the method invocation. If this property is not set,
|
||||
* or the Object array is of length 0, a method with no arguments is assumed.
|
||||
*/
|
||||
public void setArguments(Object[] arguments) {
|
||||
this.arguments = (arguments != null ? arguments : new Object[0]);
|
||||
public void setArguments(Object... arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,12 +156,8 @@ public class MethodInvoker {
|
|||
|
||||
Class<?> targetClass = getTargetClass();
|
||||
String targetMethod = getTargetMethod();
|
||||
if (targetClass == null) {
|
||||
throw new IllegalArgumentException("Either 'targetClass' or 'targetObject' is required");
|
||||
}
|
||||
if (targetMethod == null) {
|
||||
throw new IllegalArgumentException("Property 'targetMethod' is required");
|
||||
}
|
||||
Assert.notNull(targetClass, "Either 'targetClass' or 'targetObject' is required");
|
||||
Assert.notNull(targetMethod, "Property 'targetMethod' is required");
|
||||
|
||||
Object[] arguments = getArguments();
|
||||
Class<?>[] argTypes = new Class<?>[arguments.length];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -724,12 +724,8 @@ public abstract class ReflectionUtils {
|
|||
* work on objects with public no-arg constructors.
|
||||
*/
|
||||
public static void shallowCopyFieldState(final Object src, final Object dest) {
|
||||
if (src == null) {
|
||||
throw new IllegalArgumentException("Source for field copy cannot be null");
|
||||
}
|
||||
if (dest == null) {
|
||||
throw new IllegalArgumentException("Destination for field copy cannot be null");
|
||||
}
|
||||
Assert.notNull(src, "Source for field copy cannot be null");
|
||||
Assert.notNull(dest, "Destination for field copy cannot be null");
|
||||
if (!src.getClass().isAssignableFrom(dest.getClass())) {
|
||||
throw new IllegalArgumentException("Destination class [" + dest.getClass().getName() +
|
||||
"] must be same or subclass as source class [" + src.getClass().getName() + "]");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -215,7 +215,6 @@ public abstract class TypeUtils {
|
|||
if (rhsType == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lhsType == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -49,7 +49,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
|||
* @param adaptee the future to delegate to
|
||||
*/
|
||||
protected FutureAdapter(Future<S> adaptee) {
|
||||
Assert.notNull(adaptee, "'delegate' must not be null");
|
||||
Assert.notNull(adaptee, "Delegate must not be null");
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -25,6 +25,14 @@ package org.springframework.expression;
|
|||
@SuppressWarnings("serial")
|
||||
public class AccessException extends Exception {
|
||||
|
||||
/**
|
||||
* Create an AccessException with a specific message.
|
||||
* @param message the message
|
||||
*/
|
||||
public AccessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AccessException with a specific message and cause.
|
||||
* @param message the message
|
||||
|
|
@ -34,12 +42,4 @@ public class AccessException extends Exception {
|
|||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AccessException with a specific message.
|
||||
* @param message the message
|
||||
*/
|
||||
public AccessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,13 +36,12 @@ public interface ConstructorExecutor {
|
|||
|
||||
/**
|
||||
* Execute a constructor in the specified context using the specified arguments.
|
||||
*
|
||||
* @param context the evaluation context in which the command is being executed
|
||||
* @param arguments the arguments to the constructor call, should match (in terms of
|
||||
* number and type) whatever the command will need to run
|
||||
* @param arguments the arguments to the constructor call, should match (in terms
|
||||
* of number and type) whatever the command will need to run
|
||||
* @return the new object
|
||||
* @throws AccessException if there is a problem executing the command or the
|
||||
* CommandExecutor is no longer valid
|
||||
* CommandExecutor is no longer valid
|
||||
*/
|
||||
TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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,9 +17,9 @@
|
|||
package org.springframework.expression;
|
||||
|
||||
/**
|
||||
* By default the mathematical operators {@link Operation} support simple types like
|
||||
* numbers. By providing an implementation of OperatorOverloader, a user of the expression
|
||||
* language can support these operations on other types.
|
||||
* By default the mathematical operators {@link Operation} support simple types
|
||||
* like numbers. By providing an implementation of OperatorOverloader, a user
|
||||
* of the expression language can support these operations on other types.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @since 3.0
|
||||
|
|
@ -27,21 +27,21 @@ package org.springframework.expression;
|
|||
public interface OperatorOverloader {
|
||||
|
||||
/**
|
||||
* Return true if the operator overloader supports the specified operation between the
|
||||
* two operands and so should be invoked to handle it.
|
||||
* Return true if the operator overloader supports the specified operation
|
||||
* between the two operands and so should be invoked to handle it.
|
||||
* @param operation the operation to be performed
|
||||
* @param leftOperand the left operand
|
||||
* @param rightOperand the right operand
|
||||
* @return true if the OperatorOverloader supports the specified operation between the
|
||||
* two operands
|
||||
* @return true if the OperatorOverloader supports the specified operation
|
||||
* between the two operands
|
||||
* @throws EvaluationException if there is a problem performing the operation
|
||||
*/
|
||||
boolean overridesOperation(Operation operation, Object leftOperand, Object rightOperand)
|
||||
throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Execute the specified operation on two operands, returning a result. See
|
||||
* {@link Operation} for supported operations.
|
||||
* Execute the specified operation on two operands, returning a result.
|
||||
* See {@link Operation} for supported operations.
|
||||
* @param operation the operation to be performed
|
||||
* @param leftOperand the left operand
|
||||
* @param rightOperand the right operand
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
|
|||
String prefix = context.getExpressionPrefix();
|
||||
String suffix = context.getExpressionSuffix();
|
||||
int startIdx = 0;
|
||||
|
||||
while (startIdx < expressionString.length()) {
|
||||
int prefixIndex = expressionString.indexOf(prefix, startIdx);
|
||||
if (prefixIndex >= startIdx) {
|
||||
|
|
@ -126,22 +127,18 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
|
|||
"No ending suffix '" + suffix + "' for expression starting at character " +
|
||||
prefixIndex + ": " + expressionString.substring(prefixIndex));
|
||||
}
|
||||
|
||||
if (suffixIndex == afterPrefixIndex) {
|
||||
throw new ParseException(expressionString, prefixIndex,
|
||||
"No expression defined within delimiter '" + prefix + suffix +
|
||||
"' at character " + prefixIndex);
|
||||
}
|
||||
|
||||
String expr = expressionString.substring(prefixIndex + prefix.length(), suffixIndex);
|
||||
expr = expr.trim();
|
||||
|
||||
if (expr.isEmpty()) {
|
||||
throw new ParseException(expressionString, prefixIndex,
|
||||
"No expression defined within delimiter '" + prefix + suffix +
|
||||
"' at character " + prefixIndex);
|
||||
}
|
||||
|
||||
expressions.add(doParseExpression(expr, context));
|
||||
startIdx = suffixIndex + suffix.length();
|
||||
}
|
||||
|
|
@ -151,6 +148,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
|
|||
startIdx = expressionString.length();
|
||||
}
|
||||
}
|
||||
|
||||
return expressions.toArray(new Expression[expressions.size()]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -32,6 +32,7 @@ import org.springframework.expression.TypeComparator;
|
|||
import org.springframework.expression.TypeConverter;
|
||||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* An ExpressionState is for maintaining per-expression-evaluation state, any changes to
|
||||
|
|
@ -53,6 +54,12 @@ public class ExpressionState {
|
|||
|
||||
private final TypedValue rootObject;
|
||||
|
||||
private final SpelParserConfiguration configuration;
|
||||
|
||||
private Stack<TypedValue> contextObjects;
|
||||
|
||||
private Stack<VariableScope> variableScopes;
|
||||
|
||||
// When entering a new scope there is a new base object which should be used
|
||||
// for '#this' references (or to act as a target for unqualified references).
|
||||
// This stack captures those objects at each nested scope level.
|
||||
|
|
@ -62,12 +69,6 @@ public class ExpressionState {
|
|||
// element from list1
|
||||
private Stack<TypedValue> scopeRootObjects;
|
||||
|
||||
private final SpelParserConfiguration configuration;
|
||||
|
||||
private Stack<VariableScope> variableScopes;
|
||||
|
||||
private Stack<TypedValue> contextObjects;
|
||||
|
||||
|
||||
public ExpressionState(EvaluationContext context) {
|
||||
this(context, context.getRootObject(), new SpelParserConfiguration(false, false));
|
||||
|
|
@ -105,7 +106,7 @@ public class ExpressionState {
|
|||
* The active context object is what unqualified references to properties/etc are resolved against.
|
||||
*/
|
||||
public TypedValue getActiveContextObject() {
|
||||
if (this.contextObjects == null || this.contextObjects.isEmpty()) {
|
||||
if (CollectionUtils.isEmpty(this.contextObjects)) {
|
||||
return this.rootObject;
|
||||
}
|
||||
return this.contextObjects.peek();
|
||||
|
|
@ -130,7 +131,7 @@ public class ExpressionState {
|
|||
}
|
||||
|
||||
public TypedValue getScopeRootContextObject() {
|
||||
if (this.scopeRootObjects == null || this.scopeRootObjects.isEmpty()) {
|
||||
if (CollectionUtils.isEmpty(this.scopeRootObjects)) {
|
||||
return this.rootObject;
|
||||
}
|
||||
return this.scopeRootObjects.peek();
|
||||
|
|
@ -142,12 +143,7 @@ public class ExpressionState {
|
|||
|
||||
public TypedValue lookupVariable(String name) {
|
||||
Object value = this.relatedContext.lookupVariable(name);
|
||||
if (value == null) {
|
||||
return TypedValue.NULL;
|
||||
}
|
||||
else {
|
||||
return new TypedValue(value);
|
||||
}
|
||||
return (value != null ? new TypedValue(value) : TypedValue.NULL);
|
||||
}
|
||||
|
||||
public TypeComparator getTypeComparator() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -18,7 +18,6 @@ package org.springframework.expression.spel;
|
|||
|
||||
import org.springframework.core.SpringProperties;
|
||||
|
||||
|
||||
/**
|
||||
* Configuration object for the SpEL expression parser.
|
||||
*
|
||||
|
|
@ -106,35 +105,35 @@ public class SpelParserConfiguration {
|
|||
|
||||
|
||||
/**
|
||||
* @return the configuration mode for parsers using this configuration object
|
||||
* Return the configuration mode for parsers using this configuration object.
|
||||
*/
|
||||
public SpelCompilerMode getCompilerMode() {
|
||||
return this.compilerMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ClassLoader to use as the basis for expression compilation
|
||||
* Return the ClassLoader to use as the basis for expression compilation.
|
||||
*/
|
||||
public ClassLoader getCompilerClassLoader() {
|
||||
return this.compilerClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if {@code null} references should be automatically grown
|
||||
* Return {@code true} if {@code null} references should be automatically grown.
|
||||
*/
|
||||
public boolean isAutoGrowNullReferences() {
|
||||
return this.autoGrowNullReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if collections should be automatically grown
|
||||
* Return {@code true} if collections should be automatically grown.
|
||||
*/
|
||||
public boolean isAutoGrowCollections() {
|
||||
return this.autoGrowCollections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum size that a collection can auto grow
|
||||
* Return the maximum size that a collection can auto grow.
|
||||
*/
|
||||
public int getMaximumAutoGrowSize() {
|
||||
return this.maximumAutoGrowSize;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -37,7 +37,7 @@ public class BeanReference extends SpelNodeImpl {
|
|||
private final String beanName;
|
||||
|
||||
|
||||
public BeanReference(int pos,String beanName) {
|
||||
public BeanReference(int pos, String beanName) {
|
||||
super(pos);
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -31,7 +31,7 @@ import org.springframework.expression.spel.SpelEvaluationException;
|
|||
*/
|
||||
public class CompoundExpression extends SpelNodeImpl {
|
||||
|
||||
public CompoundExpression(int pos,SpelNodeImpl... expressionComponents) {
|
||||
public CompoundExpression(int pos, SpelNodeImpl... expressionComponents) {
|
||||
super(pos, expressionComponents);
|
||||
if (expressionComponents.length < 2) {
|
||||
throw new IllegalStateException("Do not build compound expressions with less than two entries: " +
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -59,7 +59,7 @@ public class FunctionReference extends SpelNodeImpl {
|
|||
|
||||
|
||||
public FunctionReference(String functionName, int pos, SpelNodeImpl... arguments) {
|
||||
super(pos,arguments);
|
||||
super(pos, arguments);
|
||||
this.name = functionName;
|
||||
}
|
||||
|
||||
|
|
@ -107,15 +107,15 @@ public class FunctionReference extends SpelNodeImpl {
|
|||
SpelMessage.FUNCTION_MUST_BE_STATIC, ClassUtils.getQualifiedMethodName(method), this.name);
|
||||
}
|
||||
|
||||
argumentConversionOccurred = false;
|
||||
this.argumentConversionOccurred = false;
|
||||
// Convert arguments if necessary and remap them for varargs if required
|
||||
if (functionArgs != null) {
|
||||
TypeConverter converter = state.getEvaluationContext().getTypeConverter();
|
||||
argumentConversionOccurred = ReflectionHelper.convertAllArguments(converter, functionArgs, method);
|
||||
this.argumentConversionOccurred = ReflectionHelper.convertAllArguments(converter, functionArgs, method);
|
||||
}
|
||||
if (method.isVarArgs()) {
|
||||
functionArgs =
|
||||
ReflectionHelper.setupArgumentsForVarargsInvocation(method.getParameterTypes(), functionArgs);
|
||||
functionArgs = ReflectionHelper.setupArgumentsForVarargsInvocation(
|
||||
method.getParameterTypes(), functionArgs);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -51,7 +51,7 @@ import org.springframework.expression.spel.support.ReflectivePropertyAccessor;
|
|||
// TODO support correct syntax for multidimensional [][][] and not [,,,]
|
||||
public class Indexer extends SpelNodeImpl {
|
||||
|
||||
private static enum IndexedType {ARRAY, LIST, MAP, STRING, OBJECT}
|
||||
private enum IndexedType {ARRAY, LIST, MAP, STRING, OBJECT}
|
||||
|
||||
|
||||
// These fields are used when the indexer is being used as a property read accessor.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -29,7 +29,7 @@ import org.springframework.expression.spel.CodeFlow;
|
|||
public class NullLiteral extends Literal {
|
||||
|
||||
public NullLiteral(int pos) {
|
||||
super(null,pos);
|
||||
super(null, pos);
|
||||
this.exitTypeDescriptor = "Ljava/lang/Object";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -44,7 +44,7 @@ public class OpAnd extends Operator {
|
|||
|
||||
@Override
|
||||
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
||||
if (getBooleanValue(state, getLeftOperand()) == false) {
|
||||
if (!getBooleanValue(state, getLeftOperand())) {
|
||||
// no need to evaluate right operand
|
||||
return BooleanTypedValue.FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,8 +192,8 @@ public class OpPlus extends Operator {
|
|||
private void walk(MethodVisitor mv, CodeFlow cf, SpelNodeImpl operand) {
|
||||
if (operand instanceof OpPlus) {
|
||||
OpPlus plus = (OpPlus)operand;
|
||||
walk(mv,cf,plus.getLeftOperand());
|
||||
walk(mv,cf,plus.getRightOperand());
|
||||
walk(mv, cf, plus.getLeftOperand());
|
||||
walk(mv, cf, plus.getRightOperand());
|
||||
}
|
||||
else {
|
||||
cf.enterCompilationScope();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public abstract class Operator extends SpelNodeImpl {
|
|||
|
||||
protected boolean isCompilableOperatorUsingNumerics() {
|
||||
SpelNodeImpl left = getLeftOperand();
|
||||
SpelNodeImpl right= getRightOperand();
|
||||
SpelNodeImpl right = getRightOperand();
|
||||
if (!left.isCompilable() || !right.isCompilable()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -273,11 +273,11 @@ public abstract class Operator extends SpelNodeImpl {
|
|||
boolean rightNumeric = CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean(rd);
|
||||
|
||||
// If the declared descriptors aren't providing the information, try the actual descriptors
|
||||
if (!leftNumeric && !ld.equals(leftActualDescriptor)) {
|
||||
if (!leftNumeric && !ObjectUtils.nullSafeEquals(ld, leftActualDescriptor)) {
|
||||
ld = leftActualDescriptor;
|
||||
leftNumeric = CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean(ld);
|
||||
}
|
||||
if (!rightNumeric && !rd.equals(rightActualDescriptor)) {
|
||||
if (!rightNumeric && !ObjectUtils.nullSafeEquals(rd, rightActualDescriptor)) {
|
||||
rd = rightActualDescriptor;
|
||||
rightNumeric = CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean(rd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -77,6 +77,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
|||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
protected SpelNodeImpl getPreviousChild() {
|
||||
SpelNodeImpl result = null;
|
||||
if (this.parent != null) {
|
||||
|
|
@ -214,9 +215,9 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
|||
|
||||
|
||||
/**
|
||||
* Generate code that handles building the argument values for the specified method. This method will take account
|
||||
* of whether the invoked method is a varargs method and if it is then the argument values will be appropriately
|
||||
* packaged into an array.
|
||||
* Generate code that handles building the argument values for the specified method.
|
||||
* This method will take account of whether the invoked method is a varargs method
|
||||
* and if it is then the argument values will be appropriately packaged into an array.
|
||||
* @param mv the method visitor where code should be generated
|
||||
* @param cf the current codeflow
|
||||
* @param member the method or constructor for which arguments are being setup
|
||||
|
|
@ -226,7 +227,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
|||
String[] paramDescriptors = null;
|
||||
boolean isVarargs = false;
|
||||
if (member instanceof Constructor) {
|
||||
Constructor<?> ctor = (Constructor<?>)member;
|
||||
Constructor<?> ctor = (Constructor<?>) member;
|
||||
paramDescriptors = CodeFlow.toDescriptors(ctor.getParameterTypes());
|
||||
isVarargs = ctor.isVarArgs();
|
||||
}
|
||||
|
|
@ -246,25 +247,25 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
|||
generateCodeForArgument(mv, cf, arguments[p], paramDescriptors[p]);
|
||||
}
|
||||
|
||||
SpelNodeImpl lastchild = (childCount == 0 ? null : arguments[childCount - 1]);
|
||||
String arraytype = paramDescriptors[paramDescriptors.length - 1];
|
||||
SpelNodeImpl lastChild = (childCount == 0 ? null : arguments[childCount - 1]);
|
||||
String arrayType = paramDescriptors[paramDescriptors.length - 1];
|
||||
// Determine if the final passed argument is already suitably packaged in array
|
||||
// form to be passed to the method
|
||||
if (lastchild != null && lastchild.getExitDescriptor().equals(arraytype)) {
|
||||
generateCodeForArgument(mv, cf, lastchild, paramDescriptors[p]);
|
||||
if (lastChild != null && arrayType.equals(lastChild.getExitDescriptor())) {
|
||||
generateCodeForArgument(mv, cf, lastChild, paramDescriptors[p]);
|
||||
}
|
||||
else {
|
||||
arraytype = arraytype.substring(1); // trim the leading '[', may leave other '['
|
||||
arrayType = arrayType.substring(1); // trim the leading '[', may leave other '['
|
||||
// build array big enough to hold remaining arguments
|
||||
CodeFlow.insertNewArrayCode(mv, childCount - p, arraytype);
|
||||
CodeFlow.insertNewArrayCode(mv, childCount - p, arrayType);
|
||||
// Package up the remaining arguments into the array
|
||||
int arrayindex = 0;
|
||||
while (p < childCount) {
|
||||
SpelNodeImpl child = arguments[p];
|
||||
mv.visitInsn(DUP);
|
||||
CodeFlow.insertOptimalLoad(mv, arrayindex++);
|
||||
generateCodeForArgument(mv, cf, child, arraytype);
|
||||
CodeFlow.insertArrayStore(mv, arraytype);
|
||||
generateCodeForArgument(mv, cf, child, arrayType);
|
||||
CodeFlow.insertArrayStore(mv, arrayType);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
|
@ -283,15 +284,16 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
|
|||
protected static void generateCodeForArgument(MethodVisitor mv, CodeFlow cf, SpelNodeImpl argument, String paramDesc) {
|
||||
cf.enterCompilationScope();
|
||||
argument.generateCode(mv, cf);
|
||||
boolean primitiveOnStack = CodeFlow.isPrimitive(cf.lastDescriptor());
|
||||
String lastDesc = cf.lastDescriptor();
|
||||
boolean primitiveOnStack = CodeFlow.isPrimitive(lastDesc);
|
||||
// Check if need to box it for the method reference?
|
||||
if (primitiveOnStack && paramDesc.charAt(0) == 'L') {
|
||||
CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
|
||||
CodeFlow.insertBoxIfNecessary(mv, lastDesc.charAt(0));
|
||||
}
|
||||
else if (paramDesc.length() == 1 && !primitiveOnStack) {
|
||||
CodeFlow.insertUnboxInsns(mv, paramDesc.charAt(0), cf.lastDescriptor());
|
||||
CodeFlow.insertUnboxInsns(mv, paramDesc.charAt(0), lastDesc);
|
||||
}
|
||||
else if (!cf.lastDescriptor().equals(paramDesc)) {
|
||||
else if (!paramDesc.equals(lastDesc)) {
|
||||
// This would be unnecessary in the case of subtyping (e.g. method takes Number but Integer passed in)
|
||||
CodeFlow.insertCheckCast(mv, paramDesc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -88,14 +88,13 @@ public class SpelCompiler implements Opcodes {
|
|||
|
||||
|
||||
/**
|
||||
* Attempt compilation of the supplied expression. A check is
|
||||
* made to see if it is compilable before compilation proceeds. The
|
||||
* check involves visiting all the nodes in the expression Ast and
|
||||
* ensuring enough state is known about them that bytecode can
|
||||
* be generated for them.
|
||||
* Attempt compilation of the supplied expression. A check is made to see
|
||||
* if it is compilable before compilation proceeds. The check involves
|
||||
* visiting all the nodes in the expression Ast and ensuring enough state
|
||||
* is known about them that bytecode can be generated for them.
|
||||
* @param expression the expression to compile
|
||||
* @return an instance of the class implementing the compiled expression, or null
|
||||
* if compilation is not possible
|
||||
* @return an instance of the class implementing the compiled expression,
|
||||
* or {@code null} if compilation is not possible
|
||||
*/
|
||||
public CompiledExpression compile(SpelNodeImpl expression) {
|
||||
if (expression.isCompilable()) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -27,6 +27,7 @@ import org.springframework.expression.TypeConverter;
|
|||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MethodInvoker;
|
||||
|
||||
/**
|
||||
|
|
@ -141,8 +142,8 @@ public class ReflectionHelper {
|
|||
static ArgumentsMatchInfo compareArgumentsVarargs(
|
||||
List<TypeDescriptor> expectedArgTypes, List<TypeDescriptor> suppliedArgTypes, TypeConverter typeConverter) {
|
||||
|
||||
Assert.isTrue(expectedArgTypes != null && expectedArgTypes.size() > 0,
|
||||
"Expected arguments must at least include one array (the vargargs parameter)");
|
||||
Assert.isTrue(!CollectionUtils.isEmpty(expectedArgTypes),
|
||||
"Expected arguments must at least include one array (the varargs parameter)");
|
||||
Assert.isTrue(expectedArgTypes.get(expectedArgTypes.size() - 1).isArray(),
|
||||
"Final expected argument should be array type (the varargs parameter)");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -44,6 +44,7 @@ public class ReflectiveMethodExecutor implements MethodExecutor {
|
|||
|
||||
private boolean argumentConversionOccurred = false;
|
||||
|
||||
|
||||
public ReflectiveMethodExecutor(Method method) {
|
||||
this.method = method;
|
||||
if (method.isVarArgs()) {
|
||||
|
|
@ -55,6 +56,7 @@ public class ReflectiveMethodExecutor implements MethodExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public Method getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
|
@ -68,8 +70,8 @@ public class ReflectiveMethodExecutor implements MethodExecutor {
|
|||
* method (if there is one!). For toString() it may walk as far as Object.
|
||||
*/
|
||||
public Class<?> getPublicDeclaringClass() {
|
||||
if (!computedPublicDeclaringClass) {
|
||||
this.publicDeclaringClass = discoverPublicClass(method, method.getDeclaringClass());
|
||||
if (!this.computedPublicDeclaringClass) {
|
||||
this.publicDeclaringClass = discoverPublicClass(this.method, this.method.getDeclaringClass());
|
||||
this.computedPublicDeclaringClass = true;
|
||||
}
|
||||
return this.publicDeclaringClass;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -93,14 +93,23 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
return this.rootObject;
|
||||
}
|
||||
|
||||
public void addConstructorResolver(ConstructorResolver resolver) {
|
||||
ensureConstructorResolversInitialized();
|
||||
this.constructorResolvers.add(this.constructorResolvers.size() - 1, resolver);
|
||||
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) {
|
||||
this.propertyAccessors = propertyAccessors;
|
||||
}
|
||||
|
||||
public boolean removeConstructorResolver(ConstructorResolver resolver) {
|
||||
ensureConstructorResolversInitialized();
|
||||
return this.constructorResolvers.remove(resolver);
|
||||
@Override
|
||||
public List<PropertyAccessor> getPropertyAccessors() {
|
||||
ensurePropertyAccessorsInitialized();
|
||||
return this.propertyAccessors;
|
||||
}
|
||||
|
||||
public void addPropertyAccessor(PropertyAccessor accessor) {
|
||||
ensurePropertyAccessorsInitialized();
|
||||
this.propertyAccessors.add(this.propertyAccessors.size() - 1, accessor);
|
||||
}
|
||||
|
||||
public boolean removePropertyAccessor(PropertyAccessor accessor) {
|
||||
return this.propertyAccessors.remove(accessor);
|
||||
}
|
||||
|
||||
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers) {
|
||||
|
|
@ -113,14 +122,14 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
return this.constructorResolvers;
|
||||
}
|
||||
|
||||
public void addMethodResolver(MethodResolver resolver) {
|
||||
ensureMethodResolversInitialized();
|
||||
this.methodResolvers.add(this.methodResolvers.size() - 1, resolver);
|
||||
public void addConstructorResolver(ConstructorResolver resolver) {
|
||||
ensureConstructorResolversInitialized();
|
||||
this.constructorResolvers.add(this.constructorResolvers.size() - 1, resolver);
|
||||
}
|
||||
|
||||
public boolean removeMethodResolver(MethodResolver methodResolver) {
|
||||
ensureMethodResolversInitialized();
|
||||
return this.methodResolvers.remove(methodResolver);
|
||||
public boolean removeConstructorResolver(ConstructorResolver resolver) {
|
||||
ensureConstructorResolversInitialized();
|
||||
return this.constructorResolvers.remove(resolver);
|
||||
}
|
||||
|
||||
public void setMethodResolvers(List<MethodResolver> methodResolvers) {
|
||||
|
|
@ -133,6 +142,16 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
return this.methodResolvers;
|
||||
}
|
||||
|
||||
public void addMethodResolver(MethodResolver resolver) {
|
||||
ensureMethodResolversInitialized();
|
||||
this.methodResolvers.add(this.methodResolvers.size() - 1, resolver);
|
||||
}
|
||||
|
||||
public boolean removeMethodResolver(MethodResolver methodResolver) {
|
||||
ensureMethodResolversInitialized();
|
||||
return this.methodResolvers.remove(methodResolver);
|
||||
}
|
||||
|
||||
public void setBeanResolver(BeanResolver beanResolver) {
|
||||
this.beanResolver = beanResolver;
|
||||
}
|
||||
|
|
@ -142,25 +161,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
return this.beanResolver;
|
||||
}
|
||||
|
||||
public void addPropertyAccessor(PropertyAccessor accessor) {
|
||||
ensurePropertyAccessorsInitialized();
|
||||
this.propertyAccessors.add(this.propertyAccessors.size() - 1, accessor);
|
||||
}
|
||||
|
||||
public boolean removePropertyAccessor(PropertyAccessor accessor) {
|
||||
return this.propertyAccessors.remove(accessor);
|
||||
}
|
||||
|
||||
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) {
|
||||
this.propertyAccessors = propertyAccessors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyAccessor> getPropertyAccessors() {
|
||||
ensurePropertyAccessorsInitialized();
|
||||
return this.propertyAccessors;
|
||||
}
|
||||
|
||||
public void setTypeLocator(TypeLocator typeLocator) {
|
||||
Assert.notNull(typeLocator, "TypeLocator must not be null");
|
||||
this.typeLocator = typeLocator;
|
||||
|
|
@ -169,7 +169,7 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
@Override
|
||||
public TypeLocator getTypeLocator() {
|
||||
if (this.typeLocator == null) {
|
||||
this.typeLocator = new StandardTypeLocator();
|
||||
this.typeLocator = new StandardTypeLocator();
|
||||
}
|
||||
return this.typeLocator;
|
||||
}
|
||||
|
|
@ -244,6 +244,7 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void ensurePropertyAccessorsInitialized() {
|
||||
if (this.propertyAccessors == null) {
|
||||
initializePropertyAccessors();
|
||||
|
|
@ -258,6 +259,20 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureConstructorResolversInitialized() {
|
||||
if (this.constructorResolvers == null) {
|
||||
initializeConstructorResolvers();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void initializeConstructorResolvers() {
|
||||
if (this.constructorResolvers == null) {
|
||||
List<ConstructorResolver> defaultResolvers = new ArrayList<ConstructorResolver>();
|
||||
defaultResolvers.add(new ReflectiveConstructorResolver());
|
||||
this.constructorResolvers = defaultResolvers;
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureMethodResolversInitialized() {
|
||||
if (this.methodResolvers == null) {
|
||||
initializeMethodResolvers();
|
||||
|
|
@ -273,18 +288,4 @@ public class StandardEvaluationContext implements EvaluationContext {
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureConstructorResolversInitialized() {
|
||||
if (this.constructorResolvers == null) {
|
||||
initializeConstructorResolvers();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void initializeConstructorResolvers() {
|
||||
if (this.constructorResolvers == null) {
|
||||
List<ConstructorResolver> defaultResolvers = new ArrayList<ConstructorResolver>();
|
||||
defaultResolvers.add(new ReflectiveConstructorResolver());
|
||||
this.constructorResolvers = defaultResolvers;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -67,8 +67,9 @@ public class StandardTypeConverter implements TypeConverter {
|
|||
return this.conversionService.convert(value, sourceType, targetType);
|
||||
}
|
||||
catch (ConversionException ex) {
|
||||
throw new SpelEvaluationException(
|
||||
ex, SpelMessage.TYPE_CONVERSION_ERROR, sourceType.toString(), targetType.toString());
|
||||
throw new SpelEvaluationException(ex, SpelMessage.TYPE_CONVERSION_ERROR,
|
||||
(sourceType != null ? sourceType.toString() : (value != null ? value.getClass().getName() : "null")),
|
||||
targetType.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
|
|||
// Apply kept transaction settings, if any.
|
||||
if (this.readOnly) {
|
||||
try {
|
||||
this.target.setReadOnly(this.readOnly);
|
||||
this.target.setReadOnly(true);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// "read-only not supported" -> ignore, it's just a hint anyway
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -153,7 +153,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
|||
* @see #addScript(Resource)
|
||||
*/
|
||||
public void setSqlScriptEncoding(String sqlScriptEncoding) {
|
||||
this.sqlScriptEncoding = StringUtils.hasText(sqlScriptEncoding) ? sqlScriptEncoding : null;
|
||||
this.sqlScriptEncoding = (StringUtils.hasText(sqlScriptEncoding) ? sqlScriptEncoding : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +17,7 @@
|
|||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.util.InvalidMimeTypeException;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
|
|
@ -29,15 +30,11 @@ public interface ContentTypeResolver {
|
|||
|
||||
/**
|
||||
* Determine the {@link MimeType} of a message from the given MessageHeaders.
|
||||
*
|
||||
* @param headers the headers to use for the resolution
|
||||
* @return the resolved {@code MimeType} of {@code null} if none found
|
||||
*
|
||||
* @throws org.springframework.util.InvalidMimeTypeException if the content type
|
||||
* is a String that cannot be parsed
|
||||
* @throws java.lang.IllegalArgumentException if there is a content type but
|
||||
* its type is unknown
|
||||
* @return the resolved {@code MimeType}, or {@code null} if none found
|
||||
* @throws InvalidMimeTypeException if the content type is a String that cannot be parsed
|
||||
* @throws IllegalArgumentException if there is a content type but its type is unknown
|
||||
*/
|
||||
MimeType resolve(MessageHeaders headers);
|
||||
MimeType resolve(MessageHeaders headers) throws InvalidMimeTypeException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -175,7 +175,7 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
|
|||
payload = writer.toString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex);
|
||||
}
|
||||
return payload;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -190,6 +190,9 @@ public class DestinationPatternsMessageCondition extends AbstractMessageConditio
|
|||
@Override
|
||||
public int compareTo(DestinationPatternsMessageCondition other, Message<?> message) {
|
||||
String destination = (String) message.getHeaders().get(LOOKUP_DESTINATION_HEADER);
|
||||
if (destination == null) {
|
||||
return 0;
|
||||
}
|
||||
Comparator<String> patternComparator = this.pathMatcher.getPatternComparator(destination);
|
||||
|
||||
Iterator<String> iterator = patterns.iterator();
|
||||
|
|
|
|||
|
|
@ -38,11 +38,14 @@ import org.springframework.util.ClassUtils;
|
|||
*/
|
||||
public abstract class AbstractExceptionHandlerMethodResolver {
|
||||
|
||||
private static final Method NO_METHOD_FOUND = ClassUtils.getMethodIfAvailable(System.class, "currentTimeMillis");
|
||||
private static final Method NO_METHOD_FOUND =
|
||||
ClassUtils.getMethodIfAvailable(System.class, "currentTimeMillis");
|
||||
|
||||
private final Map<Class<? extends Throwable>, Method> mappedMethods = new ConcurrentHashMap<Class<? extends Throwable>, Method>(16);
|
||||
private final Map<Class<? extends Throwable>, Method> mappedMethods =
|
||||
new ConcurrentHashMap<Class<? extends Throwable>, Method>(16);
|
||||
|
||||
private final Map<Class<? extends Throwable>, Method> exceptionLookupCache = new ConcurrentHashMap<Class<? extends Throwable>, Method>(16);
|
||||
private final Map<Class<? extends Throwable>, Method> exceptionLookupCache =
|
||||
new ConcurrentHashMap<Class<? extends Throwable>, Method>(16);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -40,13 +40,13 @@ public interface HandlerMethodReturnValueHandler {
|
|||
/**
|
||||
* Handle the given return value.
|
||||
* @param returnValue the value returned from the handler method
|
||||
* @param returnType the type of the return value. This type must have
|
||||
* previously been passed to
|
||||
* {@link #supportsReturnType(org.springframework.core.MethodParameter)}
|
||||
* and it must have returned {@code true}
|
||||
* @param returnType the type of the return value. This type must have previously
|
||||
* been passed to {@link #supportsReturnType(org.springframework.core.MethodParameter)}
|
||||
* and it must have returned {@code true}.
|
||||
* @param message the message that caused this method to be called
|
||||
* @throws Exception if the return value handling results in an error
|
||||
*/
|
||||
void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception;
|
||||
void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -19,7 +19,6 @@ package org.springframework.messaging.simp;
|
|||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
|
||||
/**
|
||||
* Holder class to expose SiMP attributes associated with a session (e.g. WebSocket)
|
||||
* in the form of a thread-bound {@link SimpAttributes} object.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue