my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes Conversational state of stateful session 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 "Conversational state of stateful session" Watch "Conversational state of stateful session" New topic
Author

Conversational state of stateful session

Rashmi Tambe
Ranch Hand

Joined: Aug 07, 2001
Posts: 418
I have not understood following paragraph from ejb2.0 specs, section 7.4.1 :
The Bean Provider is required to ensure that the ejbPassivate method leaves the instance fields
ready to be serialized by the Container. The objects that are assigned to the instance’s non-transient
fields after the ejbPassivate method completes must be one of the following:
• A serializable object [2] .
• A null.
• An enterprise bean’s remote interface reference, even if the stub class is not serializable.
...
...
...so on

Can somebody please explain ???
or am i too dumb to understand !
[ September 01, 2003: Message edited by: Rashmi Tambe ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
That part says that as a bean provider you are expected to replace any references to non-serializable objects with serializable "handles". A handle in this context is an object that the bean's ejbActivate() method can use to restore any non-serializable references. For example, the bean could "trade" a JDBC connection reference into a connection URL (with which the bean can make another JDBC connection).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Rashmi Tambe
Ranch Hand

Joined: Aug 07, 2001
Posts: 418
thaks Lasse !
But tell me one thing, how would the container replace the null with serizable handle? In addition, what is the replacement for beans' home and remote interfaces?
[ September 01, 2003: Message edited by: Rashmi Tambe ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
how would the container replace the null with serizable handle?

Why would the container need to replace it with anything? When the container activates the bean and realizes it doesn't have the magical serialized state object for one of the fields, it leaves it as null. Simple as that. Another approach would be for the container to replace null's with some kind of NullObject reference. Any of these internals don't affect the bean developer -- null in, null out.
In addition, what is the replacement for beans' home and remote interfaces?

The references to EJBs are already serializable (it's the container generated classes you're using, not the one(s) you typed in). How the container implements this is, again, it's own business and the developer doesn't need to care about it. Probably (if I had to make a guess) the container uses the same EJB handle mechanism as is available to you as a developer...
Rashmi Tambe
Ranch Hand

Joined: Aug 07, 2001
Posts: 418
Thanks once again Lasse...
Now its pretty clear to me !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversational state of stateful session