RE: Command line to STOP Restlet server

2009-01-15 Thread Jerome Louvel
Hi Leshek,

Here is a way that should work in Restlet 1.0:

   public static void main(String[] args) {
 try {
 Component component = new Component();
 component.getServers().add(Protocol.HTTP, 8182);
 MyApplication myApp = new MyApplication(component.getContext());
 myApp.getContext().getAttributes().put(component, component);
 component.getDefaultHost().attach(myApp);
 component.start();

Note that if you are in Restlet 1.1, you shouldn't pass the parent component's 
context directly. Instead, do something like:

   public static void main(String[] args) {
 try {
 Component component = new Component();
 component.getServers().add(Protocol.HTTP, 8182);
 MyApplication myApp = new MyApplication();

 // Will automatically set the right context on myApp
 component.getDefaultHost().attach(myApp);

 myApp.getContext().getAttributes().put(component, component);
 component.start();

Hope this will help.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-Message d'origine-
De : news [mailto:n...@ger.gmane.org] De la part de Leshek
Envoye : jeudi 15 janvier 2009 00:21
A : discuss@restlet.tigris.org
Objet : Re: Command line to STOP Restlet server

 When you stop the parent Component, it stops all the child connectors. 

Sounds like a simple, nice, soft stop for me, but... 

What I am thinking is to respond to URI request like PUT .../shutdown 
(limit to localhost request and run through authentication guard as all 
the other requests). 

How in the resource do I get to parent component when I started Restlet HTTP
server using main in my application as follows, or am I doing something 
silly here? : 

  public static void main(String[] args) {
 try {
 Component component = new Component();
 component.getServers().add(Protocol.HTTP, 8182);
 component.getDefaultHost().attach(new
MyApplication(component.getContext()));
 component.start();

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1025076

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1026048


RE: Command line to STOP Restlet server

2009-01-14 Thread Jerome Louvel
Hi Leshek,

When you stop the parent Component, it stops all the child connectors. 
Otherwise, you can stop each connector individually using the
stop() method. It should stop listening.

If you want to do that from an Application, you have to explicitly/manually 
pass it a reference to the parent Component so it can
call stop() on it when necessary.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 

-Message d'origine-
De : news [mailto:n...@ger.gmane.org] De la part de Leshek Fiedorowicz
Envoye : mercredi 14 janvier 2009 06:35
A : discuss@restlet.tigris.org
Objet : Re: Command line to STOP Restlet server

All good, helpful hints, but... by Restlet designed (the best practice?) way 
to stop Restlet internal HTTP server?

Leshek
Ps. I have re-registered with tigris, thank you Jerome!

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1023582

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1024607


Re: Command line to STOP Restlet server

2009-01-14 Thread Leshek
 When you stop the parent Component, it stops all the child connectors. 

Sounds like a simple, nice, soft stop for me, but... 

What I am thinking is to respond to URI request like PUT .../shutdown 
(limit to localhost request and run through authentication guard as all 
the other requests). 

How in the resource do I get to parent component when I started Restlet HTTP
server using main in my application as follows, or am I doing something 
silly here? : 

  public static void main(String[] args) {
 try {
 Component component = new Component();
 component.getServers().add(Protocol.HTTP, 8182);
 component.getDefaultHost().attach(new
MyApplication(component.getContext()));
 component.start();

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1025076


Re: Command line to STOP Restlet server

2009-01-13 Thread Tim Peierls
Take a look at Java Service Wrapper:
http://wrapper.tanukisoftware.org/

It covers all sorts of possibilities.

--tim

On Mon, Jan 12, 2009 at 12:29 PM, Leshek lesh...@hotmail.com wrote:

 I want to have stop and exit restlet server command line interface.
 The start is simple (java -jar myRest.jar).

 I know from within I can do getContext().getApplication().stop()
 I could to it in response to http request .../STOP, but... I want to keep
 control on the server only.

 So I am looking for something like starting a new Java application

 java -jar myRest.jar STOP

 to tell the other application to STOP cleanly.

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1019583



Re: Command line to STOP Restlet server

2009-01-13 Thread Simon Reinhardt
Leshek wrote:
 I know from within I can do getContext().getApplication().stop()
 I could to it in response to http request .../STOP, but... I want to keep 
 control on the server only.

Apart from the Service Wrapper already pointed out, you could always restrict 
access to such a resource. Either with HTTP Auth or by restricting the client 
host to localhost or both.

Regards,
  Simon

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1021804


Re: Command line to STOP Restlet server

2009-01-13 Thread Leshek Fiedorowicz
All good, helpful hints, but... by Restlet designed (the best practice?) way 
to stop Restlet internal HTTP server?

Leshek
Ps. I have re-registered with tigris, thank you Jerome!

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1023582