10-26-2012 08:37 PM
10-29-2012 06:55 AM
<process id="executionListenersProcess">
<extensionElements>
<activiti:executionListener class="org.activiti.examples.RecordProcessFinishedListener" event="end" />
</extensionElements>
10-29-2012 01:16 PM
class JenkowEngine{
static ProcessEngine getEngine(){
if (engine == null){
…
ClassLoader peCL = JenkowEngine.class.getClassLoader();
Thread.currentThread().setContextClassLoader(peCL);
ProcessEngineConfigurationImpl peCfg = (ProcessEngineConfigurationImpl)cfg;
List<BpmnParseListener> preParseListeners = peCfg.getPreParseListeners();
if (preParseListeners == null){
preParseListeners = new ArrayList<BpmnParseListener>();
peCfg.setPreParseListeners(preParseListeners);
}
preParseListeners.add(new JenkowBpmnParseListener());
cfg.setClassLoader(peCL);
engine = cfg.buildProcessEngine();
}
return engine;
}
}
A new method adds the execution listener:
class JenkowBpmnParseListener extends AbstractBpmnParseListener{
…
@Override
public void parseProcess(Element el, ProcessDefinitionEntity processDefinition) {
processDefinition.addExecutionListener("end",new ProcessExecLogger(el.attribute("id")));
}
}
The execution listener itself is the easy part.
public class ProcessExecLogger implements ExecutionListener{
private String name;
ProcessExecLogger(String name) {
this.name = name;
}
@Override
public void notify(DelegateExecution exec) throws Exception {
System.out.println("name = "+name);
System.out.println("exec.getEventName() -> "+exec.getEventName());
System.out.println("exec.getId() -> "+exec.getId());
System.out.println("exec.getProcessBusinessKey() -> "+exec.getProcessBusinessKey());
System.out.println("exec.getProcessInstanceId() -> "+exec.getProcessInstanceId());
}
}
It works, but does this make sense?10-30-2012 02:23 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.