aspose file tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Diffrence between @EJB and  SessionContext.getBusinessObject(InterfaceName.class) ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Diffrence between @EJB and  SessionContext.getBusinessObject(InterfaceName.class) ?" Watch "Diffrence between @EJB and  SessionContext.getBusinessObject(InterfaceName.class) ?" New topic
Author

Diffrence between @EJB and SessionContext.getBusinessObject(InterfaceName.class) ?

rutuparna lastname
Greenhorn

Joined: Aug 01, 2009
Posts: 4
May I know which to use when ?
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 1986
    
  39

Hi Rutuparna

@EJB is used to inject an EJB in your (client) code.

SessionContext.getBusinessObject(InterfaceName.class) is used to get a reference to "your own" EJB (and pass it for instance to another EJB), as you can't use the "this" keyword.

Regards,
Frits
 
Don't get me started about those stupid light bulbs.
 
subject: Diffrence between @EJB and SessionContext.getBusinessObject(InterfaceName.class) ?