• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stateless & Stateful Session Bean

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
In Stateless session why do we need to implement ejbActivate(), and ejbPassivate() methods since its empty and doesnt maintain any state behalf of a client ?
In Statefull Session Bean how cotainer maintain a conversational state for a client ? can any one explain briefly how it does ?
how to identify a bean is a stateless or statefull programmatically instead of deployment descripter ?
thanks in advance
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Stateless session why do we need to implement ejbActivate(), and ejbPassivate() methods since its empty and doesnt maintain any state behalf of a client ?
Because, when you implement a session bean, your code doesn't care whether is stateless or stateful, you just implement the SessionBean interface when you write your bean.
Now, if you look at the SessionBean interface you see that these two methods are declared there, so you must implement them, even if you put nothing in them (for stateless session bean.
In Statefull Session Bean how cotainer maintain a conversational state for a client ? can any one explain briefly how it does ?
thru passivation and activation. your bean is tied to a particular client, and will maintain its state by using these two methods and storing your instance (serializable) variables in a persistent storage, to keep resources and to wait until the client requests another business method.
how to identify a bean is a stateless or statefull programmatically instead of deployment descripter ?
Did you mean that if you look at a bean code, how can you say whether it's statless or stateful?
hmm, stateless session beans have only a single ejbCreate() method, that takes no parameters. This is because stateless are *not* tied to any client.
Stateful session beans can have multiple overloaded ejbCreate() methods.
passivate/activate wouldn't do it, since you can put code in your stateless methods if you want, it just not going to be executed.
hope it helps
 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Andres. one more doubt.
how can a ejb container match a bean with a purticular client after ejbActivation() ? there could be many clients can access statefull session bean.
how does a ejb container identifies a purticular bean instance to purticular client ? pls give me in detail.
thanks.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While ejbPassivate() callback;
1. release all the resources like db connections, socket connections etc.
2. storing object state in secondary storage device like hard disk, db.
definately with client/session id.*****
while ejbActivate() callback;
1. restoring the released resources
2. setting state values to bean based on client/seesion id.
(container can set values(recreation of state) to any bean available in the pool (mostly least used) or can create new instance as per need.)
developer need not to vary about ejbActivate()/ejbPassivate(); unless you need to manage resources to release/restore.
And I beleive state management is duty of container.*****
Please correct me if I am missing something.
[ January 09, 2004: Message edited by: sanjeev mehra ]
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic