org.springframework.batch.core.listener
Class AbstractListenerFactoryBean

java.lang.Object
  extended by org.springframework.batch.core.listener.AbstractListenerFactoryBean
All Implemented Interfaces:
FactoryBean, InitializingBean
Direct Known Subclasses:
JobListenerFactoryBean, StepListenerFactoryBean

public abstract class AbstractListenerFactoryBean
extends Object
implements FactoryBean, 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:

It should be noted that methods obtained by name or annotation that don't match the listener method signatures to which they belong will cause errors. However, it is acceptable to have no parameters at all. If the same method is marked in more than one way. (i.e. the method name is given and it is annotated) the method will only be called once. However, if the same class has multiple methods tied to a particular listener, each method will be called. Also note that the same annotations cannot be applied to two separate methods in a single class.

Since:
2.0
Author:
Lucas Ward, Dan Garrette
See Also:
ListenerMetaData

Nested Class Summary
protected static class AbstractListenerFactoryBean.NullIgnoringSet<E>
           
 
Constructor Summary
AbstractListenerFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
protected abstract  Class<?> getDefaultListenerClass()
           
protected abstract  ListenerMetaData getMetaDataFromPropertyName(String propertyName)
           
protected abstract  ListenerMetaData[] getMetaDataValues()
           
protected  MethodInvoker getMethodInvokerByName(String methodName, Object candidate, Class<?>... params)
           
 Object getObject()
           
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 isSingleton()
           
 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 Detail

AbstractListenerFactoryBean

public AbstractListenerFactoryBean()
Method Detail

getObject

public Object getObject()
Specified by:
getObject in interface FactoryBean

getMetaDataFromPropertyName

protected abstract ListenerMetaData getMetaDataFromPropertyName(String propertyName)

getMetaDataValues

protected abstract ListenerMetaData[] getMetaDataValues()

getDefaultListenerClass

protected abstract Class<?> getDefaultListenerClass()

getMethodInvokerByName

protected MethodInvoker getMethodInvokerByName(String methodName,
                                               Object candidate,
                                               Class<?>... params)

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean

setDelegate

public void setDelegate(Object delegate)

setMetaDataMap

public void setMetaDataMap(Map<String,String> metaDataMap)

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface 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 check
Returns:
true if the delegate is an instance of any of the listener interface, or contains the marker annotations


Copyright © 2009 SpringSource. All Rights Reserved.