org.springframework.batch.core.listener

## Class AbstractListenerFactoryBean<T>

- java.lang.Object
- - org.springframework.batch.core.listener.AbstractListenerFactoryBean<T>

- All Implemented Interfaces:
    org.springframework.beans.factory.FactoryBean<java.lang.Object>, org.springframework.beans.factory.InitializingBean
  Direct Known Subclasses:
    JobListenerFactoryBean, StepListenerFactoryBean

      public abstract class AbstractListenerFactoryBean<T>
      extends java.lang.Object
      implements org.springframework.beans.factory.FactoryBean<java.lang.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.
  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`

- - ### Field Summary

    - ### Fields inherited from interface org.springframework.beans.factory.FactoryBean

      `OBJECT_TYPE_ATTRIBUTE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractListenerFactoryBean()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()`
    `protected abstract java.lang.Class<?>` | `getDefaultListenerClass()`
    `protected abstract ListenerMetaData` | `getMetaDataFromPropertyName(java.lang.String propertyName)`
    `protected abstract ListenerMetaData[]` | `getMetaDataValues()`
    `protected MethodInvoker` | `getMethodInvokerByName(java.lang.String methodName, java.lang.Object candidate, java.lang.Class<?>... params)`
    `java.lang.Object` | `getObject()`
    `static boolean` | `isListener(java.lang.Object target, java.lang.Class<?> listenerType, ListenerMetaData[] metaDataValues)` Convenience method to check whether the given object is or can be made into a listener.
    `boolean` | `isSingleton()`
    `void` | `setDelegate(java.lang.Object delegate)`
    `void` | `setMetaDataMap(java.util.Map<java.lang.String,java.lang.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 java.lang.Object getObject()

      Specified by:
        `getObject` in interface `org.springframework.beans.factory.FactoryBean<java.lang.Object>`

    - #### getMetaDataFromPropertyName

          protected abstract ListenerMetaData getMetaDataFromPropertyName(java.lang.String propertyName)

    - #### getMetaDataValues

          protected abstract ListenerMetaData[] getMetaDataValues()

    - #### getDefaultListenerClass

          protected abstract java.lang.Class<?> getDefaultListenerClass()

    - #### getMethodInvokerByName

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

    - #### isSingleton

          public boolean isSingleton()

      Specified by:
        `isSingleton` in interface `org.springframework.beans.factory.FactoryBean<java.lang.Object>`

    - #### setDelegate

          public void setDelegate(java.lang.Object delegate)

    - #### setMetaDataMap

          public void setMetaDataMap(java.util.Map<java.lang.String,java.lang.String> metaDataMap)

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Throws:
        `java.lang.Exception`

    - #### isListener

          public static boolean isListener(java.lang.Object target,
                                           java.lang.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
        `listenerType` - the class of the listener.
        `metaDataValues` - array of `ListenerMetaData`.
      Returns:
        true if the delegate is an instance of any of the listener interface, or contains the marker annotations