org.apache.commons.daemon.DaemonInitException Java Examples

The following examples show how to use org.apache.commons.daemon.DaemonInitException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Bireme.java    From bireme with Apache License 2.0 5 votes vote down vote up
protected void parseCommandLine(String[] args)
    throws DaemonInitException, ConfigurationException, BiremeException {
  Option help = new Option("help", "print this message");
  Option configFile =
      Option.builder("config_file").hasArg().argName("file").desc("config file location").build();

  Options opts = new Options();
  opts.addOption(help);
  opts.addOption(configFile);
  CommandLine cmd = null;
  CommandLineParser parser = new DefaultParser();

  try {
    cmd = parser.parse(opts, args);

    if (cmd.hasOption("help")) {
      throw new ParseException("print help message");
    }
  } catch (ParseException e) {
    HelpFormatter formatter = new HelpFormatter();
    StringWriter out = new StringWriter();
    PrintWriter writer = new PrintWriter(out);
    formatter.printHelp(writer, formatter.getWidth(), "Bireme", null, opts,
        formatter.getLeftPadding(), formatter.getDescPadding(), null, true);
    writer.flush();
    String result = out.toString();
    throw new DaemonInitException(result);
  }

  String config = cmd.getOptionValue("config_file", DEFAULT_CONFIG_FILE);

  cxt = new Context(new Config(config));
}
 
Example #2
Source File: ScoreMarkerMain.java    From ExamStack with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(DaemonContext arg0) throws DaemonInitException, Exception {

	context = new AnnotationConfigApplicationContext();
	context.register(ScoreMarkConfig.class);
	context.refresh();
	scoreCalcuService = context.getBean(ScoreCalcuService.class);
	consumer = context.getBean(QueueingConsumer.class);
	mapper = context.getBean(ObjectMapper.class);
	createWorkThread();
	LOGGER.info("ScoreMarker daemon init done.");
}
 
Example #3
Source File: ScoreMarkerMain.java    From ExamStack with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(DaemonContext arg0) throws DaemonInitException, Exception {

	context = new AnnotationConfigApplicationContext();
	context.register(ScoreMarkConfig.class);
	context.refresh();
	scoreCalcuService = context.getBean(ScoreCalcuService.class);
	consumer = context.getBean(QueueingConsumer.class);
	mapper = context.getBean(ObjectMapper.class);
	createWorkThread();
	LOGGER.info("ScoreMarker daemon init done.");
}
 
Example #4
Source File: AgentShell.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
@Override
public void init(DaemonContext dc) throws DaemonInitException {
    s_logger.debug("Initializing AgentShell from JSVC");
    try {
        init(dc.getArguments());
    } catch (ConfigurationException ex) {
        throw new DaemonInitException("Initialization failed", ex);
    }
}
 
Example #5
Source File: Service.java    From act with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void init(DaemonContext context) throws DaemonInitException, Exception {
  String args[] = context.getArguments();
  LOGGER.info("Daemon initializing with arguments: %s", StringUtils.join(args, " "));
  init(args);
}
 
Example #6
Source File: Service.java    From act with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void init(DaemonContext context) throws DaemonInitException, Exception {
  String args[] = context.getArguments();
  LOGGER.info("Daemon initializing with arguments: %s", StringUtils.join(args, " "));
  init(args);
}
 
Example #7
Source File: UsageServer.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
@Override
public void init(DaemonContext arg0) throws DaemonInitException, Exception {
    initLog4j();
}
 
Example #8
Source File: Sshd.java    From artifactory_ssh_proxy with Apache License 2.0 2 votes vote down vote up
/**
 * Initialize this <code>Daemon</code> instance.
 * <p>
 * This method gets called once the JVM process is created and the <code>Daemon</code> instance is created thru its
 * empty public constructor.
 * </p>
 * <p>
 * Under certain operating systems (typically Unix based operating systems) and if the native invocation framework
 * is configured to do so, this method might be called with <i>super-user</i> privileges.
 * </p>
 * <p>
 * For example, it might be wise to create <code>ServerSocket</code> instances within the scope of this method, and
 * perform all operations requiring <i>super-user</i> privileges in the underlying operating system.
 * </p>
 * <p>
 * Apart from set up and allocation of native resources, this method must not start the actual operation of the
 * <code>Daemon</code> (such as starting threads calling the <code>ServerSocket.accept()</code> method) as this
 * would impose some serious security hazards. The start of operation must be performed in the <code>start()</code>
 * method.
 * </p>
 * 
 * @param context A <code>DaemonContext</code> object used to communicate with the container.
 * @exception DaemonInitException An exception that prevented initialization where you want to display a nice
 *            message to the user, rather than a stack trace.
 * @exception Exception Any exception preventing a successful initialization.
 */
@Override
public void init(DaemonContext arg0) throws DaemonInitException, Exception {
    // save our arguments
    this.args = arg0.getArguments();
}