org.springframework.batch.item.adapter
Class AbstractMethodInvokingDelegator

java.lang.Object
  extended by org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
ItemReaderAdapter, ItemWriterAdapter, PropertyExtractingDelegatingItemWriter, TaskletAdapter

public class AbstractMethodInvokingDelegator
extends Object
implements InitializingBean

Superclass for delegating classes which dynamically call a custom method of injected object. Provides convenient API for dynamic method invocation shielding subclasses from low-level details and exception handling.

Author:
Robert Kasanicky

Constructor Summary
AbstractMethodInvokingDelegator()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  Object invokeDelegateMethod()
          Invoker the target method with no arguments.
protected  Object invokeDelegateMethodWithArgument(Object object)
          Invokes the target method with given argument.
protected  Object invokeDelegateMethodWithArguments(Object[] args)
          Invokes the target method with given arguments.
 void setArguments(Object[] arguments)
           
 void setTargetMethod(String targetMethod)
           
 void setTargetObject(Object targetObject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMethodInvokingDelegator

public AbstractMethodInvokingDelegator()
Method Detail

invokeDelegateMethod

protected Object invokeDelegateMethod()
Invoker the target method with no arguments.

Returns:
object returned by invoked method
Throws:
DynamicMethodInvocationException - if the MethodInvoker used throws exception

invokeDelegateMethodWithArgument

protected Object invokeDelegateMethodWithArgument(Object object)
Invokes the target method with given argument.

Parameters:
object - argument for the target method
Returns:
object returned by target method
Throws:
DynamicMethodInvocationException - if the MethodInvoker used throws exception

invokeDelegateMethodWithArguments

protected Object invokeDelegateMethodWithArguments(Object[] args)
Invokes the target method with given arguments.

Parameters:
args - arguments for the invoked method
Returns:
object returned by invoked method
Throws:
DynamicMethodInvocationException - if the MethodInvoker used throws exception

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

setTargetObject

public void setTargetObject(Object targetObject)
Parameters:
targetObject - the delegate - bean id can be used to set this value in Spring configuration

setTargetMethod

public void setTargetMethod(String targetMethod)
Parameters:
targetMethod - name of the method to be invoked on setTargetObject(Object).

setArguments

public void setArguments(Object[] arguments)
Parameters:
arguments - arguments values for the {setTargetMethod(String). These are not expected to change during the lifetime of the delegator and will be used only when the subclass tries to invoke the target method without providing explicit argument values.


Copyright © 2009 SpringSource. All Rights Reserved.