List of usage examples for org.springframework.batch.support MethodInvokerUtils getMethodInvokerByAnnotation
public static MethodInvoker getMethodInvokerByAnnotation(final Class<? extends Annotation> annotationType, final Object target)
From source file:org.springframework.batch.core.listener.AbstractListenerFactoryBean.java
/** * Convenience method to check whether the given object is or can be made * into a listener.//from w ww . j a v a 2s.co m * * @param target the object to check * @return true if the delegate is an instance of any of the listener * interface, or contains the marker annotations */ public static boolean isListener(Object target, Class<?> listenerType, ListenerMetaData[] metaDataValues) { if (target == null) { return false; } if (listenerType.isInstance(target)) { return true; } if (target instanceof Advised) { TargetSource targetSource = ((Advised) target).getTargetSource(); if (targetSource != null && targetSource.getTargetClass() != null && listenerType.isAssignableFrom(targetSource.getTargetClass())) { return true; } if (targetSource != null && targetSource.getTargetClass() != null && targetSource.getTargetClass().isInterface()) { logger.warn(String.format( "%s is an interface. The implementing class will not be queried for annotation based listener configurations. If using @StepScope on a @Bean method, be sure to return the implementing class so listener annotations can be used.", targetSource.getTargetClass().getName())); } } for (ListenerMetaData metaData : metaDataValues) { if (MethodInvokerUtils.getMethodInvokerByAnnotation(metaData.getAnnotation(), target) != null) { return true; } } return false; }