Results 1 to 4 of 4

Thread: ? Setup an external bean with arguments

  1. #1

    Default ? 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. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    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?

  3. #3
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    9

    Default

    How about writing a custom BeanFactory with an initProperties setter?

  4. #4
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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.
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •