• Post Reply Bookmark Topic Watch Topic
  • New Topic

Remote Vs Local

 
Shimi Avizmil
Greenhorn
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
Shimi
 
Eddie Sheffield
Greenhorn
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 (http://incubator.apache.org/projects/altrmi/)which is designed to be an RMI replacement with better transparency. I haven't used it, but it looks promising.
HTH!
Eddie
 
Shimi Avizmil
Greenhorn
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 here...to 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!