]>
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) 2010 Mathieu Baudier <mbaudier@argeo.org>
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.
17 package org
.argeo
.slc
.core
.execution
.tasks
;
20 import java
.io
.IOException
;
22 import org
.apache
.commons
.io
.FileUtils
;
23 import org
.apache
.commons
.logging
.Log
;
24 import org
.apache
.commons
.logging
.LogFactory
;
25 import org
.argeo
.slc
.SlcException
;
26 import org
.springframework
.core
.io
.Resource
;
28 public class Echo
implements Runnable
{
29 private final static Log defaultLog
= LogFactory
.getLog(Echo
.class);
30 private Resource writeTo
= null;
33 private Object message
;
38 if (writeTo
!= null) {
40 File file
= writeTo
.getFile();
41 if (log().isDebugEnabled())
42 log().debug("Write to " + file
);
44 FileUtils
.writeStringToFile(file
, message
.toString());
45 } catch (IOException e
) {
46 throw new SlcException("Could not write to " + writeTo
, e
);
52 return log
!= null ? log
: defaultLog
;
55 public void setMessage(Object message
) {
56 this.message
= message
;
59 public void setWriteTo(Resource writeTo
) {
60 this.writeTo
= writeTo
;