| Author |
RMI 003
|
Javini Javono
Ranch Hand
Joined: Dec 03, 2003
Posts: 286
|
|
Hi, This is a follow-up question, based upon this link here at this site: http://www.coderanch.com/t/184995/java-developer-SCJD/certification/RMI The next question to consider, or the next observation to be made, is that our ...Impl method no longer need declare the, perhaps, troublesome remote exception in every method anymore. So, here is package rmi3, with the contents of the GenImpl class, but this time I've commented out every exception thrown. This compiles and runs without error. The complete rmi3 package runs against either localhost or against a live internet connect. Also, this ...Impl class (GenImpl) does not extend UnicastRemoteObject. So, now we have added two possible components of flexibility which perhaps can be leveraged to our advantage: 1. GenImpl no longer has to extend UnicastRemoteObject, but can extend one of our own, and 2. GenImpl's methods need not declare any exceptions, such as RemoteException, but only those that we specifically decide it will throw, if any. To test the exception capability, I told my Mac to be a web server, and I received an on-the-fly http://there.somewhere.com/ URL, wherein, when I go to it, it is my computer; that is, this is, I think, exercising the internet (for when I run the client, the modem indicator lights up as if it is being used). After testing out package rmi3, I then shut down the GenServer application. Then I ran the client GenClient; surely, something bad should occur, and here is the error I received: And the exception I received, java.rmi.ConnectException, is a direct sub-class of RemoteException: and as seen just above, ConnectException is a direct sub-class of RemoteException. And, I received this exception without having to declare each method has throwing a RemoteException and without having to declare the class as having extended UnicastRemoteObject. As I am just learning this stuff, if anyone has added-value comments on these new experiences in Java, they would be much appreciated. Thanks, Javini Javono [ January 25, 2004: Message edited by: Javini Javono ]
|
 |
 |
|
|
subject: RMI 003
|
|
|