File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes ejbRemove - invoked on local call? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejbRemove - invoked on local call?" Watch "ejbRemove - invoked on local call?" New topic
Author

ejbRemove - invoked on local call?

Johann Evans
Ranch Hand

Joined: Nov 18, 2002
Posts: 47
The EJB spec mentions:

The container invokes the ejbRemove method on an entity bean instance with container-managed persistence in response to a client-invoked remove operation on the entity bean�s remote home or remote interface.

So that means only when using a remote interface, ejbRemove should be invoked - this seems a bit silly though - I am using a local interface using a controller facade - I need the entity bean to perform checks on ejbRemove i.e. referential integrity, but it is not invoked when remove() is called from a local interface? Is this a gap in the EJB spec or am I missing something here?
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Check the API doc, there are remove methods declared in the local interfaces as well.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Johann Evans
Ranch Hand

Joined: Nov 18, 2002
Posts: 47
Thanks, but the problem lies with the EntityBean ejbRemove() - this is almost like an event, that is fired when a client calls the remove method - now calling the remove from a remote interface will invoke ejbRemove, but calling the local interface remove does not invoke ejbRemove and I believe this is why the spec states "remote" interface.

I suppose the best place to encapsulate "pre-delete" behaviour is ejbRemove, but the container does not invoke it when remove() using a local interface?
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Originally posted by Johann Evans:
The EJB spec mentions:
The container invokes the ejbRemove method on an entity bean instance with container-managed persistence in response to a client-invoked remove operation on the entity bean�s remote home or remote interface.


The above statement is present in section 14.1.3, and section 14 is titled "EJB 1.1 Entity beans with container-managed persistence". That's probably why only the remote interfaces are mentioned.

I searched in the specs but could not find anything. So still have no answer to your question. Its strange, I (or most people for that matter) would expect the same behaviour for local beans, but then you are saying it is not happening. Hope someone has an explanation. By the way, which application server are you using?

- Sheldon Fernandes
Johann Evans
Ranch Hand

Joined: Nov 18, 2002
Posts: 47
Using JBoss

I've tried to search for similar behaviour, but it seems this is a general problem across application servers.

I'm pretty sure one should implement pre-delete behaviour in ejbRemove i.e. checking dependencies and being able to throw an Exception to abort the remove..
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
It would make no sense at all for remove to be invoked only by a remote client. The EJB 2.0 spec says:

10.7.8 Entity EJBLocalObject class
The entity EJBLocalObject class, which is generated by deployment tools, implements the entity bean�s local interface. It implements the methods of the javax.ejb.EJBLocalObject interface and the local business methods specific to the entity bean. The implementation of the remove() method (defined in the javax.ejb.EJBLocalObject interface) must activate an instance (if an instance is not already in the ready state) and invoke the
ejbRemove method on the instance.

The implementation of each local business method must activate an instance (if an instance is not already in the ready state) and invoke the matching business method on the instance.
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Roger that
Johann Evans
Ranch Hand

Joined: Nov 18, 2002
Posts: 47
Thanks guys - I'm going to setup a test case and forward it to JBoss to see if this issue is internal...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbRemove - invoked on local call?