Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Doubt on interfaces for EJB 3

 
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE 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 ]
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • 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
Oracle Java Linux
  • 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: 10192
3
Mac PPC Eclipse IDE 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
Oracle Java Linux
  • 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: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sergio!
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic