• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

loacl v/s remote interface

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what exactly is the difference between usage of local & remote interface ?
it seems that the explanation given in HF EJB was not sufficient enough to convince the interviewer.....can anyone please explain it with some example.
- prat
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, the differences are the following (summed up from chapter 5 of the EJB spec 2.0):
Remote home and component interfaces:
  • location-independent
  • interfaces are Java RMI interfaces
  • arguments and results of invocations are passed by value
  • interfaces can be mapped to CORBA clients (not written in Java)


  • Local home and component interfaces:
  • location-dependent: collocated in the same JVM
  • interfaces are normal Java interfaces
  • arguments and results of invocations are passed by reference (their state is shared by the caller and the callee)
  • local beans can only be accessed by other beans in the same JVM
  • special care must be taken when references are passed across the local interface


  • Choosing between one or the other solution might be tough as you have to make some tradeoff and maximize the ratio rapidity-flexibility (local calls are quicker than remote ones-using remote interfaces is more flexible than using local ones)
    [ April 06, 2004: Message edited by: Valentin Crettaz ]
     
    Ranch Hand
    Posts: 3178
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I think the main idea of EJB is in remote interface... Is it true, if I conclude that local interfaces are for testing purpose of the business methods on the server to make sure that the things are working well... Then go for the remote interfaces in the real world...
    Correct me, if I'm wrong...
     
    Valentin Crettaz
    Author & Gold Digger
    Posts: 7617
    6
    IntelliJ IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Well, it always depends on your architecture... For instance, you can have session beans with remote views (to be accessed form anywhere) that access entity beans with local views. Session and entity beans run in the same JVM on the same server. That way, the access of entity bean is much quicker as everything goes through their local interfaces. This kind of scenario can be used when Swing applications want to access entity beans on some server.
    If you develop an application where the only way to manipulate entity beans is through session beans (Session fa�ade design pattern) and you now at the beginning that all the beans will be deployed in the same application, it does not make big sense to have entity beans with remote views... Everytime you want to access an entity bean, a RMI call is issued on the network with all the overhead of un/marshalling going on, etc... It always makes sense to think about the architecture of your application before deciding if you go with local or remote (or both) views.
     
    Ko Ko Naing
    Ranch Hand
    Posts: 3178
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Valentin,
    Thanks a lot for your great explanation... I now know that it is according to the architecture that we are designing... We do have to care about the trade-offs between the local and home interfaces, meanwhile we cannot be sure that which one is better than which one...
    Thank you very much...
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic