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