Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Remote Vs Local

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a service that can run locally OR remotely, What is the best way to code it transparently, i.e. that the client doesn't know if he is using Local or Remote object?
I've been looking around for couple of days now but I can't find an elegant way to do it. All the options involve either the client catching RemoteExceptions or coding another RemoteInterface.
Could someone PLEASE enlighten me!
Do you know on any good resources/links in this area?
Thanks in advance
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've hit on my biggest pet peeve with RMI - lack of location transparency. I haven't found a solution that I would consider elegant. What I've done in the past is declare an interface that is identical to my remote interface EXCEPT for the RemoteException declarations. The actual business object implements this interface. In local usage, the client accesses the BOs directly through this interface. In remote usage the client uses a proxy that implements this interface and wraps the actual remote proxy, catching RemoteExceptions and wrapping them as either application specific exceptions or RuntimeExceptions as appropriate and rethrowing them. The proxy might also implement some kind of retry logic. I usually use some kind of factory in the client that vends the correct type of proxies as required.
This approach has worked for me, but I don't really like it. You end up with the duplicate interface declarations that need to be kept in sync and it just generally messy. Another option would be to consider an alternative like the Apache Jakarta AltRMI project ( is designed to be an RMI replacement with better transparency. I haven't used it, but it looks promising.
Shimi Avizmil
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eddie,
Thanks for the reply !
Yes, it looks like I have to stick to your design patter (which I have been trying to avoid).
I don't know if I can get the altRMI to be adopted much hustle...(and Politics), probably give it another year..
Anyway, Thank for the reply !
If anyone has a better/nicer solution would you mind posting it here..
Thanks again
    Bookmark Topic Watch Topic
  • New Topic