import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
-import org.argeo.slc.logging.Log4jUtils;
import org.argeo.slc.runtime.SlcExecutionContext;
import org.argeo.slc.runtime.SlcRuntime;
-import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class SlcMain {
public enum Mode {
- single, agent
+ single, agent, osgi
}
private static Log log = null;
private final static String BOOTSTRAP_LOG4J_CONFIG = "org/argeo/slc/cli/bootstrapLog4j.properties";
+ private final static String DEFAULT_AGENT_CONTEXT = "classpath:org/argeo/slc/cli/spring-agent-default.xml";
private final static Option modeOpt = OptionBuilder.withLongOpt("mode")
.withArgName("mode").hasArg().withDescription(
}
// Agent
else if (mode.equals(Mode.agent)) {
- if (runtimeStr == null)
- runtimeStr = "agent.xml";
- final ConfigurableApplicationContext applicationContext = new FileSystemXmlApplicationContext(
- "agent.xml");
+ final ConfigurableApplicationContext applicationContext;
+ if (runtimeStr == null) {
+ applicationContext = new ClassPathXmlApplicationContext(
+ DEFAULT_AGENT_CONTEXT);
+ } else {
+ applicationContext = new FileSystemXmlApplicationContext(
+ runtimeStr);
+ }
+ applicationContext.registerShutdownHook();
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
- }
- }
+ }
+ // OSGi
+ else if (mode.equals(Mode.osgi)) {
}
}