On 20/12/06, Jerome Louvel <[EMAIL PROTECTED]> wrote:

Dave,

This is the default behavior for all Java servers/daemons.
Which is clear (though not stated).



If you only want
to launch a server for a limited time, you can do something like:

<snip/>

Yes, that was my other thought, a simple timeout.
I thought the thread use, timeouts etc might be offputting?

   Server srv=null;

   /**
    *Respond to a GET
    **/
   public void respondToGet(){
       // Creating a minimal Restlet returning "Hello World"
               // Creating a minimal Restlet returning "Hello World"
       Restlet restlet = new Restlet() {
           @Override
           public void handle(Request request, Response response) {
               response.setEntity("Hello World!", MediaType.TEXT_PLAIN);

           }
       };
       // Create the HTTP server and listen on port 8182
       //Server srv = new Server(Protocol.HTTP, 8182, restlet);
       srv = new Server(Protocol.HTTP, 8182, restlet);
       try {
           srv.start();
       } catch (Exception ex) {
           ex.printStackTrace();
       }
   }

public void stopServer(){
       try {
           srv.stop();
       } catch (Exception ex) {
           ex.printStackTrace();
       }
}

Runs just the same as the example,
yet offers the opportunity to shut down using code?

regards


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

Reply via email to