]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java
Clarify SLC project structure.
[gpl/argeo-slc.git] / cms / org.argeo.slc.spring / src / org / argeo / slc / core / execution / ExecutionResourcesFactoryBean.java
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java
new file mode 100644 (file)
index 0000000..b217c3b
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.slc.core.execution;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+/** Workaround when execution placedholders needs to be passed. */
+public class ExecutionResourcesFactoryBean implements FactoryBean<Resource> {
+       private ExecutionResources executionResources;
+       private String relativePath;
+
+       public Resource getObject() throws Exception {
+               Assert.notNull(executionResources, "executionResources is null");
+               Assert.notNull(relativePath, "relativePath is null");
+               return executionResources.getWritableResource(relativePath);
+       }
+
+       public Class<? extends Object> getObjectType() {
+               return Resource.class;
+       }
+
+       public boolean isSingleton() {
+               return true;
+       }
+
+       public void setExecutionResources(ExecutionResources executionResources) {
+               this.executionResources = executionResources;
+       }
+
+       public void setRelativePath(String relativePath) {
+               this.relativePath = relativePath;
+       }
+
+}