• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: concerning exception handling

 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I have some questions concerning exceptions:
My MetaData Class is a singleton. I have two methods:

I have decided to implement two methods, thus I have a distinction between the instantiation of MetaData and the providing of its instance.
The second reason consists in the different exception handling for the MagicCookieException and IOException:
The createInstance will only be called within my ConnectionFactoryImpl or my getLocalConnection-method within my RoomConnector-Class. Thus I can avoid that my Remote Client has to handle the MagicCookieException or the IOException which may occur while reading the header information.
1. Does my argumentation sounds reasonable?
2. What do you think about throwing an unchecked FatalSystemException within the getInstance()-method?
Why throwing an unchecked exception? Because the client has first to call the createInstance()-method before being able to call getInstance(). So it's an implementation error. Sounds reasonnable?
3. Concerning the handling of the beforementioned MagicCookieException and IOException at the caller's side:
Within my Server GUI, I have decided to create for my RoomServer Class a new exception, called StartServerException.Within the startServer-method I have following exception handling:

My Server GUI will catch the StartServerException and will display the message to the user and alert him that the server will shut down:

Andrew wrote in another thread:

You cannot stop the Sun RMI Registry programattically.
You can stop (or unbind) your server process from the registry, and then bind a new server process to the registry

That's why I decided to shut down my server if an excpetion occured during the registering and binding-process, otherwise it could be quite complicate to recovery from this exception.
What do you think about that? How have you handled this or a similar problem?
4. For the local connection, the concerning exceptions will be wrapped within the more general GUIException with the concerning message.
An application exit wouldn't be necessary.
I would be very thankful about comments,
Greetings
Ulrich
[ January 19, 2004: Message edited by: Ulrich Heeger ]
[ January 19, 2004: Message edited by: Ulrich Heeger ]
[ January 19, 2004: Message edited by: Ulrich Heeger ]
[ January 19, 2004: Message edited by: Ulrich Heeger ]
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
1. Your Singleton implementation looks weird IMO. The typical implementation has no createInstance(), while getInstance() creates the instance if it doesn't exist yet. If you need some examples, a search on this forum with "singleton" as keyword could be helpful.
2. N/A is 1. convinced you.
3. I keep the question open for some RMI specialist.
4. It sounds OK.
Best,
Phil.
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
How about this:

The client does something like this:

Hope this helps,
George
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Phil, hi George,
thank you for your help.
You have convinced me, I will change my Singleton, the third question will I post in a new thread where I will have some more questions concerning exceptions.
Regards
Ulrich
 
Billy Tsai
Ranch Hand
Posts: 1304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just use exception chaining will be enough
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic