]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/Echo.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.core
.execution
.tasks
;
19 import java
.io
.IOException
;
21 import org
.apache
.commons
.io
.FileUtils
;
22 import org
.apache
.commons
.logging
.Log
;
23 import org
.apache
.commons
.logging
.LogFactory
;
24 import org
.argeo
.slc
.SlcException
;
25 import org
.springframework
.core
.io
.Resource
;
27 public class Echo
implements Runnable
{
28 private final static Log defaultLog
= LogFactory
.getLog(Echo
.class);
29 private Resource writeTo
= null;
32 private Object message
;
37 if (writeTo
!= null) {
39 File file
= writeTo
.getFile();
40 if (log().isDebugEnabled())
41 log().debug("Write to " + file
);
43 FileUtils
.writeStringToFile(file
, message
.toString());
44 } catch (IOException e
) {
45 throw new SlcException("Could not write to " + writeTo
, e
);
51 return log
!= null ? log
: defaultLog
;
54 public void setMessage(Object message
) {
55 this.message
= message
;
58 public void setWriteTo(Resource writeTo
) {
59 this.writeTo
= writeTo
;