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
ListenerMetaData
value in the metaDataMap.
- Since:
- 2.0
- Author:
- Lucas Ward, Dan Garrette
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected abstract Class<?>
protected abstract ListenerMetaData
getMetaDataFromPropertyName
(String propertyName) protected abstract ListenerMetaData[]
protected MethodInvoker
getMethodInvokerByName
(String methodName, Object candidate, Class<?>... params) 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.boolean
void
setDelegate
(Object delegate) void
setMetaDataMap
(Map<String, String> metaDataMap) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.FactoryBean
getObjectType
-
Constructor Details
-
AbstractListenerFactoryBean
public AbstractListenerFactoryBean()
-
-
Method Details
-
getObject
- Specified by:
getObject
in 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:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<T>
-
setDelegate
-
setMetaDataMap
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in 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
-