IntelliJ Java IDE
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes stateful beans Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Architect Certification (SCEA/OCMJEA)
Reply Bookmark "stateful beans" Watch "stateful beans" New topic
Author

stateful beans

k doshi
Ranch Hand

Joined: Mar 16, 2002
Posts: 41
in a stateful bean ---the container doesn't create a pool. The bean is dedicated to the EJBObject for its entire life(probably why a pool is not created)
But when the bean is passivated the bean is destroyed, and when activated a new bean is created and assigned to the EJBObject.
So why isn't a pool created from which during activation a bean is assigned to the EJBObject instead of creating a new one.
Nicky Moelholm
Ranch Hand

Joined: Jan 20, 2002
Posts: 43

in a stateful bean ---the container doesn't create a pool. The bean is dedicated to the EJBObject for its entire life(probably why a pool is not created)
But when the bean is passivated the bean is destroyed, and when activated a new bean is created and assigned to the EJBObject.
So why isn't a pool created from which during activation a bean is assigned to the EJBObject instead of creating a new one.

Some vendors do choose to implement pooling in the scenario you describe. When people say stateful session beans are not pooled, they are referring to the logical concept (one stateful ejb for one client, do not get pooled).


Nicky Moelholm
MyCerts: SCJP 1.2, SCJP 1.5, SCJD, SCWCD 1.3, SCBCD 1.3, SCDJWS 1.4, SCEA, IBM 253
MyBooks: IBM WebSphere Application Server V7.0 Web Services Guide
k doshi
Ranch Hand

Joined: Mar 16, 2002
Posts: 41
yes i agree, but i dont understand why in the logical concept also they have differentiated it that way
thks
kiran
Shankar Ranganathan
Ranch Hand

Joined: Sep 19, 2001
Posts: 71
Hi Doshi,
Pooling is mainly done to improve the scalability by having a small number of instances servicing many clients.This is true with Stateless and entity beans. The reason that it is not possible with stateful session bean because the bean instance is saved relative to the ejbobject, but it is not like that in entity and stateless session beans. That is why they are put back in the pool and stateful session can't be pooled back or not reusable.
Rgds
Shankar


Shankar<br />Post mock questions in<br /><a href="http://groups.yahoo.com/group/scea_mock" target="_blank" rel="nofollow">http://groups.yahoo.com/group/scea_mock</a>
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
If that is the case then why would you passivate and then activate again? Once you passivate and serialize all the data, what happens to the bean instance?
I would think that by passivating, we reduce "in memory" data. Is this right?


ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
Shankar Ranganathan
Ranch Hand

Joined: Sep 19, 2001
Posts: 71
Hi Chintan,
I was talking about why we are not pooling stateful session bean.
The bean instance is saved in the filesystem but not disassociated from the ejbobject as in the case of entity and stateless and entity beans.In other word the ejbobject is always tied up with the bean instance in the case of stateful session bean.That is why we are not able reuse that bean instance for a different client which is possible with stateless and entity.Hope this makes sense.
Rgds
Shankar
Alexander Yanuar Koentjara
Ranch Hand

Joined: Jun 03, 2002
Posts: 31
The reason you cannot pool: the container never know about specific information stored in the bean. Imagine a bean like this:
class MyEJB ..... {
private int state = 0;
...
...
}
You can passivate this bean (to reduce RAM consumtion) and activate the bean (if client request it later), but there is no way you can reuse this bean for other client since the state of one client is different to the others. The container just doesn't have a way to modify the state.
Stateless bean won't have this problem since it should never store user-specific information in the bean itself, so it is safe for container to assume the bean is poolable.


===================================<br />Fear not, God know the best.<br />SCJP2 91%<br />SCWCD 89%<br />SCJD2 92% (143/155 pts)<br />SCEA Part I (89%)
 
 
subject: stateful beans
 
Threads others viewed
Pool for Stateless Session Beans ??
ejbCreate in stateful session bean
Architectural Overview(Stateful and Stateless Session beans)
getEJBObject in setSessionContext
EJBObject reference in stateless ejbCreate() ?
IntelliJ Java IDE