Announcement Announcement Module
Collapse
No announcement yet.
one object instance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • one object instance

    i have a bean that takes several beans as consrtuctor arguments:

    <bean id="MyBean" class="MyBeanClass" singleton="false">
    <constructor-arg><ref bean="Bean1"/></constructor-arg>
    <constructor-arg><ref bean="Bean2"/></constructor-arg>
    <constructor-arg><ref bean="Bean3"/></constructor-arg>
    </bean>

    and for some reasons i need to make it possible to pass one object instance in place of some or all of this arguments. but this object can't be singltone. something like this:

    <bean id="MyBean" class="MyBeanClass" singleton="false">
    <constructor-arg><ref bean="CommonBean"/></constructor-arg>
    <constructor-arg><ref bean="CommonBean"/></constructor-arg>
    <constructor-arg><ref bean="CommonBean"/></constructor-arg>
    </bean>
    <bean id="CommonBean" class="CommonBeanClass" singleton="false"/>

    where all constructor arguments must refer to one instance of CommonBean.

    anyone have an idea how can i do this?

    ps sorry for poor english, it's not my native tongue =)

  • #2
    You could inherit the class, write a constructor with just one param and from there invoke the super constructor with 3 params, using the same object.

    Comment

    Working...
    X