• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on interfaces for EJB 3

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sergio!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic