package org.argeo.slc.client.rcp;
import org.argeo.security.ui.rcp.SecureRcp;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.window.Window.IExceptionHandler;
import org.eclipse.ui.application.WorkbenchAdvisor;
/**
@Override
protected WorkbenchAdvisor createWorkbenchAdvisor(String username) {
+ Window.setExceptionHandler(new IExceptionHandler() {
+
+ public void handleException(Throwable t) {
+ System.err.println("Unexpected SLC UI exception: " + t);
+
+ }
+ });
+
return new SlcSecureWorkbenchAdvisor(username);
}
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processController" class="org.argeo.slc.client.ui.controllers.ProcessController">
-<!-- <property name="slcExecutionService" ref="slcExecutionService" /> -->
</bean>
</beans>
<bean id="processEditor" class="org.argeo.slc.client.ui.editors.ProcessEditor"
scope="prototype">
<property name="processController" ref="processController" />
+ <property name="modulesManager" ref="modulesManager" />
<property name="session">
<bean factory-bean="repository" factory-method="login" />
</property>
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <!-- Views -->
- <bean id="jcrExecutionModulesView" class="org.argeo.slc.client.ui.views.JcrExecutionModulesView"
- scope="prototype">
- <property name="session" ref="session" />
- <property name="modulesManager" ref="modulesManager"/>
- </bean>
-
- <bean id="jcrProcessListView" class="org.argeo.slc.client.ui.views.JcrProcessListView"
- scope="prototype">
- <property name="session" ref="session" />
- </bean>
-
- <bean id="jcrResultListView" class="org.argeo.slc.client.ui.views.JcrResultListView"
- scope="prototype">
- <property name="session" ref="session" />
- </bean>
-
<bean id="session" class="org.argeo.jcr.spring.ThreadBoundSession">
<property name="repository" ref="repository" />
</bean>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-<!-- <bean id="testManagerServiceAdapter" -->
-<!-- class="org.argeo.slc.client.ui.listeners.TestManagerServiceAdapter"> -->
-<!-- <property name="testManagerService" ref="testManagerService" /> -->
-<!-- </bean> -->
-
-<!-- <bean id="slcExecutionServiceAdapter" class="org.argeo.slc.services.impl.SlcExecutionServiceAdapter"> -->
-<!-- <property name="slcExecutionService" ref="slcExecutionService" /> -->
-<!-- </bean> -->
-
-</beans>
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <!-- Views -->
-<!-- <bean id="executionModulesView" class="org.argeo.slc.client.ui.views.ExecutionModulesView" -->
-<!-- scope="prototype"> -->
-<!-- <property name="contentProvider" ref="executionModulesContentProvider" /> -->
-<!-- <property name="processController" ref="processController" /> -->
-<!-- <property name="oxmBean" ref="oxmBean" /> -->
-<!-- </bean> -->
+ <bean id="jcrExecutionModulesView" class="org.argeo.slc.client.ui.views.JcrExecutionModulesView"
+ scope="prototype">
+ <property name="session" ref="session" />
+ <property name="modulesManager" ref="modulesManager" />
+ </bean>
-<!-- <bean id="resultListView" class="org.argeo.slc.client.ui.views.ResultListView" -->
-<!-- scope="prototype"> -->
-<!-- <property name="testResultCollectionDao" ref="testResultCollectionDao" /> -->
-<!-- </bean> -->
+ <bean id="jcrProcessListView" class="org.argeo.slc.client.ui.views.JcrProcessListView"
+ scope="prototype">
+ <property name="session" ref="session" />
+ </bean>
-<!-- <bean id="resultDetailView" class="org.argeo.slc.client.ui.views.ResultDetailView" -->
-<!-- scope="prototype"> -->
-<!-- <property name="treeTestResultDao" ref="treeTestResultDao" /> -->
-<!-- <property name="contentProvider" ref="resultDetailContentProvider" /> -->
-<!-- <property name="labelProvider" ref="resultDetailLabelProvider" /> -->
-<!-- </bean> -->
-<!-- <bean id="processListView" class="org.argeo.slc.client.ui.views.ProcessListView" -->
-<!-- scope="prototype"> -->
-<!-- <property name="slcExecutionDao" ref="slcExecutionDao" /> -->
-<!-- <property name="structuredContentProvider" ref="processListStructuredContentProvider" /> -->
-<!-- <property name="tableLabelProvider" ref="processListTableLabelProvider" /> -->
-<!-- </bean> -->
+ <bean id="jcrResultListView" class="org.argeo.slc.client.ui.views.JcrResultListView"
+ scope="prototype">
+ <property name="session" ref="session" />
+ </bean>
-<!-- <bean id="processDetailView" class="org.argeo.slc.client.ui.views.ProcessDetailView" -->
-<!-- scope="prototype"> -->
-<!-- <property name="slcExecutionDao" ref="slcExecutionDao" /> -->
-<!-- <property name="contentProvider" ref="processDetailContentProvider" /> -->
-<!-- </bean> -->
-
-<!-- <bean id="processBuilderView" class="org.argeo.slc.client.ui.views.ProcessBuilderView" -->
-<!-- scope="prototype"> -->
-<!-- <property name="processController" ref="processController" /> -->
-<!-- <property name="oxmBean" ref="oxmBean" /> -->
-<!-- <property name="slcAgents" ref="slcAgents" /> -->
-<!-- </bean> -->
-
-<!-- <bean id="processParametersView" class="org.argeo.slc.client.ui.views.ProcessParametersView" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-
- <!-- Providers. -->
-<!-- <bean id="executionModulesContentProvider" -->
-<!-- class="org.argeo.slc.client.ui.providers.ExecutionModulesContentProvider"> -->
-<!-- <property name="slcAgents" ref="slcAgents" /> -->
-<!-- </bean> -->
</beans>
private final static Log log = LogFactory.getLog(ProcessController.class);
private Map<String, SlcAgentFactory> agentFactories = new HashMap<String, SlcAgentFactory>();
- public void process(Node processNode) {
+ public ExecutionProcess process(Node processNode) {
JcrExecutionProcess process = new JcrExecutionProcess(processNode);
try {
// we currently only deal with single agents
SlcAgent slcAgent = agentFactory.getAgent(agentUuid);
slcAgent.process(process);
}
+ return process;
} catch (Exception e) {
if (!process.getStatus().equals(ExecutionProcess.ERROR))
process.setStatus(ExecutionProcess.ERROR);
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
+/** Definition of the process. */
public class ProcessBuilderPage extends FormPage implements SlcNames {
public final static String ID = "processBuilderPage";
// private final static Log log =
package org.argeo.slc.client.ui.editors;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.UUID;
import javax.jcr.Node;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.ClientUiPlugin;
import org.argeo.slc.client.ui.controllers.ProcessController;
+import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionProcessNotifier;
+import org.argeo.slc.execution.ExecutionStep;
import org.argeo.slc.jcr.SlcJcrUtils;
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;
-public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames {
+public class ProcessEditor extends FormEditor implements
+ ExecutionProcessNotifier, SlcTypes, SlcNames {
public final static String ID = ClientUiPlugin.ID + ".processEditor";
private Session session;
private ProcessBuilderPage builderPage;
private ProcessLogPage logPage;
+ private ExecutionModulesManager modulesManager;
+
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
}
doSave(null);
try {
- processController.process(processNode);
+ ExecutionProcess process = processController.process(processNode);
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put(ExecutionModulesManager.SLC_PROCESS_ID,
+ process.getUuid());
+ modulesManager.registerProcessNotifier(this, properties);
} catch (Exception e) {
Error.show("Execution of " + processNode + " failed", e);
}
return false;
}
+ public void updateStatus(ExecutionProcess process, String oldStatus,
+ String newStatus) {
+ }
+
+ public void addSteps(ExecutionProcess process, List<ExecutionStep> steps) {
+ logPage.addSteps(steps);
+ }
+
/** Expects one session per editor. */
public void setSession(Session session) {
this.session = session;
this.processController = processController;
}
+ public void setModulesManager(ExecutionModulesManager modulesManager) {
+ this.modulesManager = modulesManager;
+ }
+
}
package org.argeo.slc.client.ui.editors;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import org.argeo.slc.execution.ExecutionStep;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
public class ProcessLogPage extends FormPage {
- public final static String ID = "processLogrPage";
+ public final static String ID = "processLogPage";
+
+ private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ /** Where the log is displayed. */
+ private Text text;
+ /**
+ * Stores logs received before the text was shown. TODO : rather store in in
+ * JCR and reads it from there.
+ */
+ private StringBuffer beforeTextInit = new StringBuffer("");
public ProcessLogPage(FormEditor editor) {
super(editor, ID, "Log");
}
+ @Override
+ public synchronized void createPartControl(Composite parent) {
+ // bypass createFormContent
+ FormToolkit tk = getEditor().getToolkit();
+ // parent.setLayout(new FillLayout());
+ text = tk.createText(parent, "", SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ text.setEditable(false);
+
+ // transfer the existing buffer the first time
+ if (beforeTextInit.length() > 0) {
+ text.append(beforeTextInit.toString());
+ // clear buffer
+ beforeTextInit.setLength(0);
+ }
+
+ }
+
+// @Override
+// protected synchronized void createFormContent(IManagedForm mf) {
+// ScrolledForm form = mf.getForm();
+// form.setExpandHorizontal(true);
+// form.setExpandVertical(true);
+// // form.setText("Log");
+// FillLayout mainLayout = new FillLayout();
+// form.getBody().setLayout(mainLayout);
+//
+// FormToolkit tk = getManagedForm().getToolkit();
+// text = tk.createText(form.getBody(), "", SWT.MULTI | SWT.H_SCROLL
+// | SWT.V_SCROLL);
+// text.setEditable(false);
+// // transfer the existing buffer the first time
+// if (beforeTextInit.length() > 0) {
+// text.append(beforeTextInit.toString());
+// // clear buffer
+// beforeTextInit.setLength(0);
+// }
+// }
+
+ public synchronized void addSteps(List<ExecutionStep> steps) {
+ final StringBuffer buf = new StringBuffer("");
+ for (ExecutionStep step : steps) {
+ buf.append(dateFormat.format(step.getTimestamp()));
+ buf.append(' ');
+ if (step.getType().equals(ExecutionStep.PHASE_START)) {
+ buf.append("## START ").append(step.getLog());
+ buf.append('\n');
+ } else if (step.getType().equals(ExecutionStep.PHASE_END)) {
+ buf.append("## END ").append(step.getLog());
+ buf.append("\n");
+ } else {
+ buf.append(step.getLog());
+ }
+ }
+
+ if (text != null) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ text.append(buf.toString());
+ }
+ });
+ } else
+ beforeTextInit.append(buf);
+ }
+
+ @Override
+ public Control getPartControl() {
+ return text;
+ }
+
+ @Override
+ public void setFocus() {
+ if (text != null)
+ text.setFocus();
+ }
+
}
package org.argeo.slc.core.execution;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionProcessNotifier;
+import org.argeo.slc.execution.ExecutionStep;
import org.argeo.slc.process.RealizedFlow;
import org.argeo.slc.process.SlcExecutionNotifier;
-import org.argeo.slc.process.SlcExecutionStep;
/** Provides the base feature of an execution module manager. */
@SuppressWarnings("deprecation")
private List<SlcExecutionNotifier> slcExecutionNotifiers = new ArrayList<SlcExecutionNotifier>();
- private ThreadGroup processesThreadGroup = new ThreadGroup("Processes");
+ private List<FilteredNotifier> filteredNotifiers = Collections
+ .synchronizedList(new ArrayList<FilteredNotifier>());
+
+ private ThreadGroup processesThreadGroup = new ThreadGroup("SLC Processes");
protected abstract ExecutionFlow findExecutionFlow(String moduleName,
String moduleVersion, String flowName);
//
}
- public void dispatchUpdateStatus(ExecutionProcess slcExecution,
+ public void dispatchUpdateStatus(ExecutionProcess process,
String oldStatus, String newStatus) {
+ // generic notifiers (notified of everything)
for (Iterator<SlcExecutionNotifier> it = getSlcExecutionNotifiers()
.iterator(); it.hasNext();) {
- it.next().updateStatus(slcExecution, oldStatus, newStatus);
+ it.next().updateStatus(process, oldStatus, newStatus);
+ }
+
+ // filtered notifiers
+ for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+ .hasNext();) {
+ FilteredNotifier filteredNotifier = it.next();
+ if (filteredNotifier.receiveFrom(process))
+ filteredNotifier.getNotifier().updateStatus(process, oldStatus,
+ newStatus);
}
}
- public void dispatchAddStep(ExecutionProcess slcExecution,
- SlcExecutionStep step) {
- List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();
- steps.add(step);
+ public void dispatchAddSteps(ExecutionProcess process,
+ List<ExecutionStep> steps) {
for (Iterator<SlcExecutionNotifier> it = getSlcExecutionNotifiers()
.iterator(); it.hasNext();) {
- it.next().addSteps(slcExecution, steps);
+ it.next().addSteps(process, steps);
+ }
+
+ for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+ .hasNext();) {
+ FilteredNotifier filteredNotifier = it.next();
+ if (filteredNotifier.receiveFrom(process))
+ filteredNotifier.getNotifier().addSteps(process, steps);
}
}
+ public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+ Map<String, String> properties) {
+ filteredNotifiers.add(new FilteredNotifier(notifier, properties));
+ }
+
public void setSlcExecutionNotifiers(
List<SlcExecutionNotifier> slcExecutionNotifiers) {
this.slcExecutionNotifiers = slcExecutionNotifiers;
}
- public List<SlcExecutionNotifier> getSlcExecutionNotifiers() {
+ private List<SlcExecutionNotifier> getSlcExecutionNotifiers() {
return slcExecutionNotifiers;
}
return processesThreadGroup;
}
+ protected class FilteredNotifier {
+ private final ExecutionProcessNotifier notifier;
+ private final String processId;
+
+ public FilteredNotifier(ExecutionProcessNotifier notifier,
+ Map<String, String> properties) {
+ super();
+ this.notifier = notifier;
+ if (properties.containsKey(SLC_PROCESS_ID))
+ processId = properties.get(SLC_PROCESS_ID);
+ else
+ processId = null;
+ }
+
+ /**
+ * Whether event from this process should be received by this listener.
+ */
+ public Boolean receiveFrom(ExecutionProcess process) {
+ if (processId != null)
+ if (process.getUuid().equals(processId))
+ return true;
+ else
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return notifier.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return notifier.equals(obj);
+ }
+
+ public ExecutionProcessNotifier getNotifier() {
+ return notifier;
+ }
+
+ }
}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionStep;
import org.argeo.slc.process.RealizedFlow;
-import org.argeo.slc.process.SlcExecutionStep;
/** Thread of a single execution */
public class ExecutionThread extends Thread {
.getFlowDescriptor();
String flowName = executionFlowDescriptor.getName();
- dispatchAddStep(new SlcExecutionStep(SlcExecutionStep.PHASE_START,
- "Flow " + flowName));
+ dispatchAddStep(new ExecutionStep(ExecutionStep.PHASE_START, "Flow "
+ + flowName));
try {
String autoUpgrade = System
// TODO: re-throw exception ?
String msg = "Execution of flow " + flowName + " failed.";
log.error(msg, e);
- dispatchAddStep(new SlcExecutionStep(SlcExecutionStep.ERROR, msg
- + " " + e.getMessage()));
+ dispatchAddStep(new ExecutionStep(ExecutionStep.ERROR, msg + " "
+ + e.getMessage()));
processThread.notifyError();
} finally {
processThread.flowCompleted();
- dispatchAddStep(new SlcExecutionStep(SlcExecutionStep.PHASE_END,
- "Flow " + flowName));
+ dispatchAddStep(new ExecutionStep(ExecutionStep.PHASE_END, "Flow "
+ + flowName));
}
}
- private void dispatchAddStep(SlcExecutionStep step) {
+ private void dispatchAddStep(ExecutionStep step) {
processThread.getProcessThreadGroup().dispatchAddStep(step);
}
package org.argeo.slc.core.execution;
+import java.util.ArrayList;
+import java.util.List;
+
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionStep;
import org.argeo.slc.process.SlcExecution;
import org.argeo.slc.process.SlcExecutionStep;
// return processThread.getSlcProcess();
// }
- public void dispatchAddStep(SlcExecutionStep step) {
+ public void dispatchAddStep(ExecutionStep step) {
+ // legacy
ExecutionProcess slcProcess = processThread.getProcess();
if (slcProcess instanceof SlcExecution)
- ((SlcExecution) slcProcess).getSteps().add(step);
- executionModulesManager.dispatchAddStep(slcProcess, step);
+ ((SlcExecution) slcProcess).getSteps().add((SlcExecutionStep) step);
+
+ List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
+ steps.add(step);
+ dispatchAddSteps(steps);
+ }
+
+ public void dispatchAddSteps(List<ExecutionStep> steps) {
+ ExecutionProcess slcProcess = processThread.getProcess();
+ executionModulesManager.dispatchAddSteps(slcProcess, steps);
}
}
package org.argeo.slc.execution;
import java.util.List;
+import java.util.Map;
import org.argeo.slc.deploy.ModulesManager;
import org.argeo.slc.process.RealizedFlow;
/** Provides access to the execution modules */
public interface ExecutionModulesManager extends ModulesManager {
+ /** Used to filter event notified to an execution notifier. */
+ public static String SLC_PROCESS_ID = "slc.process.id";
+
/** @return a full fledged module descriptor. */
public ExecutionModuleDescriptor getExecutionModuleDescriptor(
String moduleName, String version);
String oldStatus, String newStatus);
/** Notify that a step was added in an {@link ExecutionProcess} */
- public void dispatchAddStep(ExecutionProcess process, SlcExecutionStep step);
+ public void dispatchAddSteps(ExecutionProcess process,
+ List<ExecutionStep> steps);
+
+ /**
+ * Register a notifier which will be notified based on the provided
+ * properties.
+ */
+ public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+ Map<String, String> properties);
}
import java.util.List;
-import org.argeo.slc.process.SlcExecutionStep;
-
+/**
+ * Implementations of this interface can be notified of events related to
+ * process execution.
+ */
public interface ExecutionProcessNotifier {
- public void addSteps(ExecutionProcess process,
- List<SlcExecutionStep> additionalSteps);
-
+ /**
+ * Notify a status change, see {@link ExecutionProcess} for the list of
+ * vaailable statuses.
+ */
public void updateStatus(ExecutionProcess process, String oldStatus,
String newStatus);
+ /** Notifiy of new execution steps. */
+ public void addSteps(ExecutionProcess process, List<ExecutionStep> steps);
+
}
--- /dev/null
+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+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 START = "START";\r
+ // public final static String END = "END";\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
+ // 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
+ /** Empty constructor */\r
+ public ExecutionStep() {\r
+ thread = Thread.currentThread().getName();\r
+ }\r
+\r
+ /** Creates a step at the current date of type INFO */\r
+ public ExecutionStep(String log) {\r
+ this(new Date(), INFO, log);\r
+ }\r
+\r
+ /** Creates a step at the current date */\r
+ public ExecutionStep(String type, String log) {\r
+ this(new Date(), type, log);\r
+ }\r
+\r
+ /** Creates a step of the given type. */\r
+ public ExecutionStep(Date timestamp, String type, String log) {\r
+ this(timestamp, type, log, Thread.currentThread().getName());\r
+ }\r
+\r
+ public ExecutionStep(Date timestamp, String type, String log, String thread) {\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
+}\r
\r
package org.argeo.slc.process;\r
\r
-import java.io.Serializable;\r
import java.util.ArrayList;\r
import java.util.Date;\r
import java.util.List;\r
import java.util.StringTokenizer;\r
import java.util.UUID;\r
\r
+import org.argeo.slc.execution.ExecutionStep;\r
+\r
/**\r
* An atomic step to be notified in during an {@link SlcExecution}. Can be a log\r
* or the start/end of a phase, etc.\r
+ * \r
+ * @deprecated use {@link ExecutionStep} instead\r
*/\r
-public class SlcExecutionStep implements Serializable {\r
+public class SlcExecutionStep extends ExecutionStep {\r
private static final long serialVersionUID = -7308643628104726471L;\r
\r
- public final static String START = "START";\r
- public final static String END = "END";\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
private String uuid = UUID.randomUUID().toString();\r
- private String type;\r
- private String thread;\r
- private Date timestamp = new Date();\r
private List<String> logLines = new ArrayList<String>();\r
\r
/** Empty constructor */\r
public SlcExecutionStep() {\r
- thread = Thread.currentThread().getName();\r
}\r
\r
/** Creates a step at the current date of type INFO */\r
\r
public SlcExecutionStep(Date timestamp, String type, String log,\r
String thread) {\r
- this.type = type;\r
- this.timestamp = timestamp;\r
- this.thread = thread;\r
- addLog(log);\r
+ super(timestamp, type, log, thread);\r
}\r
\r
public String getUuid() {\r
this.uuid = uuid;\r
}\r
\r
- public String getType() {\r
- return type;\r
- }\r
-\r
public void setType(String type) {\r
this.type = type;\r
}\r
\r
- public Date getTimestamp() {\r
- return timestamp;\r
- }\r
-\r
public void setTimestamp(Date begin) {\r
this.timestamp = begin;\r
}\r
\r
- public String getThread() {\r
- return thread;\r
- }\r
-\r
public void setThread(String thread) {\r
this.thread = thread;\r
}\r
this.logLines = logLines;\r
}\r
\r
- public void addLog(String log) {\r
+ protected String addLog(String log) {\r
+ if (logLines == null)\r
+ logLines = new ArrayList<String>();\r
+\r
if (log == null)\r
- return;\r
+ return null;\r
\r
StringTokenizer st = new StringTokenizer(log, "\n");\r
while (st.hasMoreTokens())\r
logLines.add(removeNonXmlChars(st.nextToken()));\r
+ return null;\r
}\r
\r
/**\r
import org.apache.log4j.spi.LoggingEvent;
import org.argeo.slc.core.execution.ExecutionThread;
import org.argeo.slc.core.execution.ProcessThreadGroup;
-import org.argeo.slc.process.SlcExecutionStep;
+import org.argeo.slc.execution.ExecutionStep;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
final String type;
if (event.getLevel().equals(Level.ERROR)
|| event.getLevel().equals(Level.FATAL))
- type = SlcExecutionStep.ERROR;
+ type = ExecutionStep.ERROR;
else if (event.getLevel().equals(Level.WARN))
- type = SlcExecutionStep.WARNING;
+ type = ExecutionStep.WARNING;
else if (event.getLevel().equals(Level.INFO))
- type = SlcExecutionStep.INFO;
+ type = ExecutionStep.INFO;
else if (event.getLevel().equals(Level.DEBUG))
- type = SlcExecutionStep.DEBUG;
+ type = ExecutionStep.DEBUG;
else if (event.getLevel().equals(Level.TRACE))
- type = SlcExecutionStep.TRACE;
+ type = ExecutionStep.TRACE;
else
- type = SlcExecutionStep.INFO;
+ type = ExecutionStep.INFO;
- SlcExecutionStep step = new SlcExecutionStep(new Date(event
- .getTimeStamp()), type, layout.format(event));
+ ExecutionStep step = new ExecutionStep(new Date(
+ event.getTimeStamp()), type, layout.format(event));
try {
dispatching.set(true);