本文整理汇总了Java中org.apache.commons.daemon.DaemonInitException类的典型用法代码示例。如果您正苦于以下问题:Java DaemonInitException类的具体用法?Java DaemonInitException怎么用?Java DaemonInitException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DaemonInitException类属于org.apache.commons.daemon包,在下文中一共展示了DaemonInitException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext context) throws DaemonInitException, Exception {
if (!config.init(context.getArguments()))
throw new DaemonInitException("Invalid configuration.");
ClassLoader loader = SPLDaemon.class.getClassLoader();
InputStream params = loader.getResourceAsStream(DEFAULT_PARAMS_FILE);
if (params != null) {
MAVLinkShadow.getInstance().loadParams(params);
params.close();
} else {
logger.warn("File 'default.params' with initial parameters values not found.");
}
MAVLinkMessageQueue mtMessageQueue = new MAVLinkMessageQueue(config.getQueueSize());
tcpServer = new MAVLinkTcpServer(config.getMAVLinkPort(), mtMessageQueue);
MAVLinkMessageQueue moMessageQueue = new MAVLinkMessageQueue(config.getQueueSize());
MOMessageHandler moHandler = new MOMessageHandler(moMessageQueue);
httpServer = HttpServer.create(new InetSocketAddress(config.getRockblockPort()), 0);
httpServer.createContext(config.getHttpContext(),
new RockBlockHttpHandler(moHandler, config.getRockBlockIMEI()));
httpServer.setExecutor(null);
// TODO: Broadcast MO messages to all the connected clients.
RockBlockClient rockblock = new RockBlockClient(config.getRockBlockIMEI(),
config.getRockBlockUsername(),
config.getRockBlockPassword(),
config.getRockBlockURL());
MTMessagePump mtMsgPump = new MTMessagePump(mtMessageQueue, rockblock);
mtMsgPumpThread = new Thread(mtMsgPump, "mt-message-pump");
WSEndpoint.setMTQueue(mtMessageQueue);
wsServer = new Server("localhost", config.getWSPort(), "/gcs", WSEndpoint.class);
}
示例2: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext context) throws DaemonInitException{
logger.info("---- Initializing Jabbot ----");
logger.info("# Loading configuration file");
//File file = new File(CONFIG_FILE);
File file = new File(ClassLoader.getSystemResource(CONFIG_FILE).getFile());
FileConfigurationDao fileConfigurationDao = new FileConfigurationDao(file);
JabbotConfiguration configuration = fileConfigurationDao.getConfiguration();
logger.info("# Scanning extensions folder");
if(configuration.getExtensionsFolder() != null){
new ExtensionScanner(configuration.getExtensionsFolder()).run();
}
logger.info("# Registering configured bindings");
if(configuration.getServerList() != null) {
for (final BindingConfiguration connectionConfiguration : configuration.getServerList()) {
BindingManager.register(connectionConfiguration);
}
}
logger.info("# Initializing Event handlers");
this.registerEventHandlers();
logger.info("### Initialization completed");
}
示例3: parseCommandLine
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
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));
}
示例4: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext context) throws DaemonInitException, Exception {
if (instance != null)
throw new IllegalStateException("Mentor already initialized!");
instance = Mentor.get();
instance.init();
}
示例5: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
public void init(final DaemonContext dc) throws DaemonInitException {
logger.debug("Initializing AgentShell from JSVC");
try {
init(dc.getArguments());
} catch (final ConfigurationException ex) {
throw new DaemonInitException("Initialization failed", ex);
}
}
示例6: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@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.");
}
示例7: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init ( DaemonContext daemonContext ) throws DaemonInitException, Exception
{
String configFile = "/etc/eclipsescada/ngp2modbus/ngp2modbus.json";
// config file would be the first command line parameter
if ( daemonContext.getArguments ().length > 0 )
{
configFile = daemonContext.getArguments ()[0];
}
// is config file accessible at all?
if ( !new File ( configFile ).canRead () )
{
String msg = "config file '" + configFile + "' does not exists or can not be read!";
System.err.println ( msg );
throw new DaemonInitException ( msg );
}
// check if config file is valid
try
{
FileInputStream is = new FileInputStream ( configFile );
NgpToModbusConfiguration config = NgpToModbusConfiguration.read ( is );
System.out.println ( config );
}
catch ( final Exception e )
{
e.printStackTrace ();
throw new DaemonInitException ( "config validation failed", e );
}
System.out.println ( "Staring Modbus converter with config file " + configFile );
m = new Ngp2Modbus ( configFile );
}
示例8: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext daemonContext) throws DaemonInitException, Exception
{
//System.out.println("deamon: init()");
String arguments[] = daemonContext.getArguments();
System.out.println(arguments);
GlobalRegistryServer.main(arguments);
}
示例9: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
public void init(DaemonContext daemonContext) throws DaemonInitException, Exception {
logger = LoggerFactory.getLogger(DaemonWrapper.class);
logger.debug("DaemonWrapper initializing");
String[] args = daemonContext.getArguments();
dumblock = new Object();
stopped = false;
serverThread = new CliDispatcher(this,args,dumblock);
logger.debug("DaemonWrapper initialized");
}
示例10: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext context) throws DaemonInitException, Exception {
LOGGER.info("Initializing " + getClass().getSimpleName());
this.context = context;
cfg = MainConfiguration.getCfg(System.getProperties());
Properties p = MainConfiguration.processArguments(context.getArguments());
if (p != null) {
cfg.applyProperties(p);
}
mainController = new Controller(cfg);
mainController.setDaemon(true);
}
示例11: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@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);
}
}
示例12: main
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
public static void main(final String[] args)
{
AgentDaemon daemon = new AgentDaemon();
if (args.length != 1)
{
AgentDaemon.usage();
return;
}
try
{
if (StringUtils.equals("start", args[0]))
{
daemon.init(null);
daemon.start();
}
else if (StringUtils.equals("stop", args[0]))
{
daemon.stop();
}
else
{
AgentDaemon.usage();
}
}
catch (DaemonInitException dix)
{
ERROR_RECORDER.error(dix.getMessage(), dix);
System.exit(-1);
}
}
示例13: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext arg) throws DaemonInitException, Exception {
//TODO: get an xml config file from the command line
log.info("Linux daemon received init");
for (String s : arg.getArguments()) {
log.debug("Got argument: "+s);
}
if (!this.configure(DEFAULT_CONFIG_FILE)) {
throw new DaemonInitException("Error configuring logger with file: "+DEFAULT_CONFIG_FILE);
}
}
示例14: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
@Override
public void init(DaemonContext dc) throws DaemonInitException, Exception {
System.out.println("SVC INIT");
parseArguments(dc.getArguments(), this);
}
示例15: init
import org.apache.commons.daemon.DaemonInitException; //导入依赖的package包/类
public static void init(DaemonContext arg0) throws DaemonInitException,
Exception {
// TODO Auto-generated method stub
// System.out.println("init");
logger.info("init");
}