List of usage examples for org.apache.commons.daemon DaemonContext getController
public DaemonController getController();
DaemonController
object that can be used to control the Daemon
instance that this DaemonContext
is passed to. From source file:com.msp.jsvc.JRubyDaemon.java
/** *//*from ww w.ja va2s. c o m*/ public void init(DaemonContext arguments) throws Exception { this.controller = arguments.getController(); init(arguments.getArguments()); }
From source file:com.globalsight.cxe.adapter.teamsite.autoimport.AutomaticImportDaemon.java
/** * init and destroy were added in jakarta-tomcat-daemon. *//*from w w w . java2 s . c o m*/ public void init(DaemonContext context) throws Exception { s_logger.debug("AutomaticImportDaemon: instance " + this.hashCode() + " init"); /* Set up this simple daemon */ this.controller = context.getController(); this.thread = new Thread(this); }
From source file:SimpleDaemon.java
/** * init and destroy were added in jakarta-tomcat-daemon. */// ww w . jav a2 s .c o m public void init(DaemonContext context) throws Exception { System.err.println("SimpleDaemon: instance " + this.hashCode() + " init"); int port = 1200; String[] a = context.getArguments(); try { if (a.length > 0) port = Integer.parseInt(a[0]); } catch (NumberFormatException ex) { throw new DaemonInitException("parsing port", ex); } if (a.length > 1) this.directory = a[1]; else this.directory = "/tmp"; /* Dump a message */ System.err.println("SimpleDaemon: loading on port " + port); /* Set up this simple daemon */ this.controller = context.getController(); this.server = new ServerSocket(port); this.thread = new Thread(this); }
From source file:com.google.enterprise.adaptor.Daemon.java
@Override public void start() throws Exception { final Application savedApp; final DaemonContext savedContext; // Save values so that there aren't any races with stop/destroy. synchronized (this) { savedApp = this.app; savedContext = this.context; }//from w ww . ja v a 2 s . co m // Run in a new thread so that stop() can be called before we complete // starting (since starting can take a long time if the Adaptor keeps // throwing an exception). However, we still try to wait for start to // complete normally to ease testing and improve the user experience in the // common case of starting being quick. Thread thread = new Thread(new Runnable() { @Override public void run() { try { savedApp.daemonStart(); } catch (InterruptedException ex) { // We must be shutting down. Thread.currentThread().interrupt(); } catch (Exception ex) { savedContext.getController().fail("Failed to start service.", ex); } } }); thread.start(); thread.join(5 * 1000); }
From source file:net.sf.ehcache.server.standalone.Server.java
/** * Invoked by Jsvc with a context which includes the arguments passed to Jsvc. The main() method * also calls through here so that the server can be started using either Jsvc or java -jar... * * @param daemonContext//from w ww . ja va2 s.c o m * @throws Exception */ public void init(DaemonContext daemonContext) throws Exception { String[] args = daemonContext.getArguments(); if (args.length < 1 || args.length > 2 || (args.length == 1 && args[0].matches("--help"))) { System.out.println("Usage: java -jar ... [http httpPort] warfile | wardir "); System.exit(0); } if (args.length == 1) { war = new File(args[0]); if (!war.exists()) { System.err.println("Error: War file or exploded directory " + war + " does not exist."); System.exit(1); } } if (args.length == 2) { httpPort = Integer.parseInt(args[0]); war = new File(args[1]); if (!war.exists()) { System.err.println("Error: War file or exploded directory " + war + " does not exist."); System.exit(1); } } /* Dump a message */ System.err.println("\nEhcache standalone server initializing..."); /* Set up this simple daemon */ this.controller = daemonContext.getController(); }
From source file:org.waarp.common.service.ServiceLauncher.java
public void init(DaemonContext arg0) throws Exception { controller = arg0.getController(); logger.info("Daemon init"); }