// If the controller is of kind UimecppServiceController or
// PrimitiveAnalysisController
// the termination logic will be immediately triggered in the
// terminate() method.
if (asyncServiceList != null && asyncServiceList.length > 0) {
ControllerLifecycle ctrer = (ControllerLifecycle) ctx.getBean(asyncServiceList[0]);
// Send a trigger to initiate shutdown.
if (ctrer instanceof AnalysisEngineController) {
((AnalysisEngineController) ctrer).getControllerLatch().release();
}
ctrer.terminate();
}
if (ctx instanceof FileSystemXmlApplicationContext) {
((FileSystemXmlApplicationContext) ctx).destroy();
}