Announcement Announcement Module
Collapse
No announcement yet.
? Setup an external bean with arguments Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ? Setup an external bean with arguments

    (Sorry, i can not speak english)

    I would like to setup an external bean. The external bean provides an init-method with arguments

    bean.init(Properties properties)

    How can I do that with spring without java coding?

    <bean id="externalBean" class="com.external.bean">
    <please-class-method method-name="init">
    <props>
    ...
    </props>
    </please-class-method>
    </bean>

    Thanks
    Torsten

  • #2
    Is there any chance you can try and explain what your are after. You want to call a method called init(Properties) when Spring creates the bean?

    Comment


    • #3
      How about writing a custom BeanFactory with an initProperties setter?

      Comment


      • #4
        You could trying something like this:
        Code:
            <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
                <property name="targetObject" ref="obj"/>
                <property name="targetMethod" value="init"/>
                <property name="arguments">
                    <list>
                        <props>
                            <prop key="key1">Value1</prop>
                            <prop key="key2">Value2</prop>
                            <prop key="key3">Value3</prop>
                            <prop key="key4">Value4</prop>
                        </props>
                    </list>
                </property>
            </bean>
        Look at the JavaDoc for MethodInvokingFactoryBean for more details.

        Comment

        Working...
        X