0

Below is my ItemProcessor bean, I am implementing ItemProcessor interface. It works fine but

<beans:bean id="myItemProcessor"
        class="com.st.foundation.MyItemProcessor"
        p:id="#{jobParameters[date]}" p:type="my-type"
        scope="step" />

I want to combine many such beans in to single pojo and use an ItemProcessorAdapter.

<beans:bean id="myItemProcessor"
    class="org.springframework.batch.item.adapter.ItemProcessorAdapter"
    p:targetObject-ref="myObject" p:targetMethod="myMethod"
    p:arguments="{jobParameters[date]}"  scope="step" />

But my targetMethod has multiple arguments (type argument along with id). How can I pass multiple arguments to the adapter as it has only p:arguments parameter ?

I tried separating arguments by comma but it doesn't work. Getting error "target class must declare a method with matching name and parameter types".

Also I tried using

    <?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:file="http://www.springframework.org/schema/integration/file"
    xmlns:integration="http://www.springframework.org/schema/integration"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd 
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <util:list id="myList" value-type="java.lang.String">
        <value>foo</value>
        <value>bar</value>
    </util:list>

from this How to define a List bean in Spring?

But I am getting "cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'value'."

Community
  • 1
  • 1
vishal
  • 3,993
  • 14
  • 59
  • 102

2 Answers2

1

AbstractMethodInvokingDelegator.setArguments() accepts an array of Object as parameter; values of this array are used as parameterS so:

Try separating values by comma

"p:arguments="{jobParameters[date]},param2,param3"

or without p namespace facilities:

<property name="arguments">
  <list>
    <value>{jobParameters[date]}</value>
    <value>param2</value>
    <value>param3</value>
  </list>
</property>
Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
0

This worked for me,

<util:list id="myList" value-type="java.lang.String"
    scope="step">
    <beans:value>value1</beans:value>
    <beans:value>value2</beans:value>
</util:list>
vishal
  • 3,993
  • 14
  • 59
  • 102