]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java
1 package org
.argeo
.slc
.runtime
.tasks
;
4 import java
.io
.IOException
;
5 import java
.nio
.file
.Path
;
7 import org
.apache
.commons
.io
.FileUtils
;
8 import org
.apache
.commons
.logging
.Log
;
9 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.slc
.SlcException
;
12 public class Echo
implements Runnable
{
13 private final static Log defaultLog
= LogFactory
.getLog(Echo
.class);
14 private Path writeTo
= null;
17 private Object message
;
22 if (writeTo
!= null) {
24 File file
= writeTo
.toFile();
25 if (log().isDebugEnabled())
26 log().debug("Write to " + file
);
28 FileUtils
.writeStringToFile(file
, message
.toString());
29 } catch (IOException e
) {
30 throw new SlcException("Could not write to " + writeTo
, e
);
36 return log
!= null ? log
: defaultLog
;
39 public void setMessage(Object message
) {
40 this.message
= message
;
43 public void setWriteTo(Path writeTo
) {
44 this.writeTo
= writeTo
;