Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Local and Remote interfaces

 
nitin pai
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?
 
Marco Ehrentreich
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
 
Jaikiran Pai
Marshal
Pie
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic