Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

stateful session bean

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic