--- /dev/null
+package org.argeo.slc.execution;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+\r
+/**\r
+ * An atomic step to be notified in during an {@link ExecutionProcess}. Can be a\r
+ * log or the start/end of a phase, etc.\r
+ */\r
+public class ExecutionStep implements Serializable {\r
+ private static final long serialVersionUID = 798640526532912161L;\r
+\r
+ public final static String PHASE_START = "PHASE_START";\r
+ public final static String PHASE_END = "PHASE_END";\r
+ public final static String ERROR = "ERROR";\r
+ public final static String WARNING = "WARNING";\r
+ public final static String INFO = "INFO";\r
+ public final static String DEBUG = "DEBUG";\r
+ public final static String TRACE = "TRACE";\r
+\r
+ /** @deprecated */\r
+ public final static String START = "START";\r
+ /** @deprecated */\r
+ public final static String END = "END";\r
+\r
+ // TODO make the fields final and private when we don't need POJO support\r
+ // anymore (that\r
+ // is when SlcExecutionStep is removed)\r
+ protected String type;\r
+ protected String thread;\r
+ protected Date timestamp;\r
+ protected String log;\r
+\r
+ private String location;\r
+\r
+ /** Empty constructor */\r
+ public ExecutionStep() {\r
+ Thread currentThread = Thread.currentThread();\r
+ thread = currentThread.getName();\r
+ }\r
+\r
+ /** Creates a step at the current date */\r
+ public ExecutionStep(String location, String type, String log) {\r
+ this(location, new Date(), type, log);\r
+ }\r
+\r
+ /** Creates a step of the given type. */\r
+ public ExecutionStep(String location, Date timestamp, String type,\r
+ String log) {\r
+ this(location, timestamp, type, log, Thread.currentThread().getName());\r
+ }\r
+\r
+ public ExecutionStep(String location, Date timestamp, String type,\r
+ String log, String thread) {\r
+ this.location = location;\r
+ this.type = type;\r
+ this.timestamp = timestamp;\r
+ this.thread = thread;\r
+ this.log = addLog(log);\r
+ }\r
+\r
+ public String getType() {\r
+ return type;\r
+ }\r
+\r
+ public Date getTimestamp() {\r
+ return timestamp;\r
+ }\r
+\r
+ public String getThread() {\r
+ return thread;\r
+ }\r
+\r
+ /**\r
+ * Return the string that should be stored in the log field. Can be null if\r
+ * another mechanism is used to store log lines.\r
+ */\r
+ protected String addLog(String log) {\r
+ return log;\r
+ }\r
+\r
+ public String getLog() {\r
+ return log;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "Execution step, thread=" + thread + ", type=" + type;\r
+ }\r
+\r
+ /** Typically the logging category */\r
+ public String getLocation() {\r
+ return location;\r
+ }\r
+\r
+}\r