Polishing

This commit is contained in:
Juergen Hoeller
2016-03-25 23:28:45 +01:00
parent 862d10c128
commit 94cb7786c8
7 changed files with 37 additions and 33 deletions

View File

@@ -777,4 +777,5 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
return (this.cacheOperation.hashCode() * 31 + this.methodCacheKey.hashCode());
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.util.ObjectUtils;
*
* @author Costin Leau
* @author Stephane Nicoll
* @since 4.2.0
* @since 4.2
* @see CachedExpressionEvaluator
*/
public final class AnnotatedElementKey {
@@ -36,12 +36,13 @@ public final class AnnotatedElementKey {
private final Class<?> targetClass;
/**
* Create a new instance with the specified {@link AnnotatedElement} and
* optional target {@link Class}.
*/
public AnnotatedElementKey(AnnotatedElement element, Class<?> targetClass) {
Assert.notNull(element, "AnnotatedElement must be set.");
Assert.notNull(element, "AnnotatedElement must not be null");
this.element = element;
this.targetClass = targetClass;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,13 +28,14 @@ import org.springframework.util.ObjectUtils;
* are defined on {@link java.lang.reflect.AnnotatedElement}.
*
* @author Stephane Nicoll
* @since 4.2.0
* @since 4.2
* @see AnnotatedElementKey
*/
public abstract class CachedExpressionEvaluator {
private final SpelExpressionParser parser;
/**
* Create a new instance with the specified {@link SpelExpressionParser}.
*/
@@ -50,6 +51,7 @@ public abstract class CachedExpressionEvaluator {
this(new SpelExpressionParser());
}
/**
* Return the {@link SpelExpressionParser} to use.
*/
@@ -57,6 +59,7 @@ public abstract class CachedExpressionEvaluator {
return this.parser;
}
/**
* Return the {@link Expression} for the specified SpEL value
* <p>Parse the expression if it hasn't been already.
@@ -66,6 +69,7 @@ public abstract class CachedExpressionEvaluator {
*/
protected Expression getExpression(Map<ExpressionKey, Expression> cache,
AnnotatedElementKey elementKey, String expression) {
ExpressionKey expressionKey = createKey(elementKey, expression);
Expression expr = cache.get(expressionKey);
if (expr == null) {
@@ -79,6 +83,7 @@ public abstract class CachedExpressionEvaluator {
return new ExpressionKey(elementKey, expression);
}
protected static class ExpressionKey {
private final AnnotatedElementKey key;
@@ -105,7 +110,7 @@ public abstract class CachedExpressionEvaluator {
@Override
public int hashCode() {
return this.key.hashCode() * 29 + (this.expression != null ? this.expression.hashCode() : 0);
return this.key.hashCode() + (this.expression != null ? this.expression.hashCode() * 29 : 0);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +25,8 @@ import org.springframework.util.ObjectUtils;
/**
* A method-based {@link org.springframework.expression.EvaluationContext} that
* provides explicit support for method-based invocations.
* <p>
* Expose the actual method arguments using the following aliases:
*
* <p>Expose the actual method arguments using the following aliases:
* <ol>
* <li>pX where X is the index of the argument (p0 for the first argument)</li>
* <li>aX where X is the index of the argument (a1 for the second argument)</li>
@@ -34,7 +34,7 @@ import org.springframework.util.ObjectUtils;
* </ol>
*
* @author Stephane Nicoll
* @since 4.2.0
* @since 4.2
*/
public class MethodBasedEvaluationContext extends StandardEvaluationContext {
@@ -46,6 +46,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext {
private boolean paramLoaded = false;
public MethodBasedEvaluationContext(Object rootObject, Method method, Object[] args,
ParameterNameDiscoverer paramDiscoverer) {
@@ -55,6 +56,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext {
this.paramDiscoverer = paramDiscoverer;
}
@Override
public Object lookupVariable(String name) {
Object variable = super.lookupVariable(name);