logger.debug("Starting app in: " + System.getProperty("user.dir"));
// Load Spring context
AbstractApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml");
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) context.getBean("pmScheduler");
@SuppressWarnings("unchecked")
ArrayList<ProcessCheckTask> processCheckTaskList = (ArrayList<ProcessCheckTask>) context
.getBean("processCheckTaskList");
// Schedule the process check tasks
for (ProcessCheckTask task : processCheckTaskList) {
ScheduledFuture<?> future = scheduler.schedule(task, new CronTrigger(task.getCron()));
task.setScheduledFuture(future);
}
while (!Thread.interrupted()) {
try {
Thread.yield();
Thread.sleep(2000);
} catch (InterruptedException e) {
logger.error("Thread error: " + e.getMessage());
}
}
logger.debug("Stopping app...");
scheduler.shutdown();
context.close();
logger.debug("Application stopped.");
System.exit(0);