Class AbstractListenerFactoryBean<T>
java.lang.Object
org.springframework.batch.core.listener.AbstractListenerFactoryBean<T>
- All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<Object>,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
JobListenerFactoryBean,StepListenerFactoryBean
public abstract class AbstractListenerFactoryBean<T>
extends Object
implements org.springframework.beans.factory.FactoryBean<Object>, org.springframework.beans.factory.InitializingBean
FactoryBean implementation that builds a listener based on the various
lifecycle methods or annotations that are provided. There are three possible ways of
having a method called as part of a listener lifecycle:
- Interface implementation: By implementing any of the subclasses of a listener interface, methods on said interface will be called
- Annotations: Annotating a method will result in registration.
- String name of the method to be called, which is tied to a
ListenerMetaDatavalue in the metaDataMap.
- Since:
- 2.0
- Author:
- Lucas Ward, Dan Garrette, Taeik Lim
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected abstract Class<?>protected abstract ListenerMetaDatagetMetaDataFromPropertyName(String propertyName) protected abstract ListenerMetaData[]protected MethodInvokergetMethodInvokerByName(String methodName, Object candidate, Class<?>... params) static booleanisListener(Object target, Class<?> listenerType, ListenerMetaData[] metaDataValues) Convenience method to check whether the given object is or can be made into a listener.booleanvoidsetDelegate(Object delegate) voidsetMetaDataMap(Map<String, String> metaDataMap) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.FactoryBean
getObjectType
-
Constructor Details
-
AbstractListenerFactoryBean
public AbstractListenerFactoryBean()
-
-
Method Details
-
getObject
- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean<T>
-
getMetaDataFromPropertyName
-
getMetaDataValues
-
getDefaultListenerClass
-
getMethodInvokerByName
protected MethodInvoker getMethodInvokerByName(String methodName, Object candidate, Class<?>... params) -
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<T>
-
setDelegate
-
setMetaDataMap
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
isListener
public static boolean isListener(Object target, Class<?> listenerType, ListenerMetaData[] metaDataValues) Convenience method to check whether the given object is or can be made into a listener.- Parameters:
target- the object to checklistenerType- the class of the listener.metaDataValues- array ofListenerMetaData.- Returns:
- true if the delegate is an instance of any of the listener interface, or contains the marker annotations
-