aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: RMI interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: RMI interface" Watch "NX: RMI interface" New topic
Author

NX: RMI interface

Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Hi guys,
My project (URLyBird) defines an interface (that we must call DB) with a bunch of methods (read, update etc) that must be implemented. RMI requires an interface with methods that throw RemoteException. This means that the method signatures on the RMI interface are different from those on the original DB interface. Has anyone managed to get RMI working using an RMI interface that simply extends DB and Remote? This seems the neatest way to go ahead, the RMI interface IS-A DB, which is kind of nice and is also the approach used by Max in his famous book. But Max's methods already throw IOException, the superclass of RemoteException, so the necessary addition of the RemoteException does not mess up his method signatures!
I guess I could just create a new RMI interface that declares the read, update and so on with the throws RemoteException added, but I have a feeling that a more elegent solution is out there somewhere!
Any ideas?
Simon
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi Simon
Originally posted by Simon Ingram:
Hi guys,
My project (URLyBird) defines an interface (that we must call DB) with a bunch of methods (read, update etc) that must be implemented. RMI requires an interface with methods that throw RemoteException. This means that the method signatures on the RMI interface are different from those on the original DB interface. Has anyone managed to get RMI working using an RMI interface that simply extends DB and Remote?

Am doing the same way, but did'nt submit the assignment though. I think most poeple implement this way only.
Simon
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Sorry,
When you say you implemented the same way, does this mean you created a new rmi interface that implements the methods in DB with "throws RemoteException" added. Or did you use an rmi interface that extends DB and Remote, thus keeping the same method signatures as in DB?
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi Simon,
Originally posted by Simon Ingram:
Sorry,
When you say you implemented the same way, does this mean you created a new rmi interface that implements the methods in DB with "throws RemoteException" added. Or did you use an rmi interface that extends DB and Remote, thus keeping the same method signatures as in DB?

This is how I did:

+ Sun's Interface
+ Interface X (Has only two business specific operations required by CSR)
+ Interface Y extends Remote, X

Though Y extends Remote,it still needs to throw RemoteException right. Sun's interface do not involve in any operations except that it is extended as required by Data. Created an adapter which extends X interface. Client is given a reference to adapter. Relation between Adapter and Data is composition.
If you have any doubts, please ask them. Thanks.
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Hi Satish,
thanks for your reply. It is what I thought. We need two interfaces one for the database, supplied by Sun and another with methods that throw RemoteException.
This is a pity because it means that when my client wants a connection to the database, he will get either a local database or a remote database. If both could have the same interface type, then the assignment code could be a lot less clunky!
Never mind!
best wishes
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: RMI interface