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=4447&dsMessageId=1025076

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

Reply via email to