<jvmArgs>
<jvmArg>-Xmx256m</jvmArg>
</jvmArgs>
- <debug>0</debug>
+ <debug>8000</debug>
<systemProperties>
<slc.osgi.start>
org.argeo.dep.osgi.catalina.start,
<property name="attachmentUploader" ref="attachmentUploader" />\r
<property name="attachment">\r
<bean parent="taskArg.attachment">\r
- <property name="name" value="myAttachment" />\r
- <property name="contentType" value="text/plain" />\r
+ <property name="name" value="myAttachment.txt" />\r
</bean>\r
</property>\r
<property name="resource" ref="basic.writeTo" />\r
package org.argeo.slc.execution;\r
\r
+import java.util.Date;\r
import java.util.Map;\r
\r
public interface ExecutionContext {\r
- \r
+\r
/**\r
* @param name\r
* @return null if no object is found\r
*/\r
public Object findScopedObject(String name);\r
- \r
+\r
public void addScopedObject(String name, Object obj);\r
- \r
+\r
public String getUuid();\r
- \r
+\r
public void enterFlow(ExecutionFlow executionFlow);\r
- \r
+\r
public void leaveFlow(ExecutionFlow executionFlow);\r
- \r
+\r
public Object getVariable(String key);\r
- \r
+\r
public Object findVariable(String key);\r
- \r
- //TODO: replace with setVariable(String Key, Object value)\r
- public void addVariables(Map<? extends String, ? extends Object> variablesToAdd);\r
+\r
+ // TODO: replace with setVariable(String Key, Object value)\r
+ public void addVariables(\r
+ Map<? extends String, ? extends Object> variablesToAdd);\r
+\r
+ public Date getCreationDate();\r
}\r
<cache name="org.argeo.slc.runtime.SlcAgentDescriptor"
maxElementsInMemory="100" />
+ <cache name="org.argeo.slc.core.attachment.SimpleAttachment"
+ maxElementsInMemory="100000" />
+ <cache name="org.argeo.slc.core.test.tree.TreeTestResult.attachments"
+ maxElementsInMemory="100000" />
+
</ehcache>
\ No newline at end of file
package org.argeo.slc.core.execution;
import java.io.File;
+import java.text.SimpleDateFormat;
import org.argeo.slc.execution.ExecutionContext;
+import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
-public class FileExecutionResources implements ExecutionResources {
+public class FileExecutionResources implements ExecutionResources,
+ InitializingBean {
private File baseDir;
private ExecutionContext executionContext;
+ private String prefixDatePattern = "yyyyMMdd_HHmmss_";
+ private SimpleDateFormat sdf = null;
- public FileExecutionResources() {
- String osgiInstanceArea = System.getProperty("osgi.instance.area");
- if (osgiInstanceArea != null) {
- if (osgiInstanceArea.startsWith("file:"))
- osgiInstanceArea = osgiInstanceArea.substring("file:".length());
- baseDir = new File(osgiInstanceArea + File.separator
- + "executionResources");
- }
+ public void afterPropertiesSet() throws Exception {
+ if (sdf == null)
+ sdf = new SimpleDateFormat(prefixDatePattern);
if (baseDir == null) {
- String tempDir = System.getProperty("java.io.tmpdir");
- baseDir = new File(tempDir + File.separator
- + "slcExecutionResources");
+ String osgiInstanceArea = System.getProperty("osgi.instance.area");
+ if (osgiInstanceArea != null) {
+ if (osgiInstanceArea.startsWith("file:"))
+ osgiInstanceArea = osgiInstanceArea.substring("file:"
+ .length());
+ baseDir = new File(osgiInstanceArea + File.separator
+ + "executionResources");
+ }
+
+ if (baseDir == null) {
+ String tempDir = System.getProperty("java.io.tmpdir");
+ baseDir = new File(tempDir + File.separator
+ + "slcExecutionResources");
+ }
}
}
public File getFile(String relativePath) {
File executionDir = new File(baseDir.getPath() + File.separator
+ + sdf.format(executionContext.getCreationDate())
+ executionContext.getUuid());
if (!executionDir.exists())
executionDir.mkdirs();
this.executionContext = executionContext;
}
+ public void setPrefixDatePattern(String prefixDatePattern) {
+ this.prefixDatePattern = prefixDatePattern;
+ }
+
+ public void setSdf(SimpleDateFormat sdf) {
+ this.sdf = sdf;
+ }
+
}
package org.argeo.slc.core.execution;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
public class MapExecutionContext implements ExecutionContext {
private final static Log log = LogFactory.getLog(MapExecutionContext.class);
-
private final Stack<ExecutionFlowRuntime> stack = new Stack<ExecutionFlowRuntime>();
// TODO: make it thread safe?
private final Map<String, Object> variables = new HashMap<String, Object>();
private final String uuid = UUID.randomUUID().toString();
-
- public void addVariables(Map<? extends String, ? extends Object> variablesToAdd) {
+
+ private final Date creationDate = new Date();
+
+ public void addVariables(
+ Map<? extends String, ? extends Object> variablesToAdd) {
variables.putAll(variablesToAdd);
}
Map<String, ExecutionSpecAttribute> specAttrs = executionFlow
.getExecutionSpec().getAttributes();
for (String key : specAttrs.keySet()) {
- //ExecutionSpecAttribute esa = specAttrs.get(key);
+ // ExecutionSpecAttribute esa = specAttrs.get(key);
if (executionFlow.isSetAsParameter(key)) {
runtime.getLocalVariables().put(key,
executionFlow.getParameter(key));
public Object findVariable(String key) {
Object obj = null;
-
+
// Look if the variable is set in the global execution variables
// (i.e. the variable was overridden)
if (variables.containsKey(key))
- obj = variables.get(key);
-
+ obj = variables.get(key);
+
// if the variable was not found, look in the stack starting at the
// upper flows
if (obj == null) {
leftEf.getLocalVariables().clear();
}
-
+
public void addScopedObject(String name, Object obj) {
- //TODO: check that the object is not set yet ?
+ // TODO: check that the object is not set yet ?
stack.peek().getScopedObjects().put(name, obj);
}
-
+
/** return null if not found */
public Object findScopedObject(String name) {
Object obj = null;
return uuid;
}
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
private static class ExecutionFlowRuntime {
private final ExecutionFlow executionFlow;
private final Map<String, Object> scopedObjects = new HashMap<String, Object>();