• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Question about Local and Remote interfaces  RSS feed

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently started my SCBCD preparation from EJB 3 in Action.

One question I have in mind is do I need to have separate interface to provide the annotation @Remote and @Local
Can't I have both in a single one since my clients can be either remote or local for the same bean implementation?
 
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nitin,

you could simply use a @Remote interface only. The remote interface can be used local and remote!

Marco
 
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by nitin pai:


One question I have in mind is do I need to have separate interface to provide the annotation @Remote and @Local



Yes, you have to. The current EJB3.0 spec mandates two different interfaces for @Remote and @Local.

P.S: EJB 3.1 (which is in the early draft stages) proposes to do away with this requirement.
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Marco Ehrentreich:
Hi Nitin,

you could simply use a @Remote interface only. The remote interface can be used local and remote!

Marco



But when the @Remote is used it means that the client will make a RMI call, not a local call because the stubs will be built as remote stubs.

I think we would have to resort to making 2 interfaces as Jaikaran mentioned.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, now I really understand your question!

Of course you're right. With @Remote it's always a remote call but I don't know how much difference in performance this makes with a call to localhost. Perhaps it doesn't matter depending on your requirements. Perhaps a J2EE container can even make some optimizations here?!?

Unfortunately I don't know of any real solution to you problem. I never thought of it but it's obviously unhandy that one must have two different interfaces even if they declare the same methods.

The best idea is perhaps to use a common base interface with the business methods and just extend your two interfaces from it without additional method declarations!

Marco
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!