+ // Agent
+ else if (mode.equals(Mode.agent)) {
+ if (runtimeStr == null)
+ runtimeStr = "agent.xml";
+ final ConfigurableApplicationContext applicationContext = new FileSystemXmlApplicationContext(
+ "agent.xml");
+ applicationContext.start();
+ log.info("SLC Agent context started.");
+
+ Thread shutdownHook = new Thread("SLC agent shutdown hook") {
+ public void run() {
+ applicationContext.stop();
+ applicationContext.close();
+ log.info("Closed agent application context.");
+ }
+ };
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+
+ while (applicationContext.isActive()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // silent
+ }
+ }
+ }