return;
}
// Deploy components defined in Spring context files. This method blocks until
// the container is fully initialized and all UIMA-AS components are succefully
// deployed.
SpringContainerDeployer serviceDeployer = service.deploy(contextFiles);
if (serviceDeployer == null) {
System.out.println(">>> Failed to Deploy UIMA Service. Check Logs for Details");
System.exit(1);
}
// Add a shutdown hook to catch kill signal and to force quiesce and stop
ServiceShutdownHook shutdownHook = new ServiceShutdownHook(serviceDeployer);
Runtime.getRuntime().addShutdownHook(shutdownHook);
// Check if we should start an optional JMX-based monitor that will provide service metrics
// The monitor is enabled by existence of -Duima.jmx.monitor.interval=<number> parameter. By
// default
// the monitor is not enabled.
String monitorCheckpointFrequency;
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') {
serviceDeployer.undeploy(SpringContainerDeployer.STOP_NOW);
} else if (c == 'q') {
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