Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface for Destroy method in EJB

 
ramya ray
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Interface is used to destroy the instance of EJB bean :
1. Home Interface
2. Remote Interface
or other than the 2 mentioned above.

Please reply,

Thanks
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at both EJBHome and EJBObject api you can see that both the interface removes the EJB instance. From home interface you remove the instance by passing the handle of the EJB instance. One difference you need to know is both these interface cannot remove the stateless bean.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Client has access to only those interface you mentioned by its implemented classes. Using those he can do some action on bean and remove() method is from only from EJBHome and EJBObject,EJBLocalHome and EJBLocalObject interfaces.

So, client can only call remove() from Home and Component Interface. One more way bean can be removed is, if System Exception or Uncaught exception is thrown.


hth,
 
ramya ray
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so both EJBHome and EJBRemote interface can be used to remove EJB instance ?

Please confirm.

Thanks,
 
Mani vannan
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Needless to say, you have to invoke remove() on EJBObject (or EJBLocalObject) interface.
But, the consequence is,
1. The actual bean is removed if its stateful bean
2. The acutal bean is sent to pool, if its a stateless bean.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic