if ((monitorCheckpointFrequency = System.getProperty(JmxMonitor.SamplingInterval)) != null) {
// Found monitor checkpoint frequency parameter, configure and start the monitor.
// If the monitor fails to initialize the service is not effected.
service.startMonitor(Long.parseLong(monitorCheckpointFrequency));
}
AnalysisEngineController topLevelControllor = serviceDeployer.getTopLevelController();
String prompt = "Press 'q'+'Enter' to quiesce and stop the service or 's'+'Enter' to stop it now.\nNote: selected option is not echoed on the console.";
if (topLevelControllor != null) {
System.out.println(prompt);
// Loop forever or until the service is stopped
while (!topLevelControllor.isStopped()) {
if (System.in.available() > 0) {
int c = System.in.read();
if (c == 's') {
service.stopMonitor();
serviceDeployer.undeploy(SpringContainerDeployer.STOP_NOW);
} else if (c == 'q') {
service.stopMonitor();
serviceDeployer.undeploy(SpringContainerDeployer.QUIESCE_AND_STOP);
} else if (Character.isLetter(c) || Character.isDigit(c)) {
System.out.println(prompt);
}
}
// This is a polling loop. Sleep for 1 sec
try {
if (!topLevelControllor.isStopped())
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
} // while
}