X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FFileExecutionResources.java;fp=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FFileExecutionResources.java;h=171e0b2a16a023399854ad3410759ed64391c42b;hb=dac8c6efe1152245042261cb716f2b5bc078ea24;hp=e35ff0014c418bd1eb16e75b0bef814bb41d3f0d;hpb=f5e752d3632883704e7f7099330079133b939b65;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java index e35ff0014..171e0b2a1 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java @@ -1,28 +1,39 @@ 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"); + } } } @@ -34,6 +45,7 @@ public class FileExecutionResources implements ExecutionResources { public File getFile(String relativePath) { File executionDir = new File(baseDir.getPath() + File.separator + + sdf.format(executionContext.getCreationDate()) + executionContext.getUuid()); if (!executionDir.exists()) executionDir.mkdirs(); @@ -48,4 +60,12 @@ public class FileExecutionResources implements ExecutionResources { this.executionContext = executionContext; } + public void setPrefixDatePattern(String prefixDatePattern) { + this.prefixDatePattern = prefixDatePattern; + } + + public void setSdf(SimpleDateFormat sdf) { + this.sdf = sdf; + } + }