Two Laptop Bag
The moose likes EJB and other Java EE Technologies and the fly likes Storing Value Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Storing Value Object" Watch "Storing Value Object" New topic

Storing Value Object

Shashank Hiwarkar
Ranch Hand

Joined: Feb 17, 2002
Posts: 32
Dear Friends,
My Architecture requires that I should have a Web Container (Catalina) and Application Container(JBoss). To reduce the trafic across the container I am using the Value Objects.
Now conceptually this is Okay... but now can anybody help me.... where to store the Value Objects and who will manage the object lifecycle


Shashank Hiwarkar<br />SCJP, SCWCD
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Value objects are your transport objects. Typically you should not store them for long since they may get stale quickly. They are returned by methods on the business services layer and can be used by a View Helper to generate a presentation view.
Front end controllers and action classes can package Value Objects in the Httpsession.
[ May 13, 2003: Message edited by: Ajith Kallambella ]

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Since this is a general J2EE architectural topic, I am moving this discussion to EJB and Other J2EE technologies forum for the benefit of wider audience.
Brian Alexander Lee

Joined: Aug 15, 2001
Posts: 3
The Value Object pattern has been renamed "Transfer Object" by sun.
I think this new name makes its use easier to understand. The transfer object is used to transfer an ejb's data from one container to another efficiently.
The only objects storing the transfer objects would the the web container's objects (servlets, jsp, struts actions, whatever) and then they won't be storing them very long.
A good use is to have your entity or stateful ejb have a method that returns the entire transfer object (which has the name data as if you called each getter on your ejb). This is only one remote call that returns one serializable object instead of all those remote calls for each getter.
You can also have a setter that takes in a transfer object so there is only one remote call.
Small sample code:
Here's your transfer object
So your client would get an ejb and then call getTO to get all the data. They could display the data or modify it and send it back to the ejb with setTO.
I agree. Here's the link:
subject: Storing Value Object
It's not a secret anymore!