Tabnine Logo
ReflectiveMethodResolver
Code IndexAdd Tabnine to your IDE (free)

How to use
ReflectiveMethodResolver
in
org.springframework.expression.spel.support

Best Java code snippets using org.springframework.expression.spel.support.ReflectiveMethodResolver (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

@Override
@Nullable
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
    List<TypeDescriptor> argumentTypes) throws AccessException {
  if (targetObject instanceof Class) {
    throw new IllegalArgumentException("DataBindingMethodResolver does not support Class targets");
  }
  return super.resolve(context, targetObject, name, argumentTypes);
}
origin: spring-projects/spring-framework

MethodExecutor me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "methodToCall", args);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 45);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 45f);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 23d);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, (short) 23);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, 23L);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, (char) 65);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, (byte) 23);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "foo", args);
me.execute(emptyEvalContext, ru, true);
me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "bar", args);
me.execute(emptyEvalContext, ru, 12, 23f);
origin: spring-projects/spring-framework

Set<Method> result = new LinkedHashSet<>();
Method[] methods = getMethods(type);
for (Method method : methods) {
  if (Modifier.isStatic(method.getModifiers())) {
Collections.addAll(result, getMethods(Class.class));
return result;
  Method[] methods = getMethods(ifc);
  for (Method method : methods) {
    if (isCandidateForInvocation(method, type)) {
      result.add(method);
Method[] methods = getMethods(type);
for (Method method : methods) {
  if (isCandidateForInvocation(method, type)) {
    result.add(method);
origin: spring-projects/spring-framework

TypeConverter typeConverter = context.getTypeConverter();
Class<?> type = (targetObject instanceof Class ? (Class<?>) targetObject : targetObject.getClass());
ArrayList<Method> methods = new ArrayList<>(getMethods(type, targetObject));
origin: spring-projects/spring-framework

private List<MethodResolver> initMethodResolvers() {
  List<MethodResolver> resolvers = this.methodResolvers;
  if (resolvers == null) {
    resolvers = new ArrayList<>(1);
    this.reflectiveMethodResolver = new ReflectiveMethodResolver();
    resolvers.add(this.reflectiveMethodResolver);
    this.methodResolvers = resolvers;
  }
  return resolvers;
}
origin: spring-projects/spring-framework

/**
 * Register a {@code MethodFilter} which will be called during method resolution
 * for the specified type.
 * <p>The {@code MethodFilter} may remove methods and/or sort the methods which
 * will then be used by SpEL as the candidates to look through for a match.
 * @param type the type for which the filter should be called
 * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type
 * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use
 */
public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException {
  initMethodResolvers();
  ReflectiveMethodResolver resolver = this.reflectiveMethodResolver;
  if (resolver == null) {
    throw new IllegalStateException(
        "Method filter cannot be set as the reflective method resolver is not in use");
  }
  resolver.registerMethodFilter(type, filter);
}
origin: org.springframework/spring-expression

TypeConverter typeConverter = context.getTypeConverter();
Class<?> type = (targetObject instanceof Class ? (Class<?>) targetObject : targetObject.getClass());
ArrayList<Method> methods = new ArrayList<>(getMethods(type, targetObject));
origin: org.springframework/spring-expression

private List<MethodResolver> initMethodResolvers() {
  List<MethodResolver> resolvers = this.methodResolvers;
  if (resolvers == null) {
    resolvers = new ArrayList<>(1);
    this.reflectiveMethodResolver = new ReflectiveMethodResolver();
    resolvers.add(this.reflectiveMethodResolver);
    this.methodResolvers = resolvers;
  }
  return resolvers;
}
origin: org.springframework/spring-expression

/**
 * Register a {@code MethodFilter} which will be called during method resolution
 * for the specified type.
 * <p>The {@code MethodFilter} may remove methods and/or sort the methods which
 * will then be used by SpEL as the candidates to look through for a match.
 * @param type the type for which the filter should be called
 * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type
 * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use
 */
public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException {
  initMethodResolvers();
  ReflectiveMethodResolver resolver = this.reflectiveMethodResolver;
  if (resolver == null) {
    throw new IllegalStateException(
        "Method filter cannot be set as the reflective method resolver is not in use");
  }
  resolver.registerMethodFilter(type, filter);
}
origin: org.springframework/spring-expression

@Override
@Nullable
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
    List<TypeDescriptor> argumentTypes) throws AccessException {
  if (targetObject instanceof Class) {
    throw new IllegalArgumentException("DataBindingMethodResolver does not support Class targets");
  }
  return super.resolve(context, targetObject, name, argumentTypes);
}
origin: spring-projects/spring-framework

@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<>();
  // !!!! With the below line commented you'll get NPE. Uncomment and everything is OK!
  //arguments.add(new Foo());
  List<TypeDescriptor> paramDescriptors = new ArrayList<>();
  Method method = AlwaysTrueReleaseStrategy.class.getMethod("checkCompleteness", List.class);
  paramDescriptors.add(new TypeDescriptor(new MethodParameter(method, 0)));
  List<TypeDescriptor> argumentTypes = new ArrayList<>();
  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);
}
origin: org.springframework/spring-expression

Set<Method> result = new LinkedHashSet<>();
Method[] methods = getMethods(type);
for (Method method : methods) {
  if (Modifier.isStatic(method.getModifiers())) {
Collections.addAll(result, getMethods(Class.class));
return result;
  Method[] methods = getMethods(ifc);
  for (Method method : methods) {
    if (isCandidateForInvocation(method, type)) {
      result.add(method);
Method[] methods = getMethods(type);
for (Method method : methods) {
  if (isCandidateForInvocation(method, type)) {
    result.add(method);
origin: com.netflix.spinnaker.orca/orca-core

 @Override
 protected Method[] getMethods(Class<?> type) {
  Method[] methods = super.getMethods(type);

  List<Method> m = new ArrayList<>(asList(methods));
  m.removeAll(rejectedMethods);
  m = m.stream()
   .filter(it -> ReturnTypeRestrictor.supports(it.getReturnType()))
   .collect(toList());

  return m.toArray(new Method[m.size()]);
 }
}
origin: apache/servicemix-bundles

private List<MethodResolver> initMethodResolvers() {
  List<MethodResolver> resolvers = this.methodResolvers;
  if (resolvers == null) {
    resolvers = new ArrayList<>(1);
    this.reflectiveMethodResolver = new ReflectiveMethodResolver();
    resolvers.add(this.reflectiveMethodResolver);
    this.methodResolvers = resolvers;
  }
  return resolvers;
}
origin: apache/servicemix-bundles

/**
 * Register a {@code MethodFilter} which will be called during method resolution
 * for the specified type.
 * <p>The {@code MethodFilter} may remove methods and/or sort the methods which
 * will then be used by SpEL as the candidates to look through for a match.
 * @param type the type for which the filter should be called
 * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type
 * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use
 */
public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException {
  initMethodResolvers();
  ReflectiveMethodResolver resolver = this.reflectiveMethodResolver;
  if (resolver == null) {
    throw new IllegalStateException(
        "Method filter cannot be set as the reflective method resolver is not in use");
  }
  resolver.registerMethodFilter(type, filter);
}
origin: spring-projects/spring-integration

@Override
public MethodExecutor resolve(EvaluationContext context,
    Object targetObject, String name, List<TypeDescriptor> argumentTypes) throws AccessException {
  this.validateMethod(targetObject, name, (argumentTypes != null ? argumentTypes.size() : 0));
  return super.resolve(context, targetObject, name, argumentTypes);
}
origin: spring-projects/spring-framework

/**
 * Test whether {@link ReflectiveMethodResolver} handles Widening Primitive Conversion. That's passing an 'int' to a
 * method accepting 'long' is ok.
 */
@Test
public void wideningPrimitiveConversion_SPR8224() 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<>();
  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);
}
origin: apache/servicemix-bundles

Set<Method> result = new LinkedHashSet<>();
Method[] methods = getMethods(type);
for (Method method : methods) {
  if (Modifier.isStatic(method.getModifiers())) {
Collections.addAll(result, getMethods(Class.class));
return result;
  Method[] methods = getMethods(ifc);
  for (Method method : methods) {
    if (isCandidateForInvocation(method, type)) {
      result.add(method);
Method[] methods = getMethods(type);
for (Method method : methods) {
  if (isCandidateForInvocation(method, type)) {
    result.add(method);
origin: com.netflix.spinnaker.kork/kork-expressions

 @Override
 protected Method[] getMethods(Class<?> type) {
  Method[] methods = super.getMethods(type);

  List<Method> m = new ArrayList<>(asList(methods));
  m.removeAll(rejectedMethods);
  m = m.stream()
   .filter(it -> returnTypeRestrictor.supports(it.getReturnType()))
   .collect(toList());

  return m.toArray(new Method[0]);
 }
}
origin: apache/servicemix-bundles

@Override
@Nullable
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
    List<TypeDescriptor> argumentTypes) throws AccessException {
  if (targetObject instanceof Class) {
    throw new IllegalArgumentException("DataBindingMethodResolver does not support Class targets");
  }
  return super.resolve(context, targetObject, name, argumentTypes);
}
org.springframework.expression.spel.supportReflectiveMethodResolver

Javadoc

Reflection-based MethodResolver used by default in StandardEvaluationContextunless explicit method resolvers have been specified.

Most used methods

  • resolve
    Locate a method on a type. There are three kinds of match that might occur: 1. an exact match w
  • <init>
    This constructor allows the ReflectiveMethodResolver to be configured such that it will use a distan
  • getMethods
  • isCandidateForInvocation
    Determine whether the given Method is a candidate for method resolution on an instance of the given
  • registerMethodFilter
    Register a filter for methods on the given type.

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • Kernel (java.awt.image)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JPanel (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now