/**
* Config controller.
*/
void configController()
{
JVMController controller = (JVMController) _controller;
controller.setLogger(getWrapperLogger());
controller.setKey(_config.getString("wrapper.key"));
if (_config.containsKey("wrapper.port"))
{
controller.setMinPort(_config.getInt("wrapper.port"));
controller.setMaxPort(_config.getInt("wrapper.port"));
}
else
{
controller.setMinPort(_config.getInt("wrapper.port.min", Constants.DEFAULT_PORT));
controller.setMaxPort(_config.getInt("wrapper.port.max", 65535));
}
controller.setStartupTimeout(_config.getInt("wrapper.startup.timeout", DEFAULT_STARTUP_TIMEOUT) * 1000);
controller.setPingTimeout(_config.getInt("wrapper.ping.timeout", DEFAULT_PING_TIMEOUT) * 1000);
if (!_initController)
{
ControllerListener restartHandler = new ControllerListener()
{
public void fire()
{
if (_state == STATE_RESTART_STOP || _state == STATE_RESTART || _state == STATE_RESTART_START || _state == STATE_RESTART_WAIT)
return;
if (allowRestart() && exitCodeRestart() && !exitCodeShutdown())
{
restartInternal();
}
else
{
if (_debug)
{
getWrapperLogger().info("giving up after " + _restartCount + " retries");
}
if (_state != STATE_USER_STOP)
setState(STATE_ABORT);
if (!_exiting)
stop();
setState(STATE_IDLE);
}
}
};
controller.addListener(JVMController.STATE_STARTUP_TIMEOUT, restartHandler);
controller.addListener(JVMController.STATE_PING_TIMEOUT, restartHandler);
controller.addListener(JVMController.STATE_PROCESS_KILLED, restartHandler);
if (!_config.getBoolean("wrapper.ntservice.autoreport.startup", true))
if (getService() instanceof WrapperMainServiceWin)
setServiceStartupListener(new Runnable()
{
public void run()
{
((WrapperMainServiceWin) getService()).notifyStartup();
}
});
controller.setServiceStartupListener(_serviceStartupListener);
controller.init();
_initController = true;
}
}