-
- // Initializes logging and log arguments
- initLogging(properties);
- if (log.isDebugEnabled()) {
- log.debug("Mode: " + mode);
- if (runtimeStr != null)
- log.debug("Runtime: " + runtimeStr);
- log.debug("User properties: " + properties);
- if (script != null)
- log.debug("Script: " + script);
- if (targets != null)
- log.debug("Targets: " + targets);
- }
-
- // Execution
- if (mode.equals(Mode.single)) {
- try {
- // DefaultSlcRuntime runtime = new DefaultSlcRuntime();
- // FIXME: inject this more cleanly
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Class clss = cl.loadClass("org.argeo.slc.ant.AntSlcRuntime");
- SlcRuntime<? extends SlcExecutionContext> runtime = (SlcRuntime<? extends SlcExecutionContext>) clss
- .newInstance();
- runtime.executeScript(runtimeStr, script, targets, properties,
- null, null);
- // System.exit(0);
- } catch (Exception e) {
- log.error("SLC client terminated with an error: ", e);
- System.exit(1);
- }
- }
- // Agent
- else if (mode.equals(Mode.agent)) {
- 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.");
- }