Pass parameters to Spring MethodInvokingFactoryBean arguments list

I am trying to find the way to pass objects to Spring MethodInvokingFactoryBean arguments list. Here is my Spring configuration:

<bean id="qName" class="javax.xml.namespace.QName">
    <constructor-arg index="0" value="${com.groupgti.esb.online.tests.talentq.tns}"/>
    <constructor-arg index="1" value="${com.groupgti.esb.online.tests.talentq.serviceName}"/>
</bean>

<bean id="wsdlUrl" class="java.net.URL">
    <constructor-arg index="0" value="${com.groupgti.esb.online.tests.talentq.url}"/>
</bean>

<bean id="service" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject">
        <bean id="serviceObject" class="com.groupgti.onlinetest.talentq.jaxb.TQIntegrationV2"/>
    </property>
    <property name="targetMethod">
        <value>create</value>
    </property>
    <property name="arguments">
        <list>
            <value type="java.net.URL">wsdlUrl</value>
            <value type="javax.xml.namespace.QName">qName</value>
        </list>
    </property>
</bean>

This is not working:

<value type="java.net.URL">wsdlUrl</value>
<value type="javax.xml.namespace.QName">qName</value>

I am getting the exception:

Caused by: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.net.URL'; nested exception is java.lang.IllegalArgumentException: Could not retrieve URL for OSGi resource[wsdlUrl|bnd.id=573|bnd.sym=com.groupgti.esb.online.tests.talentq]: OSGi resource[wsdlUrl|bnd.id=573|bnd.sym=com.groupgti.esb.online.tests.talentq] cannot be resolved to URL because it does not exist

This is because parameter is passed as String, just wsdlUrl and not as an java.net.URL object.

I have also tried this:

<property name="arguments">
    <ref bean="wsdlUrl"/>
    <ref bean="qName"/>
</property>

This gives me an exception that ref attribute does not belong here. So how then should I pass an object to arguments list?

Answers


Found a solution. I had to add <list> and then declare <ref>:

<property name="arguments">
    <list>
        <ref bean="wsdlUrl"/>
        <ref bean="qName"/>
    </list>
</property>

Like this, everything is working.


Need Your Help

Lastest Foursquare check-in on map

php javascript jquery foursquare

I would like to display a map on my website that shows my last Foursquare check-in.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.