X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=runtime%2Forg.argeo.slc.specs%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fexecution%2FExecutionStep.java;fp=runtime%2Forg.argeo.slc.specs%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fexecution%2FExecutionStep.java;h=df2d805a897712a38c7b439bac184813ca679010;hb=0e2ff188c2e8ffac85739cccc3925e8bd82d7be9;hp=0000000000000000000000000000000000000000;hpb=8696d1a70c254b338d0cac390ef7c80b5f773942;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionStep.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionStep.java new file mode 100644 index 000000000..df2d805a8 --- /dev/null +++ b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionStep.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.argeo.slc.execution; + +import java.io.Serializable; +import java.util.Date; + +/** + * An atomic step to be notified in during an {@link ExecutionProcess}. Can be a + * log or the start/end of a phase, etc. + */ +public class ExecutionStep implements Serializable { + private static final long serialVersionUID = 798640526532912161L; + + // public final static String START = "START"; + // public final static String END = "END"; + public final static String PHASE_START = "PHASE_START"; + public final static String PHASE_END = "PHASE_END"; + public final static String ERROR = "ERROR"; + public final static String WARNING = "WARNING"; + public final static String INFO = "INFO"; + public final static String DEBUG = "DEBUG"; + public final static String TRACE = "TRACE"; + + // TODO make the fields final and private when we don't need POJO support + // anymore (that + // is when SlcExecutionStep is removed) + protected String type; + protected String thread; + protected Date timestamp; + protected String log; + + /** Empty constructor */ + public ExecutionStep() { + thread = Thread.currentThread().getName(); + } + + /** Creates a step at the current date of type INFO */ + public ExecutionStep(String log) { + this(new Date(), INFO, log); + } + + /** Creates a step at the current date */ + public ExecutionStep(String type, String log) { + this(new Date(), type, log); + } + + /** Creates a step of the given type. */ + public ExecutionStep(Date timestamp, String type, String log) { + this(timestamp, type, log, Thread.currentThread().getName()); + } + + public ExecutionStep(Date timestamp, String type, String log, String thread) { + this.type = type; + this.timestamp = timestamp; + this.thread = thread; + this.log = addLog(log); + } + + public String getType() { + return type; + } + + public Date getTimestamp() { + return timestamp; + } + + public String getThread() { + return thread; + } + + /** + * Return the string that should be stored in the log field. Can be null if + * another mechanism is used to store log lines. + */ + protected String addLog(String log) { + return log; + } + + public String getLog() { + return log; + } + + @Override + public String toString() { + return "Execution step, thread=" + thread + ", type=" + type; + } + +}