• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to stop server ? and file.exists()

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic