]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/runtime/AbstractAgent.java
Introduce the Executable interface
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / runtime / AbstractAgent.java
1 package org.argeo.slc.core.runtime;
2
3 import java.util.Map;
4 import java.util.Properties;
5
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8 import org.argeo.slc.process.SlcExecution;
9 import org.argeo.slc.runtime.SlcApplication;
10 import org.argeo.slc.runtime.SlcExecutionContext;
11
12 public abstract class AbstractAgent {
13 private final static Log log = LogFactory.getLog(AbstractAgent.class);
14
15 private SlcApplication<SlcExecutionContext> slcApplication;
16
17 protected void runSlcExecution(final SlcExecution slcExecution) {
18 // TODO: in a separate process
19 Thread thread = new Thread("SlcExecution " + slcExecution.getUuid()) {
20 public void run() {
21 Properties props = new Properties();
22 Map<String, String> attributes = slcExecution.getAttributes();
23 for (String key : attributes.keySet()) {
24 props.setProperty(key, attributes.get(key));
25 if (log.isTraceEnabled())
26 log.trace(key + "=" + props.getProperty(key));
27 }
28 slcApplication.execute(slcExecution, props, null, null);
29 log.debug("Thread for SLC execution #" + slcExecution.getUuid()
30 + " finished.");
31 }
32 };
33 thread.start();
34 }
35
36 public void setSlcApplication(
37 SlcApplication<SlcExecutionContext> application) {
38 this.slcApplication = application;
39 }
40
41 }