Announcement Announcement Module
No announcement yet.
HippyMethodInvoker too relaxed? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • HippyMethodInvoker too relaxed?

    Hi, I'm trying out the PropertyExtractingDelegatingItemWriter, and I'm seeing that if the arguments are not of the exact types as the targetMethod, then HippyMethodInvoker#findMatchingMethod is called.

    When finding candidate arguments, the findMatchingMethod method will populate all fields with the first possible match.

    The following is the sample I'm using:

    <bean id="adaptedItemWriter" class="org.springframework.batch.item.adapter.PropertyExtractingDelegatingItemWriter">
        <property name="targetObject" ref="myWriter" />
        <property name="targetMethod" value="doIt" />
        <property name="fieldsUsedAsTargetMethodArguments">
    <bean id="myWriter" class="com.mycom.writers.MyWriter"/>
    The item being passed has three properties: firstName, lastName, and network. All are Strings. In order to make MyWriter more reusable, I had the doIt(...) method use Object for one of the parameters:

    public class MyWriter {
    	public void doIt(String a, String b, Object c) {
    		System.out.println(a + ", " + b + ", and " + c); 
    If the "c" argument is a String, then the output is as expected (i.e., firstName, lastName and network are printed out). When "c" is an Object, then HippyMethodInvoker tries to find a method and selects candidate arguments. All three candidate arguments are the first value passed in (i.e., the result is firstName, firstName and firstName printed out).

    Any ideas on how to use more generic argument types?

  • #2
    You could raise a JIRA ticket to get this looked at in more detail. For now I suspect you will have to write your own delegating writer and use a less subtle approach to calling your specific method.