Hello guys!
I have few questions on Stateful Session Bean, I would be very thankful if somebody will help me out. Thanks!
Let's imagine that we have SFSB (Stateful Session Bean).
To access it we get his Home reference, then EJBObject reference.
Technically and practically we can then serialize it. Two ways for that.
First, we use getHandle() method of
EJBObject interface to get serializable handler (because EJBObject is a stub, right) and then we serialize it. To de-serialize we do that and get Handler object, then we call getEJBObject() of
Handle interface to get our actual EJBObject reference.
Second, we can just simply use
HandleDelegate and it's methods which operate directly with EJBLocalObject and EJBObject.
We can then save serialized data into file or may be into field of database.
I believe I do not have mistakes till this point.
Now my questions.
#1 Once serialized and stored into file or database field client will exit. Will Application Server still keep SFSB alive? Will Application Server know that there is an active (is it considered to be an active?) reference to it? Will it maintain SFSB state? Or serialization into file/field of database is not considered to be an active reference? So is the only way out to put everything only into HttpSession?
#2 If still Application Server is going to keep SFSB and maintain it's state, so how long it will last? There could be a situation when client will never return, or will return in a week. Is there a possibility to limit SFSB and it's state maintaince for an Application Server for some period of time? Somehow? How? And what will happen if Application Server will restart? Will all SFSBs return back alive and with their old states?
#3 Let's imagine that everything works. But we have the following structure. One client (servlet it will be) will start interaction with SFSB, then will save a reference into file or field of database. Exit. And then other client (Swing application) will load reference from file or field of database and will want to work with the same SFSB with already created state (done before). Will this be possible? Or SFSB needs to same client? How SFSB understands something about it's client (same/not?)? What if it's a different servlet? Or the same servlet, but other (new) instance of it? Etc.?
Thank you very much for any help! I really need to find answers to these questions!
---
Panda Mima, pandamima@goowy.com