• 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

ejbRemove () while passivated

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In ejbcertificate.com, I read that the container synchronizes the instance's state before it invokes the ejbRemove() method. So that means if the bean is passivated... then the container has to call
ejbActivate()->ejbLoad() and then ejbRemove().
I can't understand why the container has to go thru these process for JUST deleting the entity!!!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the bean is passivated and a timeout occurs the server will not call the ejbRemove (just kill the bean).
If the client calls remove() the server acts in the same way as the client would call another method on the bean, he will call ejbActivate (to serve the client request) and then call the ejbRemove().....
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx peter for your reply.

Well I'm not talking about time out here. Say, the client is calling a remove() and the bean is in passivated state. What happens then ???

I can understand that we need to call ejbActivate to bring the bean out of the pool. But why this ejbLoad(), container doing all these work , JUSt to delete the entity !!!

 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter, Giju is talking about entity beans for which there is no timeout stuff as for stateful session beans

Giju, the behavior you describe is required by the spec (see section 10.5.3):


The container synchronizes the instance�s state before it invokes the ejbRemove method. This means that the persistent state of the instance at the beginning of the ejbRemove method is the same as it would be at the beginning of a business method (i.e., if the instance is not already synchronized from the state in the database, the container must invoke ejbLoad before it invokes ejbRemove).



The ejbRemove method can only be called when the entity bean is in the READY state. If the entity bean has been passivated it first needs to be reactivated (ejbActivate) and synchronized (ejbLoad) before being removed. I think you understand that but you don't see why ejbLoad has to be called if the bean will be removed anyway... Well, you have to see ejbRemove as just another business method which requires that the entity bean fully reflect the current state of the database. The container doesn't make any difference between a call to a business method and a call to the ejbRemove method when an entity bean is pooled and has to be readied again. The bottom line is that ejbLoad is always called directly after ejbActivate has been called. I have verified this information with BEA Weblogic 7 application server implementation, but I think other servers are behaving the same way

I hope this answers your question.
 
Peter Wiederkehr
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Peter, Giju is talking about entity beans for which there is no timeout stuff as for stateful session beans

Well of course you are right (I've read over the ejbLoad :roll: ) but the answer is nearly the same, the server doesn't know (care) which method is called and so calls ejbActivate and then ejbRemove (for statefull session and for entity beans).
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right, but Giju's main issue was the ejbLoad being called before ejbRemove, I guess...

No big deal
 
Peter Wiederkehr
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Valentin Crettaz with 6330 posts you should be able to answer my question
at
https://coderanch.com/t/159556/java-EJB-SCBCD/certification/getEJBObject-ejbCreate-stateless-session-bean

 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx guys for your replies.

The reply that Valentin explains makes sense -- "when the spec says that the container treats the ejbremove() method as any other business method"

But what i feel is, this is totally unnecessary - to do all these work (ejbActivate+ejbLoad()) just to delete the entity from the database.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Peter Wiederkehr:
@Valentin Crettaz with 6330 posts you should be able to answer my question
at
https://coderanch.com/t/159556/java-EJB-SCBCD/certification/getEJBObject-ejbCreate-stateless-session-bean



Working on it
 
Peter Wiederkehr
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:


Working on it



You will get

if you can answer my question (but you have to come to zurich )
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[hijack]
We had a javaranch get-together in Bern last Sunday. If you had posted one week sooner, you would have been able to participate
[/hijack]
 
reply
    Bookmark Topic Watch Topic
  • New Topic