objects lifetime configuration like in JSF

Topics: Web Client Software Factory
Aug 22, 2007 at 7:52 AM
Hi, is there something similar configurable objects in Object Builder, where I could declare like it is done in JSF (jes this is Java Server Faces)

<managed-bean>
<managed-bean-name>userInfo</managed-bean-name>
<managed-bean-class>DemoApp.UserInfo</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope><!-- also available request and application scope-->
<managed-property>
<property-name>service</property-name>
<value>#{depenentlyInjectedObject}</value>
</managed-property>
</managed-bean>

In this case this class will automatically persisted in session scope with a "userInfo" key, also in this class is propety named by service, witch will be injected on object creation.

The beauty of this is that actually there is one place you configure objects life-time and in code you need to call
DemoApp.UserInfo obj=ObjectFactory.GetObject<DemoApp.UserInfo>("userInfo"); //and this comes from session if the managed-bean-scope would be request, this object would last only one request and you would get a new instance.


Aug 22, 2007 at 8:07 AM
Ok I know that there is SpringFramework.NET for this case, but I would'nt want to add too many frameworks in my app.