Win a copy of Functional Design and Architecture this week in the Functional programming 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Question about Local and Remote interfaces

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic