posted 15 years ago
All,
I have a requirement where two business classes should share the same value object. And these two business classes should be instantiated one per request and value object is common for both these.
<bean id="bus1" class="com.foo.Business1" scope="prototype">
<property name="account" ref="acct"/>
</bean>
<bean id="bus2" class="com.foo.Business2" scope="prototype">
<property name="account" ref="acct"/>
</bean>
<bean name="acct" class="com.foo.Account" scope="singleton">
</bean>
I need this acct to be singleton for bus1 and bus2 instances and not for entire IOC container. In this way, when a user logs on, bus1 and bus2 will share the same acct. And for another user, a different acct instance has to be created, but shared between bus1 and bus2.
Is this possible in Spring or should i do it programmatically?
Kindly help.
Regards,
venkat