• Post Reply Bookmark Topic Watch Topic
  • New Topic

stateful session bean

 
Sanny kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have a simple question ejb.in stateful session if a client is accessing the resource s and now client is idle for 5 mins.at this stage the instance will be stored in passivate method.now client want to access the resources(using activate).now will the client get the same instance or different instance?
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it depends, but it shouldn't really matter. I expect a new instance, since if it is passivated, then it is to clear out the object from memory, otherwise it could be a memory leak.

Mark
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of this situation.

I have some conversational state stored in the bean before it gets passivated.Lets consider a String reference.When passivated , the container has to take care of the String object , so that when it gets activated again its value should be restored.No matter what the container follows to do during passivation (As serialization is not guaranteed by the specification).I personally feel that are good chances that the container will use serialization and the same instance of bean is returned which is passivated.
[ May 02, 2007: Message edited by: Rahul Bhattacharjee ]
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally feel that are good chances that the container will use serialization and the same instance of bean is returned which is passivated.


Deserialization does not give the same instance that was serialized. It will create a new instance and copy the state (non-static non-transient member variable) of the serialized object in this instance.
As Mark said, it does not really matter whether it is the same instance or different, what matters is the state of the object.
[ May 02, 2007: Message edited by: Nitesh Kant ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad language , I too meant the same thing as during serialization only the information which is required to reconstruct a object in the heap is saved or taken care , so that during deserialization a equivalent object could be created.

I better take care of my language.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!