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%2Ftasks%2FEcho.java;h=07ec879aa2b15c6192118d2a5f8758664896493f;hb=e5249c75ef672c95d9cf5405b05cabf6083d18a6;hp=eeead38886c044b2a9d08ca8cf676328cde37fe9;hpb=34e590f37109dd9ff9aa4e12af04ee98779aa9e1;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/Echo.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/Echo.java index eeead3888..07ec879aa 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/Echo.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/Echo.java @@ -1,17 +1,34 @@ package org.argeo.slc.core.execution.tasks; +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.slc.execution.Executable; +import org.argeo.slc.SlcException; +import org.springframework.core.io.Resource; -public class Echo implements Executable { +public class Echo implements Runnable { private final static Log defaultLog = LogFactory.getLog(Echo.class); + private Resource writeTo = null; private Log log; private String message; - public void execute() { + public void run() { log().info(message); + + if (writeTo != null) { + try { + File file = writeTo.getFile(); + if (log().isDebugEnabled()) + log().debug("Write to " + file); + FileUtils.writeStringToFile(file, message); + } catch (IOException e) { + throw new SlcException("Could not write to " + writeTo, e); + } + } } protected Log log() { @@ -26,4 +43,8 @@ public class Echo implements Executable { this.message = message; } + public void setWriteTo(Resource writeTo) { + this.writeTo = writeTo; + } + }