• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stop server ? and file.exists()

 
Manish Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
There is a line of code in the constructor of the Data class [ Data(String ..)]:



I couldn't find any use of f.exists() except the readability of the code..
am i right ???

Because according to the documentation
of canRead() or canWrite() method, these methods first check the whether the
file existsor not.

So, I'm going to remove f.exists() check..

=================================

My second problem:
I've have given an option in my GUI to start/stop the server without exiting
the GUI.

For STOP i have used to unbind my remote dataFactory object from the registry..
this doesn't actually stop the server but only stops listening to new connection.
The already connected clients can still perform search, booking operation after stopping...

I've used the following code to start the server



Is there any code to stop the registry ???.. but this will also not solve my problem..

=====================



Any comment on this will appreciated.

Thanks and regards,
Manish

---------------
-SCJP2
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,

I couldn't find any use of f.exists() except the readability of the code..
am i right ???
Because according to the documentation
of canRead() or canWrite() method, these methods first check the whether the
file exists or not.
So, I'm going to remove f.exists() check..

Even though exists() doesn't seem to be necessary, I don't think you should remove it. It does short circuit the condition before the other two calls which as you pointed out both check for existance also. So it's checked three times instead of two, no big deal. And why risk the possible loss of points on something trivial.

Is there any code to stop the registry ???.. but this will also not solve my problem..
=====================
Any comment on this will appreciated.

As you pointed out, stopping the registry will not solve the problem. I used server events to notify the connected clients that the server had shut down. Upon receiving the shutdown event the client diasbled the GUI except for exit and help.
Another possibility is to store a reference to some object in the remote connection objects that knows the status of the server. You could then throw something like a ServerDownException to notify the clients when they made a call on their remote objects after server shutdown.
Hope this helps,
Michael Morris
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
f.exists must exist there or the program will blow up if the file does not exist on the file system when you call the f.canRead().
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic