Updated to spring 3.0.6
parent
f39f6ff692
commit
9fe01a9403
|
@ -1,2 +1,4 @@
|
||||||
target/*
|
target/*
|
||||||
.pmd
|
.pmd
|
||||||
|
.scala_dependencies
|
||||||
|
.settings/
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -19,6 +19,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<scala.version>2.7.7</scala.version>
|
<scala.version>2.7.7</scala.version>
|
||||||
|
<spring.version>3.0.6.RELEASE</spring.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
|
@ -189,6 +190,7 @@
|
||||||
<groupId>org.scala-lang</groupId>
|
<groupId>org.scala-lang</groupId>
|
||||||
<artifactId>scala-library</artifactId>
|
<artifactId>scala-library</artifactId>
|
||||||
<version>${scala.version}</version>
|
<version>${scala.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scalatest</groupId>
|
<groupId>org.scalatest</groupId>
|
||||||
|
@ -205,12 +207,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
<version>3.0.2.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-expression</artifactId>
|
<artifactId>spring-expression</artifactId>
|
||||||
<version>3.0.2.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
package net.abhinavsarkar.spelhelper;
|
package net.abhinavsarkar.spelhelper;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Arrays;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.core.convert.TypeDescriptor;
|
||||||
import org.springframework.expression.AccessException;
|
import org.springframework.expression.AccessException;
|
||||||
import org.springframework.expression.ConstructorExecutor;
|
import org.springframework.expression.ConstructorExecutor;
|
||||||
import org.springframework.expression.ConstructorResolver;
|
import org.springframework.expression.ConstructorResolver;
|
||||||
|
@ -31,13 +32,16 @@ final class ImplicitConstructorResolver implements
|
||||||
|
|
||||||
private final ReflectiveConstructorResolver delegate = new ReflectiveConstructorResolver();
|
private final ReflectiveConstructorResolver delegate = new ReflectiveConstructorResolver();
|
||||||
|
|
||||||
public ConstructorExecutor resolve(final EvaluationContext context,
|
@Override
|
||||||
final String typeName, final Class<?>[] argumentTypes) throws AccessException {
|
public ConstructorExecutor resolve(
|
||||||
|
final EvaluationContext context, final String typeName,
|
||||||
|
final List<TypeDescriptor> argumentTypes)
|
||||||
|
throws AccessException {
|
||||||
try {
|
try {
|
||||||
return delegate.resolve(context, typeName, argumentTypes);
|
return delegate.resolve(context, typeName, argumentTypes);
|
||||||
} catch (AccessException ex) {
|
} catch (AccessException ex) {
|
||||||
Object variable = ((SpelHelper) context.lookupVariable(SpelHelper.CONTEXT_LOOKUP_KEY))
|
Object variable = ((SpelHelper) context.lookupVariable(SpelHelper.CONTEXT_LOOKUP_KEY))
|
||||||
.lookupImplicitConstructor(typeName + Arrays.toString(argumentTypes));
|
.lookupImplicitConstructor(typeName + argumentTypes.toString());
|
||||||
if (variable instanceof Constructor<?>) {
|
if (variable instanceof Constructor<?>) {
|
||||||
Constructor<?> constructor = (Constructor<?>) variable;
|
Constructor<?> constructor = (Constructor<?>) variable;
|
||||||
return delegate.resolve(context, constructor.getDeclaringClass().getName(), argumentTypes);
|
return delegate.resolve(context, constructor.getDeclaringClass().getName(), argumentTypes);
|
||||||
|
|
|
@ -19,8 +19,11 @@ package net.abhinavsarkar.spelhelper;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.springframework.core.convert.TypeDescriptor;
|
||||||
import org.springframework.expression.AccessException;
|
import org.springframework.expression.AccessException;
|
||||||
import org.springframework.expression.EvaluationContext;
|
import org.springframework.expression.EvaluationContext;
|
||||||
import org.springframework.expression.MethodExecutor;
|
import org.springframework.expression.MethodExecutor;
|
||||||
|
@ -33,6 +36,8 @@ final class ImplicitMethodResolver implements MethodResolver {
|
||||||
private static final ConcurrentHashMap<String, MethodExecutor> CACHE =
|
private static final ConcurrentHashMap<String, MethodExecutor> CACHE =
|
||||||
new ConcurrentHashMap<String, MethodExecutor>();
|
new ConcurrentHashMap<String, MethodExecutor>();
|
||||||
|
|
||||||
|
private final ReflectiveMethodResolver delegate = new ReflectiveMethodResolver();
|
||||||
|
|
||||||
private static final MethodExecutor NULL_ME = new MethodExecutor() {
|
private static final MethodExecutor NULL_ME = new MethodExecutor() {
|
||||||
public TypedValue execute(final EvaluationContext context, final Object target,
|
public TypedValue execute(final EvaluationContext context, final Object target,
|
||||||
final Object... arguments) throws AccessException {
|
final Object... arguments) throws AccessException {
|
||||||
|
@ -57,9 +62,11 @@ final class ImplicitMethodResolver implements MethodResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodExecutor resolve(final EvaluationContext context,
|
@Override
|
||||||
final Object targetObject, final String name, final Class<?>[] argumentTypes)
|
public MethodExecutor resolve(
|
||||||
throws AccessException {
|
final EvaluationContext context, final Object targetObject,
|
||||||
|
final String name, final List<TypeDescriptor> argumentTypes)
|
||||||
|
throws AccessException {
|
||||||
if (targetObject == null) {
|
if (targetObject == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -78,13 +85,13 @@ final class ImplicitMethodResolver implements MethodResolver {
|
||||||
Class<?> firstParamType = parameterTypes[0];
|
Class<?> firstParamType = parameterTypes[0];
|
||||||
if (parameterTypes.length > 0
|
if (parameterTypes.length > 0
|
||||||
&& firstParamType.isAssignableFrom(type)) {
|
&& firstParamType.isAssignableFrom(type)) {
|
||||||
Class<?>[] newArgumentTypes = new Class[argumentTypes.length + 1];
|
List<TypeDescriptor> newArgumentTypes = new ArrayList<TypeDescriptor>();
|
||||||
newArgumentTypes[0] = firstParamType;
|
newArgumentTypes.add(TypeDescriptor.valueOf(firstParamType));
|
||||||
System.arraycopy(argumentTypes, 0, newArgumentTypes,
|
newArgumentTypes.addAll(argumentTypes);
|
||||||
1, argumentTypes.length);
|
|
||||||
MethodExecutor executor = new ReflectiveMethodResolver()
|
MethodExecutor executor =
|
||||||
.resolve(context, method.getDeclaringClass(), name,
|
delegate.resolve(context, method.getDeclaringClass(),
|
||||||
newArgumentTypes);
|
name, newArgumentTypes);
|
||||||
MethodExecutor wrappedExecutor = executor == null ? null
|
MethodExecutor wrappedExecutor = executor == null ? null
|
||||||
: new ImplicitMethodExecutor(executor);
|
: new ImplicitMethodExecutor(executor);
|
||||||
if (wrappedExecutor == null) {
|
if (wrappedExecutor == null) {
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
package net.abhinavsarkar.spelhelper;
|
package net.abhinavsarkar.spelhelper;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.springframework.core.convert.TypeDescriptor;
|
||||||
import org.springframework.expression.AccessException;
|
import org.springframework.expression.AccessException;
|
||||||
import org.springframework.expression.EvaluationContext;
|
import org.springframework.expression.EvaluationContext;
|
||||||
import org.springframework.expression.MethodExecutor;
|
import org.springframework.expression.MethodExecutor;
|
||||||
|
@ -42,7 +44,8 @@ final class ImplicitPropertyAccessor extends ReadOnlyGenericPropertyAccessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MethodResolver mr : context.getMethodResolvers()) {
|
for (MethodResolver mr : context.getMethodResolvers()) {
|
||||||
MethodExecutor me = mr.resolve(context, target, name, new Class[0]);
|
MethodExecutor me =
|
||||||
|
mr.resolve(context, target, name, Collections.<TypeDescriptor>emptyList());
|
||||||
if (me != null) {
|
if (me != null) {
|
||||||
CACHE.putIfAbsent(cacheKey, me);
|
CACHE.putIfAbsent(cacheKey, me);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue