1 package org.jacorb.notification; 2 3 23 24 import org.tanukisoftware.wrapper.WrapperListener; 25 import org.tanukisoftware.wrapper.WrapperManager; 26 27 31 32 public class WrapperMain implements WrapperListener 33 { 34 private static final Runnable CMD_WRAPPERMANAGER_STOP = new Runnable () 35 { 36 public void run() 37 { 38 WrapperManager.stop(0); 39 } 40 }; 41 42 private static final EventChannelFactoryImpl.ShutdownCallback WRAPPERMANAGER_BEGIN_SHUTDOWN = new EventChannelFactoryImpl.ShutdownCallback() 43 { 44 public void needTime(int time) 45 { 46 WrapperManager.signalStopping(time); 47 } 48 49 public void shutdownComplete() 50 { 51 } 53 }; 54 55 private AbstractChannelFactory application_; 56 57 59 private WrapperMain() 60 { 61 super(); 62 } 63 64 66 68 public Integer start(String [] args) 69 { 70 try 71 { 72 application_ = ConsoleMain.newFactory(args); 73 74 application_.setDestroyMethod(CMD_WRAPPERMANAGER_STOP); 75 76 return null; 77 } catch (Exception e) 78 { 79 e.printStackTrace(); 80 81 return new Integer (1); 82 } 83 } 84 85 public int stop(int n) 86 { 87 application_.shutdown(WRAPPERMANAGER_BEGIN_SHUTDOWN); 88 89 return 0; 90 } 91 92 public void controlEvent(int event) 93 { 94 if (WrapperManager.isControlledByNativeWrapper()) 95 { 96 } 98 else 99 { 100 103 if ((event == WrapperManager.WRAPPER_CTRL_C_EVENT) 104 || (event == WrapperManager.WRAPPER_CTRL_CLOSE_EVENT) 105 || (event == WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT)) 106 { 107 WrapperManager.stop(0); 108 } 109 } 110 } 111 112 public static void main(String [] args) 113 { 114 WrapperManager.start(new WrapperMain(), args); 115 } 116 } 117 | Popular Tags |