aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt on interfaces for EJB 3 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 "Doubt on interfaces for EJB 3" Watch "Doubt on interfaces for EJB 3" New topic
Author

Doubt on interfaces for EJB 3

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9381
    
    2

Guys,

The following is from EJB 3 in Action,


If you want, you can apply the @Local, @Remote, or @WebService annotation in the
bean class without having to implement the business interface as follows:



My question here is with the @Remote annotation specified in the code above as it says that BidManager.class which is a POJI is the Remote interface for this session bean. So does this imply that when I write my client class (which is going to be a remote client), can I do a DI like this below,



OR do I have to do this,



Please help guys!
[ September 03, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Hi Jothi,

In the following code:



The BidManagerBean business remote interface is BidManager. There are no other business interfaces. So the proper way to get a reference to your bean will be to define:


You cannot use


BidManagerRemote is NOT a business interface of BidManagerBean.


SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Here's another scenario:

You define the following:


Now you have the obvious choice of doing DI as follows:


And the not so obvious:


The beauty of EJBs ;-)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9381
    
    2

Originally posted by Sergio Tridente:
Hi Jothi,

In the following code:



The BidManagerBean business remote interface is BidManager. There are no other business interfaces. So the proper way to get a reference to your bean will be to define:


You cannot use


BidManagerRemote is NOT a business interface of BidManagerBean.


I competely got what you are trying to convey. Thanks for the response! Another question here is, can I also say the same interface to be a Local interface?



Would this be right?
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Accordingly to section 4.6.6 of the ejb core specification:


The same business interface cannot be both a local and a remote business interface of the bean.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9381
    
    2

Thanks Sergio!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on interfaces for EJB 3