1 /*------------------------------------------------------------------------------
 2 Name:      MainSvc.java
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 Comment:   Main class to invoke the xmlBlaster server
 6 Version:   $Id: MainSvc.java 14841 2006-03-06 23:58:27Z ruff $
 7 ------------------------------------------------------------------------------*/
 8 package org.xmlBlaster;
 9 
10 import com.silveregg.wrapper.WrapperManager;
11 import com.silveregg.wrapper.WrapperListener;
12 
13 import java.util.logging.Level;
14 
15 import org.xmlBlaster.engine.*;
16 import org.xmlBlaster.util.XmlBlasterException;
17 
18 public class MainSvc implements WrapperListener 
19 {
20    private Main main = null;
21     
22     /**************************************************************************
23      * WrapperListener Methods
24      *************************************************************************/
25     public Integer start(String[] args) {
26         System.out.println("start()");
27         
28         final String[] myArgs = args;
29         WrapperManager.signalStarting(20000);
30         
31         Thread startThread = new Thread() {
32             public void run() {
33                 ServerScope glob = new ServerScope(myArgs);
34                 try {
35                     glob.getProperty().set("doBlocking", "false");
36                 }catch(XmlBlasterException ex) {
37                 }
38                 main = new Main(glob);
39                 while (!main.isHalted()) try { Thread.sleep(60*1000); } catch (Exception e) {}
40             }
41         };
42         startThread.start();
43         
44         return null;
45     }
46     
47     public int stop(int exitCode) {
48         System.out.println("stop(" + exitCode + ")");
49 
50      if (main != null) main.shutdown();
51         main = null;
52         
53         return exitCode;
54     }
55     
56     public void controlEvent(int event) {
57         System.out.println("controlEvent(" + event + ")");
58         if (event == WrapperManager.WRAPPER_CTRL_C_EVENT) {
59             WrapperManager.stop(0);
60         }
61     }
62     
63     /**************************************************************************
64      * Main Method
65      *************************************************************************/
66     public static void main(String[] args) {
67         System.out.println("Initializing...");
68         
69         // Start the application.  If the JVM was launched from the native
70         //  Wrapper then the application will wait for the native Wrapper to
71         //  call the application's start method.  Otherwise the start method
72         //  will be called immediately.
73         WrapperManager.start(new MainSvc(), args);
74     }
75 }


syntax highlighted by Code2HTML, v. 0.9.1