List of usage examples for org.springframework.util ReflectionUtils USER_DECLARED_METHODS
MethodFilter USER_DECLARED_METHODS
To view the source code for org.springframework.util ReflectionUtils USER_DECLARED_METHODS.
Click Source Link
From source file:org.craftercms.commons.ebus.config.EBusBeanAutoConfiguration.java
private static Set<Method> findHandlerMethods(final Class<?> handlerType, final ReflectionUtils.MethodFilter listenerMethodFilter) { final Set<Method> handlerMethods = new LinkedHashSet<Method>(); if (handlerType == null) { return handlerMethods; }// w w w .j a va 2 s . c o m Set<Class<?>> handlerTypes = new LinkedHashSet<Class<?>>(); Class<?> specifiedHandlerType = null; if (!Proxy.isProxyClass(handlerType)) { handlerTypes.add(handlerType); specifiedHandlerType = handlerType; } handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces())); for (Class<?> currentHandlerType : handlerTypes) { final Class<?> targetClass = (specifiedHandlerType != null ? specifiedHandlerType : currentHandlerType); ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() { @Override public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException { Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass); Method bridgeMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); if (listenerMethodFilter.matches(specificMethod) && (bridgeMethod == specificMethod || !listenerMethodFilter.matches(bridgeMethod))) { handlerMethods.add(specificMethod); } } }, ReflectionUtils.USER_DECLARED_METHODS); } return handlerMethods; }
From source file:org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.java
@Override public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException { Class<?> targetClass = AopUtils.getTargetClass(bean); Collection<RabbitListener> classLevelListeners = findListenerAnnotations(targetClass); final boolean hasClassLevelListeners = classLevelListeners.size() > 0; final List<Method> multiMethods = new ArrayList<Method>(); ReflectionUtils.doWithMethods(targetClass, method -> { for (RabbitListener rabbitListener : findListenerAnnotations(method)) { processAmqpListener(rabbitListener, method, bean, beanName); }// w w w . j av a 2s. c o m if (hasClassLevelListeners) { RabbitHandler rabbitHandler = AnnotationUtils.findAnnotation(method, RabbitHandler.class); if (rabbitHandler != null) { multiMethods.add(method); } } }, ReflectionUtils.USER_DECLARED_METHODS); if (hasClassLevelListeners) { processMultiMethodListeners(classLevelListeners, multiMethods, bean, beanName); } return bean; }
From source file:org.springframework.cloud.stream.reactive.StreamEmitterAnnotationBeanPostProcessor.java
@Override public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException { Class<?> targetClass = AopUtils.getTargetClass(bean); ReflectionUtils.doWithMethods(targetClass, method -> { if (AnnotatedElementUtils.isAnnotated(method, StreamEmitter.class)) { mappedStreamEmitterMethods.add(bean, method); }/*from ww w. j a va2 s. co m*/ }, ReflectionUtils.USER_DECLARED_METHODS); return bean; }