Hi All, What happens to EJBObject related to an entity bean when that entity bean is moved to pool. If EJBObject is destroyed, then how can a container finds an EJBObject when finder methods are invoked by clients?
Well, don't forget that bean instances are assigned to EJB objects.
A bean can move from the Ready State to the Pooled state via passivation or removal. Bean instances remain inactive in the Pooled state, until they are assigned to an EJB object.
When the bean instance returns to the pool, the EJB object is left without an instance to delegate client requests to. When the client invokes a business method on the EJB object, the EJB object must obtain a new bean instance. This is accomplished by activating a bean instance.
Hi KRK, 1. By two ways, an entity bean move from "method ready" state to "pooled" state --- ejbPassivate() and ejbRemove() (same as Celinio said).
For ejbPassivate(), the EJBObject will be stay there for the next business method call (at least we can make this assumption based on the "conceptual architecture" -- head first EJB);
For ejbRemove(), the EJBObject will be removed or be not valid, if I call the stub to this EJBObject, I will get a NoSuchObjectException exception.
2. The invocation of finder methods goes through EJBHomeObject not EJBObject (same as Awishek said)
3. The entity bean in the pool is still active, because it can do "finder" methods, and Home Business Methods.
posted 12 years ago
Hi All, Thanks for the responses. Awishek caught partially what i meant to say. When clients invoke finder methods, a bean instance in the pool will query database for the existence of the primary key in the database. If found, then container will find (or makes) EJBObject and send its stub to client. This is how flow for finder method goes right. Now, at the point
If found, then container will find (or makes) EJBObject and send its stub to client.
I am confused. How container finds an EJBOject which is related to the primary key? If a EJBObject is alive, then bean instance acting as entity bean for that primary key must be active and in method ready state. All i want to know is how the container service will find one? Please correct and excuse me if i am wrong.
Thanks and Regards
posted 12 years ago
I am confused. How container finds an EJBOject which is related to the primary key? If a EJBObject is alive, then bean instance acting as entity bean for that primary key must be active and in method ready state. All i want to know is how the container service will find one?
Any EJBObject for a bean type is capable to represent an entity its depend from vendor to vendor it might to chose to create a pool of EJBObject foe a bean type OR create a new EJBOject when required.
when the finder method(intended to find an entity) returns, it returns a primary key ,the container picks one EJBObject or creates one and assign this primary key to this EJBObject and returns the stub of this EJBObject to the remote client(at this time EJBObject is not actually pointing to the bean instance ,it just have the primary key of the entity)
Only when the client calls a business method on this currently returned EJBObject stub, the container pulls a bean instance from pool & assign the same primary key (assigned to the EJBObject to the Entity context of bean instance) which linked the EJBObject to the bean instance and this instance now represent the entity in database. Hope it clears your doubt..