Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

RMI 003

Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a follow-up question, based upon this link here at this site:
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 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.
Javini Javono
[ January 25, 2004: Message edited by: Javini Javono ]
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic