aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejbRemove () while passivated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ejbRemove () while passivated" Watch "ejbRemove () while passivated" New topic
Author

ejbRemove () while passivated

Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
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!!!


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCEA
Peter Wiederkehr
Greenhorn

Joined: Jul 15, 2004
Posts: 14
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().....


SCJP 1.4<br />SCBCD 1.3
Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
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 !!!

Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Peter Wiederkehr
Greenhorn

Joined: Jul 15, 2004
Posts: 14
>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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Right, but Giju's main issue was the ejbLoad being called before ejbRemove, I guess...

No big deal
Peter Wiederkehr
Greenhorn

Joined: Jul 15, 2004
Posts: 14
@Valentin Crettaz with 6330 posts you should be able to answer my question
at
http://www.coderanch.com/t/159556/java-EJB-SCBCD/certification/getEJBObject-ejbCreate-stateless-session-bean

Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Originally posted by Peter Wiederkehr:
@Valentin Crettaz with 6330 posts you should be able to answer my question
at
http://www.coderanch.com/t/159556/java-EJB-SCBCD/certification/getEJBObject-ejbCreate-stateless-session-bean



Working on it
Peter Wiederkehr
Greenhorn

Joined: Jul 15, 2004
Posts: 14
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
[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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbRemove () while passivated