• 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:

RMI in Java Developer

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating an interface for Remote Method Invocation in which all the methods throws RemoteException.
However, there is a query: The Developer exam say that the user can used local or remote access.
Is that OK that both the local and remote used that interface in which all the method throw RemoteException or should the local used a different interface that does not throw RemoteException?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
Actually you can decide how you wish to proceed. You can use two interfaces. I had one interface that extended Remote but just threw Exception, so I could then throw any type I wanted to int he implementing classes. However, I am not sure that that is the best way.
Anyone else have suggestions?
Mark
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just had one interface that threw RemoteException in addition to any other exceptions, and documented the fact that these would never be thrown by a local implementation. I was not really happy with this design, but it was expedient, so I did it, and it seemed to be tolerated by the assesor.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
Yes, I use one interface too. Before , I couldn't sure whether it is fine or not. Now
I think it's no problem in logic. I think that
the class implements a remote interface means it
has the ability provided by the interface instead means it has to do every time. For example , you can create a class which implements Serializable , but you can use it without serialize it.
Wish this help you.
[ November 26, 2002: Message edited by: HiBob Chu ]
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pete Lyons:
I just had one interface that threw RemoteException in addition to any other exceptions, and documented the fact that these would never be thrown by a local implementation. I was not really happy with this design [...]

Do be happy. This works exactly the way it should do.
The fact that the interface throws RemoteException is an expression of the fact that implementations of this interface may be Remote. Any code using this interface should not care about the particular implementation it's working with; client code simply needs to cater for the fact that RemoteException may be thrown and doesn't care about whether it can be thrown by the particular implementation or not.
You do not really need to document that RemoteException is never thrown in a local implementation. The code that is using the interface shouldn't even have to know that there is a local implementation in the first place. Any code that needs a local implementation to work correctly should use Data directly (or perhaps a LocalDataInterface which extends DataInterface and strips all the RemoteExceptions).
By the way, you could argue that the DataInterface methods should all throw IOException rather than RemoteException, to express the fact that socket-based implementations are valid as well as RMI-based ones.
- Peter
reply
    Bookmark Topic Watch Topic
  • New Topic