Example usage for org.springframework.util ReflectionUtils.MethodFilter ReflectionUtils.MethodFilter

List of usage examples for org.springframework.util ReflectionUtils.MethodFilter ReflectionUtils.MethodFilter

Introduction

In this page you can find the example usage for org.springframework.util ReflectionUtils.MethodFilter ReflectionUtils.MethodFilter.

Prototype

ReflectionUtils.MethodFilter

Source Link

Usage

From source file:org.springframework.messaging.handler.method.AbstractMethodMessageHandler.java

/**
 * Detect if the given handler has any methods that can handle messages and if
 * so register it with the extracted mapping information.
 * @param handler the handler to check, either an instance of a Spring bean name
 *//* w  ww.j ava2s  .  c  o  m*/
protected final void detectHandlerMethods(Object handler) {

    Class<?> handlerType = (handler instanceof String) ? this.applicationContext.getType((String) handler)
            : handler.getClass();

    final Class<?> userType = ClassUtils.getUserClass(handlerType);

    Set<Method> methods = HandlerMethodSelector.selectMethods(userType, new ReflectionUtils.MethodFilter() {
        @Override
        public boolean matches(Method method) {
            return getMappingForMethod(method, userType) != null;
        }
    });

    for (Method method : methods) {
        T mapping = getMappingForMethod(method, userType);
        registerHandlerMethod(handler, method, mapping);
    }
}