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

Doubt on EJBObject

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?


Thanks and Regards
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gowda
EJBObject is destroyed & invocation of finder methods does not require EJBObject it is invoked on EJBHomeObject .
Thanks
 
Ranch Hand
Posts: 563
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Awishek sinha
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gowda


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..
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That clears my confusion.

Thanks and Regards
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic