Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbRemove - invoked on local call?

 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API doc, there are remove methods declared in the local interfaces as well.
 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roger that
 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys - I'm going to setup a test case and forward it to JBoss to see if this issue is internal...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic