本文整理汇总了Java中org.springframework.expression.MethodExecutor类的典型用法代码示例。如果您正苦于以下问题:Java MethodExecutor类的具体用法?Java MethodExecutor怎么用?Java MethodExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodExecutor类属于org.springframework.expression包,在下文中一共展示了MethodExecutor类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCachedExecutor
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
private MethodExecutor getCachedExecutor(EvaluationContext evaluationContext, Object value,
TypeDescriptor target, List<TypeDescriptor> argumentTypes) {
List<MethodResolver> methodResolvers = evaluationContext.getMethodResolvers();
if (methodResolvers == null || methodResolvers.size() != 1 ||
!(methodResolvers.get(0) instanceof ReflectiveMethodResolver)) {
// Not a default ReflectiveMethodResolver - don't know whether caching is valid
return null;
}
CachedMethodExecutor executorToCheck = this.cachedExecutor;
if (executorToCheck != null && executorToCheck.isSuitable(value, target, argumentTypes)) {
return executorToCheck.get();
}
this.cachedExecutor = null;
return null;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:MethodReference.java
示例2: findAccessorForMethod
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
private MethodExecutor findAccessorForMethod(String name, List<TypeDescriptor> argumentTypes,
Object targetObject, EvaluationContext evaluationContext) throws SpelEvaluationException {
List<MethodResolver> methodResolvers = evaluationContext.getMethodResolvers();
if (methodResolvers != null) {
for (MethodResolver methodResolver : methodResolvers) {
try {
MethodExecutor methodExecutor = methodResolver.resolve(
evaluationContext, targetObject, name, argumentTypes);
if (methodExecutor != null) {
return methodExecutor;
}
}
catch (AccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.PROBLEM_LOCATING_METHOD, name, targetObject.getClass());
}
}
}
throw new SpelEvaluationException(getStartPosition(), SpelMessage.METHOD_NOT_FOUND,
FormatHelper.formatMethodForMessage(name, argumentTypes),
FormatHelper.formatClassNameForMessage(
targetObject instanceof Class ? ((Class<?>) targetObject) : targetObject.getClass()));
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:MethodReference.java
示例3: wideningPrimitiveConversion_8224
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
/**
* Test whether {@link ReflectiveMethodResolver} handles Widening Primitive Conversion. That's passing an 'int' to a
* method accepting 'long' is ok.
*/
@Test
public void wideningPrimitiveConversion_8224() throws Exception {
class WideningPrimitiveConversion {
public int getX(long i) {
return 10;
}
}
final Integer INTEGER_VALUE = Integer.valueOf(7);
WideningPrimitiveConversion target = new WideningPrimitiveConversion();
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
List<TypeDescriptor> args = new ArrayList<TypeDescriptor>();
args.add(TypeDescriptor.forObject(INTEGER_VALUE));
MethodExecutor me = new ReflectiveMethodResolver(true).resolve(emptyEvalContext, target, "getX", args);
final int actual = (Integer) me.execute(emptyEvalContext, target, INTEGER_VALUE).getValue();
final int compiler = target.getX(INTEGER_VALUE);
assertEquals(compiler, actual);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:SpelReproTests.java
示例4: repro
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Ignore @Test
public void repro() throws Exception {
AlwaysTrueReleaseStrategy target = new AlwaysTrueReleaseStrategy();
BeanFactoryTypeConverter converter = new BeanFactoryTypeConverter();
StandardEvaluationContext context = new StandardEvaluationContext();
context.setTypeConverter(converter);
List<Foo> arguments = new ArrayList<Foo>();
// !!!! With the below line commented you'll get NPE. Uncomment and everything is OK!
//arguments.add(new Foo());
List<TypeDescriptor> paramDescriptors = new ArrayList<TypeDescriptor>();
Method method = AlwaysTrueReleaseStrategy.class.getMethod("checkCompleteness", List.class);
paramDescriptors.add(new TypeDescriptor(new MethodParameter(method, 0)));
List<TypeDescriptor> argumentTypes = new ArrayList<TypeDescriptor>();
argumentTypes.add(TypeDescriptor.forObject(arguments));
ReflectiveMethodResolver resolver = new ReflectiveMethodResolver();
MethodExecutor executor = resolver.resolve(context, target, "checkCompleteness", argumentTypes);
Object result = executor.execute(context, target, arguments);
System.out.println("Result: " + result);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:Spr7538Tests.java
示例5: CachedMethodExecutor
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
public CachedMethodExecutor(MethodExecutor methodExecutor, Class<?> staticClass,
TypeDescriptor target, List<TypeDescriptor> argumentTypes) {
this.methodExecutor = methodExecutor;
this.staticClass = staticClass;
this.target = target;
this.argumentTypes = argumentTypes;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:MethodReference.java
示例6: resolve
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Override
public MethodExecutor resolve(
EvaluationContext context,
Object targetObject,
String name,
List<TypeDescriptor> argumentTypes
) throws AccessException {
return Martini.class.isInstance(targetObject) ? resolve(name, argumentTypes) : null;
}
开发者ID:qas-guru,项目名称:martini-core,代码行数:10,代码来源:TagResolver.java
示例7: resolve
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Override
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name, List<TypeDescriptor> arguments)
throws AccessException {
if (name.equals("hasRole")) {
return new HasRoleExecutor(context.getTypeConverter());
}
return null;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:ScenariosForSpringSecurity.java
示例8: range
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
private MethodExecutor range () {
return (ctx,target,args) -> {
List<Integer> value = IntStream.rangeClosed((int)args[0], (int)args[1])
.boxed()
.collect(Collectors.toList());
return new TypedValue(value);
};
}
开发者ID:creactiviti,项目名称:piper,代码行数:9,代码来源:SpelTaskEvaluator.java
示例9: resolve
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
List<TypeDescriptor> argumentTypes) throws AccessException {
if (targetObject instanceof SecurityExpressionRoot) {
if ("oauthConsumerHasRole".equals(name) || "oauthConsumerHasAnyRole".equals(name)) {
return new OAuthClientRoleExecutor();
} else if ("denyOAuthConsumer".equals(name)) {
return new DenyOAuthClientRoleExecutor();
}
}
return null;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:13,代码来源:OAuthMethodSecurityExpressionHandler.java
示例10: getValueInternal
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
private TypedValue getValueInternal(EvaluationContext evaluationContext,
Object value, TypeDescriptor targetType, Object[] arguments) {
List<TypeDescriptor> argumentTypes = getArgumentTypes(arguments);
if (value == null) {
throwIfNotNullSafe(argumentTypes);
return TypedValue.NULL;
}
MethodExecutor executorToUse = getCachedExecutor(evaluationContext, value, targetType, argumentTypes);
if (executorToUse != null) {
try {
return executorToUse.execute(evaluationContext, value, arguments);
}
catch (AccessException ae) {
// Two reasons this can occur:
// 1. the method invoked actually threw a real exception
// 2. the method invoked was not passed the arguments it expected and
// has become 'stale'
// In the first case we should not retry, in the second case we should see
// if there is a better suited method.
// To determine the situation, the AccessException will contain a cause.
// If the cause is an InvocationTargetException, a user exception was
// thrown inside the method. Otherwise the method could not be invoked.
throwSimpleExceptionIfPossible(value, ae);
// At this point we know it wasn't a user problem so worth a retry if a
// better candidate can be found.
this.cachedExecutor = null;
}
}
// either there was no accessor or it no longer existed
executorToUse = findAccessorForMethod(this.name, argumentTypes, value, evaluationContext);
this.cachedExecutor = new CachedMethodExecutor(
executorToUse, (value instanceof Class ? (Class<?>) value : null), targetType, argumentTypes);
try {
return executorToUse.execute(evaluationContext, value, arguments);
}
catch (AccessException ex) {
// Same unwrapping exception handling as above in above catch block
throwSimpleExceptionIfPossible(value, ex);
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION, this.name,
value.getClass().getName(), ex.getMessage());
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:MethodReference.java
示例11: get
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
public MethodExecutor get() {
return this.methodExecutor;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:MethodReference.java
示例12: resolve
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Override
public MethodExecutor resolve(EvaluationContext context,
Object targetObject, String name,
List<TypeDescriptor> argumentTypes) throws AccessException {
return null;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:EvaluationTests.java
示例13: resolve
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Override
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
List<TypeDescriptor> argumentTypes) throws AccessException {
throw new UnsupportedOperationException();
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:MethodInvocationTests.java
示例14: varargsAndPrimitives_SPR8174
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Test
public void varargsAndPrimitives_SPR8174() throws Exception {
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
List<TypeDescriptor> args = new ArrayList<TypeDescriptor>();
args.add(TypeDescriptor.forObject(34L));
ReflectionUtil<Integer> ru = new ReflectionUtil<Integer>();
MethodExecutor me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "methodToCall", args);
args.set(0, TypeDescriptor.forObject(23));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 45);
args.set(0, TypeDescriptor.forObject(23f));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 45f);
args.set(0, TypeDescriptor.forObject(23d));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 23d);
args.set(0, TypeDescriptor.forObject((short) 23));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, (short) 23);
args.set(0, TypeDescriptor.forObject(23L));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 23L);
args.set(0, TypeDescriptor.forObject((char) 65));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, (char) 65);
args.set(0, TypeDescriptor.forObject((byte) 23));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, (byte) 23);
args.set(0, TypeDescriptor.forObject(true));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, true);
// trickier:
args.set(0, TypeDescriptor.forObject(12));
args.add(TypeDescriptor.forObject(23f));
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "bar", args);
me.execute(emptyEvalContext, ru, 12, 23f);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:48,代码来源:SpelReproTests.java
示例15: cast
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
private <T> MethodExecutor cast(Class<T> type) {
return (ctx,target,args) -> {
T value = type.cast(ConvertUtils.convert(args[0], type));
return new TypedValue(value);
};
}
开发者ID:creactiviti,项目名称:piper,代码行数:7,代码来源:SpelTaskEvaluator.java
示例16: resolve
import org.springframework.expression.MethodExecutor; //导入依赖的package包/类
@Override
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
List<TypeDescriptor> argumentTypes) throws AccessException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:6,代码来源:MethodInvocationTests.java
注:本文中的org.springframework.expression.MethodExecutor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论