From 538370bda464bf1c51f6bb449f61efe46d7f20f3 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 13 Feb 2013 20:46:52 +0100 Subject: Removed isServer boolean - implied by AbstractMain.runningAsWrapper --- src/main/java/com/c2kernel/process/Gateway.java | 6 +++--- src/main/java/com/c2kernel/process/StandardClient.java | 12 +++++++++++- src/main/java/com/c2kernel/process/StandardServer.java | 4 ++-- src/main/java/com/c2kernel/process/UserCodeProcess.java | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/c2kernel') diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 1bb451d..70bfb14 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -71,7 +71,7 @@ public class Gateway * If null, the java system properties are used * @throws InvalidDataException - invalid properties caused a failure in initialisation */ - static public void init(Properties props, boolean isServer) throws InvalidDataException { + static public void init(Properties props) throws InvalidDataException { // Init properties & resources mC2KProps = new Properties(); @@ -89,7 +89,7 @@ public class Gateway // init module manager try { - mModules = new ModuleManager(ClassLoader.getSystemResources("META-INF/cristal/module.xml"), isServer); + mModules = new ModuleManager(ClassLoader.getSystemResources("META-INF/cristal/module.xml"), AbstractMain.runningAsWrapper); } catch (Exception e) { Logger.error(e); throw new InvalidDataException("Could not load module definitions.", ""); @@ -116,7 +116,7 @@ public class Gateway } // if client, run module startup scripts. Otherwise bootstrap will do it after all imports - if (!isServer) mModules.runScripts("startup"); + if (!AbstractMain.runningAsWrapper) mModules.runScripts("startup"); } /** diff --git a/src/main/java/com/c2kernel/process/StandardClient.java b/src/main/java/com/c2kernel/process/StandardClient.java index c6df6e2..4fa3036 100644 --- a/src/main/java/com/c2kernel/process/StandardClient.java +++ b/src/main/java/com/c2kernel/process/StandardClient.java @@ -15,8 +15,18 @@ abstract public class StandardClient extends AbstractMain { static public void main(String[] args) throws Exception { - Gateway.init(readC2KArgs(args), false); + Gateway.init(readC2KArgs(args)); //AgentProxy user = Gateway.connect("username", "password"); } + + static public void close() { + Gateway.close(); + // allow waiting threads time to quit + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + } + System.exit(0); + } } diff --git a/src/main/java/com/c2kernel/process/StandardServer.java b/src/main/java/com/c2kernel/process/StandardServer.java index af432da..546aaa5 100644 --- a/src/main/java/com/c2kernel/process/StandardServer.java +++ b/src/main/java/com/c2kernel/process/StandardServer.java @@ -43,7 +43,7 @@ public class StandardServer extends AbstractMain implements WrapperListener throws Exception { // read args and init Gateway - Gateway.init(readC2KArgs(args), true); + Gateway.init(readC2KArgs(args)); // connect to LDAP as root Gateway.connect(); @@ -79,8 +79,8 @@ public class StandardServer extends AbstractMain implements WrapperListener } public static void main(String[] args) { - server = new StandardServer(); AbstractMain.runningAsWrapper = true; + server = new StandardServer(); WrapperManager.start( server, args ); } diff --git a/src/main/java/com/c2kernel/process/UserCodeProcess.java b/src/main/java/com/c2kernel/process/UserCodeProcess.java index 2f508bc..1c40194 100644 --- a/src/main/java/com/c2kernel/process/UserCodeProcess.java +++ b/src/main/java/com/c2kernel/process/UserCodeProcess.java @@ -212,7 +212,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv try { - Gateway.init(readC2KArgs(args), false); + Gateway.init(readC2KArgs(args)); UserCodeProcess proc = getInstance(); new Thread(proc).start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { -- cgit v1.2.3