From ae9571df5a41e9c35b819a6b9a496fe6d553b289 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 4 Jul 2014 17:12:57 +0200 Subject: Refactored tanuki service wrapper to a separate module --- .../java/com/c2kernel/process/StandardServer.java | 86 ++-------------------- 1 file changed, 7 insertions(+), 79 deletions(-) (limited to 'src/main/java/com/c2kernel/process/StandardServer.java') diff --git a/src/main/java/com/c2kernel/process/StandardServer.java b/src/main/java/com/c2kernel/process/StandardServer.java index 43f8afa..5855d7e 100644 --- a/src/main/java/com/c2kernel/process/StandardServer.java +++ b/src/main/java/com/c2kernel/process/StandardServer.java @@ -10,9 +10,6 @@ package com.c2kernel.process; -import org.tanukisoftware.wrapper.WrapperListener; -import org.tanukisoftware.wrapper.WrapperManager; - import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; @@ -22,27 +19,20 @@ import com.c2kernel.utils.Logger; * @author $Author: abranson $ $Date: 2005/04/28 13:49:43 $ * @version $Revision: 1.47 $ **************************************************************************/ -public class StandardServer extends AbstractMain implements WrapperListener +public class StandardServer extends AbstractMain { protected static StandardServer server; - - /************************************************************************** - * C2KRootPOA suitable for Factory objects - **************************************************************************/ - - - - - /************************************************************************** * void StandardInitalisation( String[] ) * * Set-up calls to ORB, POA and Factorys, both optional and required. **************************************************************************/ - protected void standardInitialisation( String[] args ) + protected static void standardInitialisation( String[] args ) throws Exception { + isServer = true; + // read args and init Gateway Gateway.init(readC2KArgs(args)); @@ -59,71 +49,9 @@ public class StandardServer extends AbstractMain implements WrapperListener } - - /************************************************************************** - * Sets up and runs and item server - **************************************************************************/ - @Override - public Integer start(String[] args) + public static void main(String[] args) throws Exception { - try - { - //initialise everything - standardInitialisation( args ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - Logger.die("Startup failed"); - } - return null; - } - - public static void main(String[] args) { - AbstractMain.runningAsWrapper = true; - server = new StandardServer(); - WrapperManager.start( server, args ); - } - - /** - * - */ - @Override - public void controlEvent(int event) { - if (WrapperManager.isControlledByNativeWrapper()) { - // The Wrapper will take care of this event - } else { - // We are not being controlled by the Wrapper, so - // handle the event ourselves. - if ((event == WrapperManager.WRAPPER_CTRL_C_EVENT) || - (event == WrapperManager.WRAPPER_CTRL_CLOSE_EVENT) || - (event == WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT)){ - WrapperManager.stop(0); - } - } - + //initialise everything + standardInitialisation( args ); } - - /************************************************************************** - * Closes all listeners, quits the VM. - * This method should be called to kill the server process - * e.g. from the NT service wrapper - **************************************************************************/ - @Override - public int stop(int arg0) { - WrapperManager.signalStopping(10000); - try - { - Gateway.close(); - } - catch( Exception ex ) - { - Logger.error(ex); - return 1; - } - - Logger.msg("StandardServer::shutdown - complete. "); - return 0; - } - } -- cgit v1.2.3