提交 649b4cf8 编写于 作者: J jbarrez

ACT-221: renamed EventListener to ExecutionListener

上级 7d65eca4
......@@ -14,23 +14,23 @@
package org.activiti.engine.impl.bpmn;
import org.activiti.engine.impl.el.Expression;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
/**
* An {@link EventListener} that evaluates a {@link Expression} when notified.
* An {@link ExecutionListener} that evaluates a {@link Expression} when notified.
*
* @author Frederik Heremans
*/
public class ExpressionEventListener implements EventListener {
public class ExpressionExecutionListener implements ExecutionListener {
protected Expression expression;
public ExpressionEventListener(Expression expression) {
public ExpressionExecutionListener(Expression expression) {
this.expression = expression;
}
public void notify(EventListenerExecution execution) throws Exception {
public void notify(ExecutionListenerExecution execution) throws Exception {
// Return value of expression is ignored
expression.getValue(execution);
}
......
......@@ -17,14 +17,14 @@ import org.activiti.engine.delegate.JavaDelegation;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
/**
* @author Tom Baeyens
*/
public class JavaDelegationDelegate extends BpmnActivityBehavior implements ActivityBehavior, EventListener {
public class JavaDelegationDelegate extends BpmnActivityBehavior implements ActivityBehavior, ExecutionListener {
protected JavaDelegation javaDelegation;
......@@ -40,7 +40,7 @@ public class JavaDelegationDelegate extends BpmnActivityBehavior implements Acti
performDefaultOutgoingBehavior(execution);
}
public void notify(EventListenerExecution execution) throws Exception {
public void notify(ExecutionListenerExecution execution) throws Exception {
execute((DelegateExecution) execution);
}
......
......@@ -31,7 +31,7 @@ import org.activiti.engine.impl.bpmn.CallActivityBehaviour;
import org.activiti.engine.impl.bpmn.ClassStructure;
import org.activiti.engine.impl.bpmn.Condition;
import org.activiti.engine.impl.bpmn.ExclusiveGatewayActivity;
import org.activiti.engine.impl.bpmn.ExpressionEventListener;
import org.activiti.engine.impl.bpmn.ExpressionExecutionListener;
import org.activiti.engine.impl.bpmn.ExpressionTaskListener;
import org.activiti.engine.impl.bpmn.ItemDefinition;
import org.activiti.engine.impl.bpmn.ItemKind;
......@@ -64,7 +64,7 @@ import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -437,7 +437,7 @@ public class BpmnParse extends Parse {
parseEndEvents(scopeElement, parentScope);
parseBoundaryEvents(scopeElement, parentScope);
parseSequenceFlow(scopeElement, parentScope);
parseEventListenersOnScope(scopeElement, parentScope);
parseExecutionListenersOnScope(scopeElement, parentScope);
}
/**
......@@ -589,7 +589,7 @@ public class BpmnParse extends Parse {
ActivityImpl activity = parseAndCreateActivityOnScopeElement(exclusiveGwElement, scope);
activity.setActivityBehavior(new ExclusiveGatewayActivity());
parseEventListenersOnScope(exclusiveGwElement, activity);
parseExecutionListenersOnScope(exclusiveGwElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseExclusiveGateway(exclusiveGwElement, scope, activity);
......@@ -603,7 +603,7 @@ public class BpmnParse extends Parse {
ActivityImpl activity = parseAndCreateActivityOnScopeElement(parallelGwElement, scope);
activity.setActivityBehavior(new ParallelGatewayActivity());
parseEventListenersOnScope(parallelGwElement, activity);
parseExecutionListenersOnScope(parallelGwElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseParallelGateway(parallelGwElement, scope, activity);
......@@ -636,7 +636,7 @@ public class BpmnParse extends Parse {
activity.setActivityBehavior(new ScriptTaskActivity(script, language, resultVariableName));
parseEventListenersOnScope(scriptTaskElement, activity);
parseExecutionListenersOnScope(scriptTaskElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseScriptTask(scriptTaskElement, scope, activity);
......@@ -693,7 +693,7 @@ public class BpmnParse extends Parse {
addError("'class', 'type', or 'expression' attribute is mandatory on serviceTask", serviceTaskElement);
}
parseEventListenersOnScope(serviceTaskElement, activity);
parseExecutionListenersOnScope(serviceTaskElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseServiceTask(serviceTaskElement, scope, activity);
......@@ -833,7 +833,7 @@ public class BpmnParse extends Parse {
ActivityImpl activity = parseAndCreateActivityOnScopeElement(taskElement, scope);
activity.setActivityBehavior(new TaskActivity());
parseEventListenersOnScope(taskElement, activity);
parseExecutionListenersOnScope(taskElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseTask(taskElement, scope, activity);
......@@ -847,7 +847,7 @@ public class BpmnParse extends Parse {
ActivityImpl activity = parseAndCreateActivityOnScopeElement(manualTaskElement, scope);
activity.setActivityBehavior(new ManualTaskActivity());
parseEventListenersOnScope(manualTaskElement, activity);
parseExecutionListenersOnScope(manualTaskElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseManualTask(manualTaskElement, scope, activity);
......@@ -861,7 +861,7 @@ public class BpmnParse extends Parse {
ActivityImpl activity = parseAndCreateActivityOnScopeElement(receiveTaskElement, scope);
activity.setActivityBehavior(new ReceiveTaskActivity());
parseEventListenersOnScope(receiveTaskElement, activity);
parseExecutionListenersOnScope(receiveTaskElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseManualTask(receiveTaskElement, scope, activity);
......@@ -894,7 +894,7 @@ public class BpmnParse extends Parse {
activity.setActivityBehavior(userTaskActivity);
parseProperties(userTaskElement, activity);
parseEventListenersOnScope(userTaskElement, activity);
parseExecutionListenersOnScope(userTaskElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseUserTask(userTaskElement, scope, activity);
......@@ -1259,7 +1259,7 @@ public class BpmnParse extends Parse {
}
activity.setActivityBehavior(new CallActivityBehaviour(calledElement));
parseEventListenersOnScope(callActivityElement, activity);
parseExecutionListenersOnScope(callActivityElement, activity);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseCallActivity(callActivityElement, scope, activity);
......@@ -1406,7 +1406,7 @@ public class BpmnParse extends Parse {
transition.setProperty("documentation", parseDocumentation(sequenceFlowElement));
transition.setDestination(destinationActivity);
parseSequenceFlowConditionExpression(sequenceFlowElement, transition);
parseEventListenersOnTransition(sequenceFlowElement, transition);
parseExecutionListenersOnTransition(sequenceFlowElement, transition);
for (BpmnParseListener parseListener: parseListeners) {
parseListener.parseSequenceFlow(sequenceFlowElement, scope, transition);
......@@ -1445,21 +1445,21 @@ public class BpmnParse extends Parse {
}
/**
* Parses all event-listeners on a scope.
* Parses all execution-listeners on a scope.
*
* @param scopeElement the XML element containing the scope definition.
* @param scope the scope to add the event-listeners to.
* @param scope the scope to add the executionListeners to.
*/
public void parseEventListenersOnScope(Element scopeElement, ScopeImpl scope) {
public void parseExecutionListenersOnScope(Element scopeElement, ScopeImpl scope) {
Element extentionsElement = scopeElement.element("extensionElements");
if(extentionsElement != null) {
List<Element> listenerElements = extentionsElement.elementsNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "listener");
List<Element> listenerElements = extentionsElement.elementsNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "executionListener");
for(Element listenerElement :listenerElements) {
String eventName = listenerElement.attribute("eventName");
String eventName = listenerElement.attribute("event");
if(isValidEventNameForScope(eventName, listenerElement)) {
EventListener listener = parseEventListener(listenerElement);
ExecutionListener listener = parseExecutionListener(listenerElement);
if(listener != null) {
scope.addEventListener(eventName, listener);
scope.addExecutionListener(eventName, listener);
}
}
}
......@@ -1482,48 +1482,48 @@ public class BpmnParse extends Parse {
return false;
}
public void parseEventListenersOnTransition(Element activitiElement, TransitionImpl activity) {
public void parseExecutionListenersOnTransition(Element activitiElement, TransitionImpl activity) {
Element extentionsElement = activitiElement.element("extensionElements");
if(extentionsElement != null) {
List<Element> listenerElements = extentionsElement.elementsNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "listener");
List<Element> listenerElements = extentionsElement.elementsNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "executionListener");
for(Element listenerElement : listenerElements) {
EventListener listener = parseEventListener(listenerElement);
ExecutionListener listener = parseExecutionListener(listenerElement);
if(listener != null) {
// Since a transition only fires event 'take', we don't parse the eventName, it is ignored
activity.addEventListener(listener);
activity.addExecutionListener(listener);
}
}
}
}
/**
* Parses an {@link EventListener} implementation for the given event-listener element.
* Parses an {@link ExecutionListener} implementation for the given executionListener element.
*
* @param eventListenerElement the XML element containing the event-listener definition.
* @param executionListenerElement the XML element containing the executionListener definition.
*/
public EventListener parseEventListener(Element eventListenerElement) {
EventListener eventListener = null;
public ExecutionListener parseExecutionListener(Element executionListenerElement) {
ExecutionListener executionListener = null;
String className = eventListenerElement.attribute("class");
String expression = eventListenerElement.attribute( "expression");
String className = executionListenerElement.attribute("class");
String expression = executionListenerElement.attribute( "expression");
if(className != null && className.trim().length() > 0) {
Object delegateInstance = instantiateDelegate(className, parseFieldDeclarations(eventListenerElement));
if (delegateInstance instanceof EventListener) {
eventListener = (EventListener) delegateInstance;
Object delegateInstance = instantiateDelegate(className, parseFieldDeclarations(executionListenerElement));
if (delegateInstance instanceof ExecutionListener) {
executionListener = (ExecutionListener) delegateInstance;
} else if (delegateInstance instanceof JavaDelegation) {
eventListener = new JavaDelegationDelegate((JavaDelegation) delegateInstance);
executionListener = new JavaDelegationDelegate((JavaDelegation) delegateInstance);
} else {
addError(delegateInstance.getClass().getName()+" doesn't implement "+JavaDelegation.class.getName()+" nor "+EventListener.class.getName(), eventListenerElement);
addError(delegateInstance.getClass().getName()+" doesn't implement "+JavaDelegation.class.getName()+" nor "+ExecutionListener.class.getName(), executionListenerElement);
}
} else if(expression != null && expression.trim().length() > 0) {
eventListener = new ExpressionEventListener(expressionManager.createExpression(expression));
executionListener = new ExpressionExecutionListener(expressionManager.createExpression(expression));
} else {
addError("Element 'class' or 'expression' is mandatory on event-listener", eventListenerElement);
addError("Element 'class' or 'expression' is mandatory on executionListener", executionListenerElement);
}
return eventListener;
return executionListener;
}
/**
......
......@@ -23,8 +23,8 @@ import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.history.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.ClockUtil;
......@@ -32,9 +32,9 @@ import org.activiti.engine.impl.util.ClockUtil;
/**
* @author Tom Baeyens
*/
public class ActivityInstanceEndHandler implements EventListener {
public class ActivityInstanceEndHandler implements ExecutionListener {
public void notify(EventListenerExecution execution) {
public void notify(ExecutionListenerExecution execution) {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(executionEntity);
......
......@@ -16,8 +16,8 @@ package org.activiti.engine.impl.history.handler;
import org.activiti.engine.impl.cfg.IdGenerator;
import org.activiti.engine.impl.history.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.ClockUtil;
......@@ -25,7 +25,7 @@ import org.activiti.engine.impl.util.ClockUtil;
/**
* @author Tom Baeyens
*/
public class ActivityInstanceStartHandler implements EventListener {
public class ActivityInstanceStartHandler implements ExecutionListener {
protected String activityType;
......@@ -33,7 +33,7 @@ public class ActivityInstanceStartHandler implements EventListener {
this.activityType = activityType;
}
public void notify(EventListenerExecution execution) {
public void notify(ExecutionListenerExecution execution) {
CommandContext commandContext = CommandContext.getCurrent();
IdGenerator idGenerator = commandContext.getProcessEngineConfiguration().getIdGenerator();
......
......@@ -16,7 +16,7 @@ package org.activiti.engine.impl.history.handler;
import org.activiti.engine.impl.bpmn.UserTaskActivity;
import org.activiti.engine.impl.bpmn.parser.BpmnParseListener;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
......@@ -43,8 +43,8 @@ public class HistoryParseListener implements BpmnParseListener {
}
public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {
processDefinition.addEventListener(EventListener.EVENTNAME_START, new ProcessInstanceStartHandler());
processDefinition.addEventListener(EventListener.EVENTNAME_END, new ProcessInstanceEndHandler());
processDefinition.addExecutionListener(ExecutionListener.EVENTNAME_START, new ProcessInstanceStartHandler());
processDefinition.addExecutionListener(ExecutionListener.EVENTNAME_END, new ProcessInstanceEndHandler());
}
public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
......@@ -106,7 +106,7 @@ public class HistoryParseListener implements BpmnParseListener {
protected void addActivityHandlers(Element activityElement, ActivityImpl activity) {
String activityType = activityElement.getTagName();
activity.addEventListener(EventListener.EVENTNAME_START, new ActivityInstanceStartHandler(activityType));
activity.addEventListener(EventListener.EVENTNAME_END, new ActivityInstanceEndHandler());
activity.addExecutionListener(ExecutionListener.EVENTNAME_START, new ActivityInstanceStartHandler(activityType));
activity.addExecutionListener(ExecutionListener.EVENTNAME_END, new ActivityInstanceEndHandler());
}
}
......@@ -17,17 +17,17 @@ import java.util.Date;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
import org.activiti.engine.impl.util.ClockUtil;
/**
* @author Tom Baeyens
*/
public class ProcessInstanceEndHandler implements EventListener {
public class ProcessInstanceEndHandler implements ExecutionListener {
public void notify(EventListenerExecution execution) {
public void notify(ExecutionListenerExecution execution) {
HistoricProcessInstanceEntity historicProcessInstance = CommandContext
.getCurrent()
.getHistorySession()
......
......@@ -15,8 +15,8 @@ package org.activiti.engine.impl.history.handler;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.ClockUtil;
......@@ -24,9 +24,9 @@ import org.activiti.engine.impl.util.ClockUtil;
/**
* @author Tom Baeyens
*/
public class ProcessInstanceStartHandler implements EventListener {
public class ProcessInstanceStartHandler implements ExecutionListener {
public void notify(EventListenerExecution execution) {
public void notify(ExecutionListenerExecution execution) {
// ExecutionEntity executionEntity = (ExecutionEntity) execution;
// String processInstanceId = executionEntity.getId();
// String processDefinitionId = executionEntity.getProcessDefinitionId();
......
......@@ -18,7 +18,7 @@ import java.util.List;
import java.util.Stack;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
import org.activiti.engine.impl.pvm.process.ProcessElementImpl;
......@@ -134,18 +134,18 @@ public class ProcessDefinitionBuilder {
return this;
}
public ProcessDefinitionBuilder eventListener(EventListener eventListener) {
public ProcessDefinitionBuilder executionListener(ExecutionListener executionListener) {
if (transition!=null) {
transition.addEventListener(eventListener);
transition.addExecutionListener(executionListener);
} else {
throw new PvmException("not in a transition scope");
}
return this;
}
public ProcessDefinitionBuilder eventListener(String eventName, EventListener eventListener) {
public ProcessDefinitionBuilder executionListener(String eventName, ExecutionListener executionListener) {
if (transition==null) {
scopeStack.peek().addEventListener(eventName, eventListener);
scopeStack.peek().addExecutionListener(eventName, executionListener);
} else {
throw new PvmException("not in an activity- or process definition scope. (but in a transition scope)");
}
......
......@@ -15,12 +15,13 @@ package org.activiti.engine.impl.pvm.delegate;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public interface EventListener {
public interface ExecutionListener {
String EVENTNAME_START = "start";
String EVENTNAME_END = "end";
String EVENTNAME_TAKE = "take";
void notify(EventListenerExecution execution) throws Exception;
void notify(ExecutionListenerExecution execution) throws Exception;
}
......@@ -19,7 +19,7 @@ import org.activiti.engine.impl.pvm.PvmProcessElement;
/**
* @author Tom Baeyens
*/
public interface EventListenerExecution extends DelegateExecution {
public interface ExecutionListenerExecution extends DelegateExecution {
String getEventName();
......
......@@ -21,7 +21,7 @@ import java.util.Map;
import org.activiti.engine.impl.pvm.PvmException;
import org.activiti.engine.impl.pvm.PvmScope;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
/**
......@@ -33,7 +33,7 @@ public abstract class ScopeImpl extends ProcessElementImpl implements PvmScope {
protected List<ActivityImpl> activities = new ArrayList<ActivityImpl>();
protected Map<String, ActivityImpl> namedActivities = new HashMap<String, ActivityImpl>();
protected Map<String, List<EventListener>> eventListeners = new HashMap<String, List<EventListener>>();
protected Map<String, List<ExecutionListener>> executionListeners = new HashMap<String, List<ExecutionListener>>();
public ScopeImpl(String id, ProcessDefinitionImpl processDefinition) {
super(id, processDefinition);
......@@ -85,25 +85,25 @@ public abstract class ScopeImpl extends ProcessElementImpl implements PvmScope {
// event listeners //////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
public List<EventListener> getEventListeners(String eventName) {
List<EventListener> eventListenerList = getEventListeners().get(eventName);
if (eventListenerList!=null) {
return eventListenerList;
public List<ExecutionListener> getExecutionListeners(String eventName) {
List<ExecutionListener> executionListenerList = getExecutionListeners().get(eventName);
if (executionListenerList!=null) {
return executionListenerList;
}
return Collections.EMPTY_LIST;
}
public void addEventListener(String eventName, EventListener eventListener) {
List<EventListener> listeners = eventListeners.get(eventName);
public void addExecutionListener(String eventName, ExecutionListener executionListener) {
List<ExecutionListener> listeners = executionListeners.get(eventName);
if (listeners==null) {
listeners = new ArrayList<EventListener>();
eventListeners.put(eventName, listeners);
listeners = new ArrayList<ExecutionListener>();
executionListeners.put(eventName, listeners);
}
listeners.add(eventListener);
listeners.add(executionListener);
}
public Map<String, List<EventListener>> getEventListeners() {
return eventListeners;
public Map<String, List<ExecutionListener>> getExecutionListeners() {
return executionListeners;
}
// getters and setters //////////////////////////////////////////////////////
......
......@@ -18,7 +18,7 @@ import java.util.Collections;
import java.util.List;
import org.activiti.engine.impl.pvm.PvmTransition;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
......@@ -32,7 +32,7 @@ public class TransitionImpl extends ProcessElementImpl implements PvmTransition
protected ActivityImpl source;
protected ActivityImpl destination;
protected List<EventListener> eventListeners;
protected List<ExecutionListener> executionListeners;
public TransitionImpl(String id, ProcessDefinitionImpl processDefinition) {
super(id, processDefinition);
......@@ -47,11 +47,11 @@ public class TransitionImpl extends ProcessElementImpl implements PvmTransition
destination.getIncomingTransitions().add(this);
}
public void addEventListener(EventListener eventListener) {
if (eventListeners==null) {
eventListeners = new ArrayList<EventListener>();
public void addExecutionListener(ExecutionListener executionListener) {
if (executionListeners==null) {
executionListeners = new ArrayList<ExecutionListener>();
}
eventListeners.add(eventListener);
executionListeners.add(executionListener);
}
public String toString() {
......@@ -59,11 +59,11 @@ public class TransitionImpl extends ProcessElementImpl implements PvmTransition
}
@SuppressWarnings("unchecked")
public List<EventListener> getEventListeners() {
if (eventListeners==null) {
public List<ExecutionListener> getExecutionListeners() {
if (executionListeners==null) {
return Collections.EMPTY_LIST;
}
return eventListeners;
return executionListeners;
}
// getters and setters //////////////////////////////////////////////////////
......@@ -76,7 +76,7 @@ public class TransitionImpl extends ProcessElementImpl implements PvmTransition
return destination;
}
public void setEventListeners(List<EventListener> eventListeners) {
this.eventListeners = eventListeners;
public void setExecutionListeners(List<ExecutionListener> executionListeners) {
this.executionListeners = executionListeners;
}
}
......@@ -16,7 +16,7 @@ package org.activiti.engine.impl.pvm.runtime;
import java.util.List;
import org.activiti.engine.impl.pvm.PvmException;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -27,13 +27,13 @@ public abstract class AbstractEventAtomicOperation implements AtomicOperation {
public void execute(ExecutionImpl execution) {
ScopeImpl scope = getScope(execution);
List<EventListener> eventListeners = scope.getEventListeners(getEventName());
int eventListenerIndex = execution.getEventListenerIndex();
List<ExecutionListener> exectionListeners = scope.getExecutionListeners(getEventName());
int executionListenerIndex = execution.getExecutionListenerIndex();
if (eventListeners.size()>eventListenerIndex) {
if (exectionListeners.size()>executionListenerIndex) {
execution.setEventName(getEventName());
execution.setEventSource(scope);
EventListener listener = eventListeners.get(eventListenerIndex);
ExecutionListener listener = exectionListeners.get(executionListenerIndex);
try {
listener.notify(execution);
} catch (RuntimeException e) {
......@@ -41,11 +41,11 @@ public abstract class AbstractEventAtomicOperation implements AtomicOperation {
} catch (Exception e) {
throw new PvmException("couldn't execute event listener : "+e.getMessage(), e);
}
execution.setEventListenerIndex(eventListenerIndex+1);
execution.setExecutionListenerIndex(executionListenerIndex+1);
execution.performOperation(this);
} else {
execution.setEventListenerIndex(0);
execution.setExecutionListenerIndex(0);
execution.setEventName(null);
execution.setEventSource(null);
......
......@@ -15,7 +15,7 @@ package org.activiti.engine.impl.pvm.runtime;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.CompositeActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -32,7 +32,7 @@ public class AtomicOperationActivityEnd extends AbstractEventAtomicOperation {
@Override
protected String getEventName() {
return EventListener.EVENTNAME_END;
return ExecutionListener.EVENTNAME_END;
}
@Override
......
......@@ -13,7 +13,7 @@
package org.activiti.engine.impl.pvm.runtime;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -29,7 +29,7 @@ public class AtomicOperationActivityStart extends AbstractEventAtomicOperation {
@Override
protected String getEventName() {
return EventListener.EVENTNAME_START;
return ExecutionListener.EVENTNAME_START;
}
@Override
......
......@@ -13,7 +13,7 @@
package org.activiti.engine.impl.pvm.runtime;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -40,7 +40,7 @@ public class AtomicOperationDeleteCascadeFireActivityEnd extends AbstractEventAt
@Override
protected String getEventName() {
return EventListener.EVENTNAME_END;
return ExecutionListener.EVENTNAME_END;
}
@Override
......
......@@ -13,7 +13,7 @@
package org.activiti.engine.impl.pvm.runtime;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.SubProcessActivityBehavior;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -30,7 +30,7 @@ public class AtomicOperationProcessEnd extends AbstractEventAtomicOperation {
@Override
protected String getEventName() {
return EventListener.EVENTNAME_END;
return ExecutionListener.EVENTNAME_END;
}
@Override
......
......@@ -15,7 +15,7 @@ package org.activiti.engine.impl.pvm.runtime;
import java.util.List;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -33,7 +33,7 @@ public class AtomicOperationProcessStart extends AbstractEventAtomicOperation {
@Override
protected String getEventName() {
return EventListener.EVENTNAME_START;
return ExecutionListener.EVENTNAME_START;
}
@Override
......
......@@ -15,7 +15,7 @@ package org.activiti.engine.impl.pvm.runtime;
import java.util.List;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -33,7 +33,7 @@ public class AtomicOperationProcessStartInitial extends AbstractEventAtomicOpera
@Override
protected String getEventName() {
return EventListener.EVENTNAME_START;
return ExecutionListener.EVENTNAME_START;
}
@Override
......
......@@ -12,7 +12,7 @@
*/
package org.activiti.engine.impl.pvm.runtime;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -28,7 +28,7 @@ public class AtomicOperationTransitionNotifyListenerEnd extends AbstractEventAto
@Override
protected String getEventName() {
return EventListener.EVENTNAME_END;
return ExecutionListener.EVENTNAME_END;
}
@Override
......
......@@ -12,7 +12,7 @@
*/
package org.activiti.engine.impl.pvm.runtime;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
......@@ -30,7 +30,7 @@ public class AtomicOperationTransitionNotifyListenerStart extends AbstractEventA
@Override
protected String getEventName() {
return EventListener.EVENTNAME_START;
return ExecutionListener.EVENTNAME_START;
}
@Override
......
......@@ -16,7 +16,7 @@ import java.util.List;
import java.util.logging.Logger;
import org.activiti.engine.impl.pvm.PvmException;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
......@@ -32,13 +32,13 @@ public class AtomicOperationTransitionNotifyListenerTake implements AtomicOperat
public void execute(ExecutionImpl execution) {
TransitionImpl transition = execution.getTransition();
List<EventListener> eventListeners = transition.getEventListeners();
int eventListenerIndex = execution.getEventListenerIndex();
List<ExecutionListener> executionListeners = transition.getExecutionListeners();
int executionListenerIndex = execution.getExecutionListenerIndex();
if (eventListeners.size()>eventListenerIndex) {
execution.setEventName(EventListener.EVENTNAME_TAKE);
if (executionListeners.size()>executionListenerIndex) {
execution.setEventName(ExecutionListener.EVENTNAME_TAKE);
execution.setEventSource(transition);
EventListener listener = eventListeners.get(eventListenerIndex);
ExecutionListener listener = executionListeners.get(executionListenerIndex);
try {
listener.notify(execution);
} catch (RuntimeException e) {
......@@ -46,12 +46,12 @@ public class AtomicOperationTransitionNotifyListenerTake implements AtomicOperat
} catch (Exception e) {
throw new PvmException("couldn't execute event listener : "+e.getMessage(), e);
}
execution.setEventListenerIndex(eventListenerIndex+1);
execution.setExecutionListenerIndex(executionListenerIndex+1);
execution.performOperation(this);
} else {
log.fine(execution+" takes transition "+transition);
execution.setEventListenerIndex(0);
execution.setExecutionListenerIndex(0);
execution.setEventName(null);
execution.setEventSource(null);
......
......@@ -28,7 +28,7 @@ import org.activiti.engine.impl.pvm.PvmProcessElement;
import org.activiti.engine.impl.pvm.PvmProcessInstance;
import org.activiti.engine.impl.pvm.PvmTransition;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
import org.activiti.engine.impl.pvm.delegate.SignallableActivityBehavior;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
......@@ -41,7 +41,7 @@ import org.activiti.engine.impl.pvm.process.TransitionImpl;
public class ExecutionImpl implements
Serializable,
ActivityExecution,
EventListenerExecution,
ExecutionListenerExecution,
PvmProcessInstance,
PvmExecution {
......@@ -96,7 +96,7 @@ public class ExecutionImpl implements
protected String eventName;
protected PvmProcessElement eventSource;
protected int eventListenerIndex = 0;
protected int executionListenerIndex = 0;
// cascade deletion ////////////////////////////////////////////////////////
......@@ -653,11 +653,11 @@ public class ExecutionImpl implements
public void setTransition(TransitionImpl transition) {
this.transition = transition;
}
public Integer getEventListenerIndex() {
return eventListenerIndex;
public Integer getExecutionListenerIndex() {
return executionListenerIndex;
}
public void setEventListenerIndex(Integer eventListenerIndex) {
this.eventListenerIndex = eventListenerIndex;
public void setExecutionListenerIndex(Integer executionListenerIndex) {
this.executionListenerIndex = executionListenerIndex;
}
public boolean isConcurrent() {
return isConcurrent;
......
......@@ -244,6 +244,10 @@ public class TaskEntity implements Task, DelegateTask, Serializable, PersistentO
List<TaskListener> taskEventListeners = getTaskDefinition().getTaskListener(taskEventName);
if (taskEventListeners != null) {
for (TaskListener taskListener : taskEventListeners) {
ExecutionEntity execution = getExecution();
if (execution != null) {
execution.setEventName(taskEventName);
}
taskListener.notify(this);
}
}
......
......@@ -17,20 +17,20 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
/**
* @author Tom Baeyens
*/
public class EventCollector implements EventListener {
public class EventCollector implements ExecutionListener {
private static Logger log = Logger.getLogger(EventCollector.class.getName());
public List<String> events = new ArrayList<String>();
public void notify(EventListenerExecution execution) {
public void notify(ExecutionListenerExecution execution) {
log.fine("collecting event: "+execution.getEventName()+" on "+execution.getEventSource());
events.add(execution.getEventName()+" on "+execution.getEventSource());
}
......
......@@ -20,7 +20,7 @@ import org.activiti.engine.impl.pvm.ProcessDefinitionBuilder;
import org.activiti.engine.impl.pvm.PvmExecution;
import org.activiti.engine.impl.pvm.PvmProcessDefinition;
import org.activiti.engine.impl.pvm.PvmProcessInstance;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.test.PvmTestCase;
import org.activiti.engine.test.pvm.activities.Automatic;
import org.activiti.engine.test.pvm.activities.EmbeddedSubProcess;
......@@ -43,21 +43,21 @@ public class PvmEventTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("events")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.startTransition("end")
.eventListener(eventCollector)
.executionListener(eventCollector)
.endTransition()
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......@@ -91,28 +91,28 @@ public class PvmEventTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("events")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.startTransition("wait")
.eventListener(eventCollector)
.executionListener(eventCollector)
.endTransition()
.endActivity()
.createActivity("outerscope")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("innerscope")
.scope()
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("wait")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.endActivity()
......@@ -157,37 +157,37 @@ public class PvmEventTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("events")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("embeddedsubprocess")
.endActivity()
.createActivity("embeddedsubprocess")
.scope()
.behavior(new EmbeddedSubProcess())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("startInside")
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("endInside")
.endActivity()
.createActivity("endInside")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.transition("end")
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......@@ -228,44 +228,44 @@ public class PvmEventTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("events")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("fork")
.endActivity()
.createActivity("fork")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("c1")
.transition("c2")
.endActivity()
.createActivity("c1")
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("c2")
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("join")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......
......@@ -16,7 +16,7 @@ package org.activiti.engine.test.pvm;
import org.activiti.engine.impl.pvm.ProcessDefinitionBuilder;
import org.activiti.engine.impl.pvm.PvmProcessDefinition;
import org.activiti.engine.impl.pvm.PvmProcessInstance;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.test.PvmTestCase;
import org.activiti.engine.test.pvm.activities.Automatic;
import org.activiti.engine.test.pvm.activities.WaitState;
......@@ -31,8 +31,8 @@ public class PvmProcessInstanceEndTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
......@@ -40,8 +40,8 @@ public class PvmProcessInstanceEndTest extends PvmTestCase {
.endActivity()
.createActivity("wait")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......
......@@ -20,7 +20,7 @@ import org.activiti.engine.impl.pvm.ProcessDefinitionBuilder;
import org.activiti.engine.impl.pvm.PvmExecution;
import org.activiti.engine.impl.pvm.PvmProcessDefinition;
import org.activiti.engine.impl.pvm.PvmProcessInstance;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.test.PvmTestCase;
import org.activiti.engine.test.pvm.activities.Automatic;
import org.activiti.engine.test.pvm.activities.End;
......@@ -54,51 +54,51 @@ public class PvmScopeAndEventsTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and events")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("mostOuterNestedActivity")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("outerScope")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("firstInnerScope")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("firstMostInnerNestedActivity")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("waitInFirst")
.endActivity()
.createActivity("waitInFirst")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("waitInSecond")
.endActivity()
.endActivity()
.endActivity()
.createActivity("secondInnerScope")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("secondMostInnerNestedActivity")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("waitInSecond")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.endActivity()
.endActivity()
......
......@@ -21,7 +21,7 @@ import org.activiti.engine.impl.pvm.PvmException;
import org.activiti.engine.impl.pvm.PvmExecution;
import org.activiti.engine.impl.pvm.PvmProcessDefinition;
import org.activiti.engine.impl.pvm.PvmProcessInstance;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.test.PvmTestCase;
import org.activiti.engine.test.pvm.activities.Automatic;
import org.activiti.engine.test.pvm.activities.End;
......@@ -151,48 +151,48 @@ public class PvmScopesAndConcurrencyTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and concurrency")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("fork")
.endActivity()
.createActivity("fork")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("c1")
.transition("c2")
.endActivity()
.createActivity("noscope")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("c1")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("c2")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.endActivity()
.createActivity("join")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......@@ -260,49 +260,49 @@ public class PvmScopesAndConcurrencyTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and concurrency")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("fork")
.endActivity()
.createActivity("fork")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("c1")
.transition("c2")
.endActivity()
.createActivity("scope")
.scope()
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("c1")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("c2")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.endActivity()
.createActivity("join")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......@@ -370,49 +370,49 @@ public class PvmScopesAndConcurrencyTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and concurrency")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("fork")
.endActivity()
.createActivity("scope")
.scope()
.createActivity("fork")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("c1")
.transition("c2")
.endActivity()
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("c1")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("c2")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.endActivity()
.createActivity("join")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......@@ -479,49 +479,49 @@ public class PvmScopesAndConcurrencyTest extends PvmTestCase {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and concurrency")
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("start")
.initial()
.behavior(new Automatic())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("fork")
.endActivity()
.createActivity("fork")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("c1")
.transition("c2")
.endActivity()
.createActivity("scope")
.scope()
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.createActivity("c1")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("c2")
.behavior(new WaitState())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("join")
.endActivity()
.createActivity("join")
.behavior(new ParallelGateway())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.transition("end")
.endActivity()
.endActivity()
.createActivity("end")
.behavior(new End())
.eventListener(EventListener.EVENTNAME_START, eventCollector)
.eventListener(EventListener.EVENTNAME_END, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_START, eventCollector)
.executionListener(ExecutionListener.EVENTNAME_END, eventCollector)
.endActivity()
.buildProcessDefinition();
......
......@@ -11,20 +11,20 @@
* limitations under the License.
*/
package org.activiti.examples.bpmn.eventlistener;
package org.activiti.examples.bpmn.executionlistener;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
/**
* Simple {@link EventListener} that sets 2 variables on the execution.
* Simple {@link ExecutionListener} that sets 2 variables on the execution.
*
* @author Frederik Heremans
*/
public class ExampleEventListenerTwo implements EventListener {
public class ExampleExecutionListenerOne implements ExecutionListener {
public void notify(EventListenerExecution execution) throws Exception {
execution.setVariable("variableSetInEventListener", "secondValue");
public void notify(ExecutionListenerExecution execution) throws Exception {
execution.setVariable("variableSetInExecutionListener", "firstValue");
execution.setVariable("eventNameReceived", execution.getEventName());
}
}
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.examples.bpmn.eventlistener;
package org.activiti.examples.bpmn.executionlistener;
import java.io.Serializable;
......@@ -20,7 +20,7 @@ import java.io.Serializable;
*
* @author Frederik Heremans
*/
public class ExampleEventListenerPojo implements Serializable {
public class ExampleExecutionListenerPojo implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -11,20 +11,20 @@
* limitations under the License.
*/
package org.activiti.examples.bpmn.eventlistener;
package org.activiti.examples.bpmn.executionlistener;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
/**
* Simple {@link EventListener} that sets 2 variables on the execution.
* Simple {@link ExecutionListener} that sets 2 variables on the execution.
*
* @author Frederik Heremans
*/
public class ExampleEventListenerOne implements EventListener {
public class ExampleExecutionListenerTwo implements ExecutionListener {
public void notify(EventListenerExecution execution) throws Exception {
execution.setVariable("variableSetInEventListener", "firstValue");
public void notify(ExecutionListenerExecution execution) throws Exception {
execution.setVariable("variableSetInExecutionListener", "secondValue");
execution.setVariable("eventNameReceived", execution.getEventName());
}
}
......@@ -11,24 +11,24 @@
* limitations under the License.
*/
package org.activiti.examples.bpmn.eventlistener;
package org.activiti.examples.bpmn.executionlistener;
import org.activiti.engine.impl.el.Expression;
import org.activiti.engine.impl.pvm.delegate.EventListener;
import org.activiti.engine.impl.pvm.delegate.EventListenerExecution;
import org.activiti.engine.impl.pvm.delegate.ExecutionListener;
import org.activiti.engine.impl.pvm.delegate.ExecutionListenerExecution;
/**
* Example {@link EventListener} which gets 2 fields injected.
* Example {@link ExecutionListener} which gets 2 fields injected.
*
* @author Frederik Heremans
*/
public class ExampleFieldInjectedEventListener implements EventListener {
public class ExampleFieldInjectedExecutionListener implements ExecutionListener {
private Expression fixedValue;
private Expression dynamicValue;
public void notify(EventListenerExecution execution) throws Exception {
public void notify(ExecutionListenerExecution execution) throws Exception {
execution.setVariable("var", fixedValue.getValue(execution).toString() + dynamicValue.getValue(execution).toString());
}
}
......@@ -11,7 +11,7 @@
* limitations under the License.
*/
package org.activiti.examples.bpmn.eventlistener;
package org.activiti.examples.bpmn.executionlistener;
import java.util.HashMap;
import java.util.Map;
......@@ -24,45 +24,45 @@ import org.activiti.engine.test.Deployment;
/**
* @author Frederik Heremans
*/
public class EventListenerTest extends ActivitiInternalTestCase {
public class ExecutionListenerTest extends ActivitiInternalTestCase {
@Deployment(resources = {"org/activiti/examples/bpmn/eventlistener/EventListenersProcess.bpmn20.xml"})
public void testEventListenersOnAllPossibleElements() {
@Deployment(resources = {"org/activiti/examples/bpmn/executionlistener/ExecutionListenersProcess.bpmn20.xml"})
public void testExecutionListenersOnAllPossibleElements() {
// Process start event-listener will have event-listener class that sets 2 variables
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("eventListenersProcess");
// Process start executionListener will have executionListener class that sets 2 variables
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionListenersProcess");
String varSetInEventListener = (String) runtimeService.getVariable(processInstance.getId(), "variableSetInEventListener");
String varSetInExecutionListener = (String) runtimeService.getVariable(processInstance.getId(), "variableSetInExecutionListener");
String eventNameReceived = (String) runtimeService.getVariable(processInstance.getId(), "eventNameReceived");
assertNotNull(varSetInEventListener);
assertEquals("firstValue", varSetInEventListener);
assertNotNull(varSetInExecutionListener);
assertEquals("firstValue", varSetInExecutionListener);
assertNotNull(eventNameReceived);
assertEquals("start", eventNameReceived);
// Transition take event-listener will set 2 variables
// Transition take executionListener will set 2 variables
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
taskService.complete(task.getId());
varSetInEventListener = (String) runtimeService.getVariable(processInstance.getId(), "variableSetInEventListener");
varSetInExecutionListener = (String) runtimeService.getVariable(processInstance.getId(), "variableSetInExecutionListener");
eventNameReceived = (String) runtimeService.getVariable(processInstance.getId(), "eventNameReceived");
assertNotNull(varSetInEventListener);
assertEquals("secondValue", varSetInEventListener);
assertNotNull(varSetInExecutionListener);
assertEquals("secondValue", varSetInExecutionListener);
assertNotNull(eventNameReceived);
assertEquals("take", eventNameReceived);
ExampleEventListenerPojo myPojo = new ExampleEventListenerPojo();
ExampleExecutionListenerPojo myPojo = new ExampleExecutionListenerPojo();
runtimeService.setVariable(processInstance.getId(), "myPojo", myPojo);
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
taskService.complete(task.getId());
// First usertask uses a method-expression as event-listener: ${myPojo.myMethod(execution.eventName)}
ExampleEventListenerPojo pojoVariable = (ExampleEventListenerPojo) runtimeService.getVariable(processInstance.getId(), "myPojo");
// First usertask uses a method-expression as executionListener: ${myPojo.myMethod(execution.eventName)}
ExampleExecutionListenerPojo pojoVariable = (ExampleExecutionListenerPojo) runtimeService.getVariable(processInstance.getId(), "myPojo");
assertNotNull(pojoVariable.getReceivedEventName());
assertEquals("end", pojoVariable.getReceivedEventName());
......@@ -73,12 +73,12 @@ public class EventListenerTest extends ActivitiInternalTestCase {
assertProcessEnded(processInstance.getId());
}
@Deployment(resources = {"org/activiti/examples/bpmn/eventlistener/EventListenersFieldInjectionProcess.bpmn20.xml"})
public void testEventListenerFieldInjection() {
@Deployment(resources = {"org/activiti/examples/bpmn/executionlistener/ExecutionListenersFieldInjectionProcess.bpmn20.xml"})
public void testExecutionListenerFieldInjection() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("myVar", "listening!");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("eventListenersProcess", variables);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionListenersProcess", variables);
Object varSetByListener = runtimeService.getVariable(processInstance.getId(), "var");
assertNotNull(varSetByListener);
......
......@@ -3,12 +3,12 @@
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples">
<process id="eventListenersProcess">
<process id="executionListenersProcess">
<extensionElements>
<activiti:listener class="org.activiti.examples.bpmn.eventlistener.ExampleFieldInjectedEventListener" eventName="start">
<activiti:executionListener class="org.activiti.examples.bpmn.executionlistener.ExampleFieldInjectedExecutionListener" event="start">
<activiti:field name="fixedValue" stringValue="Yes, I am " />
<activiti:field name="dynamicValue" expression="${myVar}" />
</activiti:listener>
</activiti:executionListener>
</extensionElements>
<startEvent id="theStart" />
......
......@@ -3,10 +3,10 @@
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples">
<process id="eventListenersProcess">
<process id="executionListenersProcess">
<extensionElements>
<activiti:listener class="org.activiti.examples.bpmn.eventlistener.ExampleEventListenerOne" eventName="start" />
<activiti:executionListener class="org.activiti.examples.bpmn.executionlistener.ExampleExecutionListenerOne" event="start" />
</extensionElements>
<startEvent id="theStart" />
......@@ -16,13 +16,13 @@
<userTask id="firstTask" />
<sequenceFlow sourceRef="firstTask" targetRef="secondTask">
<extensionElements>
<activiti:listener class="org.activiti.examples.bpmn.eventlistener.ExampleEventListenerTwo" />
<activiti:executionListener class="org.activiti.examples.bpmn.executionlistener.ExampleExecutionListenerTwo" />
</extensionElements>
</sequenceFlow>
<userTask id="secondTask" >
<extensionElements>
<activiti:listener expression="${myPojo.myMethod(execution.eventName)}" eventName="end" />
<activiti:executionListener expression="${myPojo.myMethod(execution.eventName)}" event="end" />
</extensionElements>
</userTask>
<sequenceFlow sourceRef="secondTask" targetRef="thirdTask" />
......
......@@ -215,7 +215,7 @@ assertNotNull(activityInstance);</programlisting>
the EE6 specification</ulink> for detailed information). To support all features of latest UEL spec on ALL environements, we use a modified version of JUEL.
</para>
<para>
Expressions can be used in for example <link linkend="bpmnJavaServiceTaskXML">Java Service tasks</link>, <link linkend="eventListeners">Event Listeners</link> and <link linkend="conditionalSequenceFlowXml">Conditional sequence flows</link>.
Expressions can be used in for example <link linkend="bpmnJavaServiceTaskXML">Java Service tasks</link>, <link linkend="executionListeners">Event Listeners</link> and <link linkend="conditionalSequenceFlowXml">Conditional sequence flows</link>.
Although there are 2 types of expressions, value-expression and method-expression, activiti makes abstraction of this and they can both be used where an <literal>expression</literal> is needed.
<itemizedlist>
<listitem>
......@@ -242,7 +242,7 @@ ${myBean.doSomething(myVar, execution)}
Note that these expressions support resolving primitives (incl. comparing them), beans, lists, arrays and maps.
</para>
<para>
For more concrete usage and examples, check out <link linkend="springExpressions">Expressions in Spring</link>, <link linkend="bpmnJavaServiceTaskXML">Java Service tasks</link>, <link linkend="eventListeners">Event Listeners</link> or <link linkend="conditionalSequenceFlowXml">Conditional sequence flows</link>.
For more concrete usage and examples, check out <link linkend="springExpressions">Expressions in Spring</link>, <link linkend="bpmnJavaServiceTaskXML">Java Service tasks</link>, <link linkend="executionListeners">Event Listeners</link> or <link linkend="conditionalSequenceFlowXml">Conditional sequence flows</link>.
</para>
</section>
......
......@@ -1686,22 +1686,23 @@ public class ReverseStringsFieldInjected implements JavaDelegation {
<section id="eventListeners">
<title>Event listeners</title>
<para>Event listeners allow you to execute external Java code or evaluate an expression when certain events occur. The events that can be captured are:
<itemizedlist>
<listitem><para>Start and ending of a process instance.</para></listitem>
<listitem><para>Taking a transition.</para></listitem>
<listitem><para>Start and ending of an activity.</para></listitem>
</itemizedlist>
</para>
<para>
The following process definition contains 3 event-listeners:
<programlisting>
&lt;process id=&quot;eventListenersProcess&quot;&gt;
<section id="executionListeners">
<title>Execution listeners</title>
<para>Execution listeners allow you to execute external Java code or evaluate an expression when certain events occur
during process exevcution. The events that can be captured are:
<itemizedlist>
<listitem><para>Start and ending of a process instance.</para></listitem>
<listitem><para>Taking a transition.</para></listitem>
<listitem><para>Start and ending of an activity.</para></listitem>
</itemizedlist>
</para>
<para>
The following process definition contains 3 execution listenerss:
<programlisting>
&lt;process id=&quot;executionListenersProcess&quot;&gt;
<emphasis role="bold">&lt;extensionElements&gt;
&lt;activiti:listener class=&quot;org.activiti.examples.bpmn.eventlistener.ExampleEventListenerOne&quot; eventName=&quot;start&quot; /&gt;
&lt;activiti:executionListener class=&quot;org.activiti.examples.bpmn.executionlistener.ExampleExecutionListenerOne&quot; event=&quot;start&quot; /&gt;
&lt;/extensionElements&gt;</emphasis>
&lt;startEvent id=&quot;theStart&quot; /&gt;
......@@ -1709,15 +1710,15 @@ public class ReverseStringsFieldInjected implements JavaDelegation {
&lt;userTask id=&quot;firstTask&quot; /&gt;
&lt;sequenceFlow sourceRef=&quot;firstTask&quot; targetRef=&quot;secondTask&quot;&gt;
<emphasis role="bold">&lt;extensionElements&gt;
&lt;activiti:listener class=&quot;org.activiti.examples.bpmn.eventlistener.ExampleEventListenerTwo&quot; /&gt;
&lt;/extensionElements&gt;</emphasis>
<emphasis role="bold">&lt;extensionElements&gt;
&lt;activiti:executionListener class=&quot;org.activiti.examples.bpmn.executionListener.ExampleExecutionListenerTwo&quot; /&gt;
&lt;/extensionElements&gt;</emphasis>
&lt;/sequenceFlow&gt;
&lt;userTask id=&quot;secondTask&quot; &gt;
<emphasis role="bold">&lt;extensionElements&gt;
&lt;activiti:listener expression=&quot;${myPojo.myMethod(execution.eventName)}&quot; eventName=&quot;end&quot; /&gt;
&lt;/extensionElements&gt;</emphasis>
<emphasis role="bold">&lt;extensionElements&gt;
&lt;activiti:executionListener expression=&quot;${myPojo.myMethod(execution.event)}&quot; event=&quot;end&quot; /&gt;
&lt;/extensionElements&gt;</emphasis>
&lt;/userTask&gt;
&lt;sequenceFlow sourceRef=&quot;secondTask&quot; targetRef=&quot;thirdTask&quot; /&gt;
......@@ -1728,50 +1729,52 @@ public class ReverseStringsFieldInjected implements JavaDelegation {
&lt;/process&gt;</programlisting>
</para>
<para>The first event-listener is notified when the process starts. The listener is an external Java-class (like <literal>ExampleEventListenerOne</literal>)
and should implement <literal>org.activiti.engine.delegate.JavaDelegation</literal>. When the event occurs (in this case <literal>end</literal> event)
the method <literal>notify(EventListenerExecution execution)</literal> is called.
<para>The first execution listener is notified when the process starts. The listener is an external Java-class (like <literal>ExampleExecutionListenerOne</literal>)
and should implement <literal>org.activiti.engine.impl.pvm.delegate.ExecutionListener</literal>. When the event occurs (in this case <literal>end</literal> event)
the method <literal>notify(ExecutionListenerExecution execution)</literal> is called.
<programlisting>
public class ExampleEventListenerOne implements <emphasis role="bold">JavaDelegation</emphasis> {
public class ExampleExecutionListenerOne implements <emphasis role="bold">ExecutionListener</emphasis> {
<emphasis role="bold">public void notify(DelegateExecution execution) throws Exception {</emphasis>
execution.setVariable("variableSetInEventListener", "firstValue");
execution.setVariable("eventNameReceived", execution.getEventName());
execution.setVariable("variableSetInExecutionListener", "firstValue");
execution.setVariable("eventReceived", execution.getevent());
}
}</programlisting>
It is also possible to use a delegation class that implements the <literal>org.activiti.engine.delegate.JavaDelegation</literal>
interface. These delegation classes can then be reused in other constructs, such as a delegation for a serviceTask.
</para>
<para>
The second event-listener is called when the transition is taken. Note that the <literal>listener</literal> element doesn't define an
<literal>eventName</literal>, since only <literal>take</literal> events are fired on transitions.
<emphasis role="bold">Values in the <literal>eventName</literal> attribute are ignored when a listener is defined on a transition.</emphasis>
The second execution listener is called when the transition is taken. Note that the <literal>listener</literal> element doesn't define an
<literal>event</literal>, since only <literal>take</literal> events are fired on transitions.
<emphasis role="bold">Values in the <literal>event</literal> attribute are ignored when a listener is defined on a transition.</emphasis>
</para>
<para>
The last eventlistener is called when activity <literal>secondTask</literal> ends. Instead of using the <literal>class</literal> on the listener declaration,
The last execution listener is called when activity <literal>secondTask</literal> ends. Instead of using the <literal>class</literal> on the listener declaration,
a <literal>expression</literal> is defined instead which is evaluated/invoked when the event is fired.
</para>
<programlisting>
&lt;activiti:listener expression=&quot;<emphasis role="bold">${myPojo.myMethod(execution.eventName)}</emphasis>&quot; eventName=&quot;end&quot; /&gt;</programlisting>
&lt;activiti:executionListener expression=&quot;<emphasis role="bold">${myPojo.myMethod(execution.eventName)}</emphasis>&quot; event=&quot;end&quot; /&gt;</programlisting>
<para>
As with other expressions, execution variables are resolved and can be used. Because the execution implementation object has a property that exposes the event name, it's
possible to pass the event-name to your methods using <literal>execution.eventName</literal>.
</para>
<section id="eventListenerFieldInjection">
<section id="executionListenerFieldInjection">
<title>Field injection on event listeners</title>
<para>
When using an eventlistener that is configured with the <literal>class</literal> attribute, field injection can be applied. This is exactly the same
When using an executionListener that is configured with the <literal>class</literal> attribute, field injection can be applied. This is exactly the same
mechanism as used <link linkend="serviceTaskFieldInjection">Service task field injection</link>, which contains an overview of the possibilities provided by field injection.
</para>
<para>
The fragment below shows a simple example process with an event-listener with fields injected.
The fragment below shows a simple example process with an execution listener with fields injected.
<programlisting>
&lt;process id=&quot;eventListenersProcess&quot;&gt;
&lt;process id=&quot;executionListenersProcess&quot;&gt;
<emphasis role="bold">&lt;extensionElements&gt;
&lt;activiti:listener class=&quot;org.activiti.examples.bpmn.eventlistener.ExampleFieldInjectedEventListener&quot; eventName=&quot;start&quot;&gt;
&lt;activiti:executionListener class=&quot;org.activiti.examples.bpmn.executionListener.ExampleFieldInjectedExecutionListener&quot; event=&quot;start&quot;&gt;
&lt;activiti:field name=&quot;fixedValue&quot; stringValue=&quot;Yes, I am &quot; /&gt;
&lt;activiti:field name=&quot;dynamicValue&quot; expression=&quot;${myVar}&quot; /&gt;
&lt;/activiti:listener&gt;
&lt;/activiti:executionListener&gt;
&lt;/extensionElements&gt;</emphasis>
&lt;startEvent id=&quot;theStart&quot; /&gt;
......@@ -1786,27 +1789,27 @@ public class ExampleEventListenerOne implements <emphasis role="bold">JavaDelega
</para>
<para>
<programlisting>
public class ExampleFieldInjectedEventListener implements EventListener {
public class ExampleFieldInjectedExecutionListener implements ExecutionListener {
<emphasis role="bold">private Expression fixedValue;
private Expression dynamicValue;</emphasis>
public void notify(EventListenerExecution execution) throws Exception {
public void notify(ExecutionListenerExecution execution) throws Exception {
execution.setVariable("var", <emphasis role="bold">fixedValue.getValue(execution).toString()</emphasis> + <emphasis role="bold">dynamicValue.getValue(execution).toString()</emphasis>);
}
}
</programlisting>
The class <literal>ExampleFieldInjectedEventListener</literal> concatenates the 2 injected fields (one fixed an the other dynamic) and stores this in the process variable '<literal>var</literal>'.
The class <literal>ExampleFieldInjectedExecutionListener</literal> concatenates the 2 injected fields (one fixed an the other dynamic) and stores this in the process variable '<literal>var</literal>'.
</para>
<para>
<programlisting>
@Deployment(resources = {"org/activiti/examples/bpmn/eventlistener/EventListenersFieldInjectionProcess.bpmn20.xml"})
public void testEventListenerFieldInjection() {
@Deployment(resources = {"org/activiti/examples/bpmn/executionListener/ExecutionListenersFieldInjectionProcess.bpmn20.xml"})
public void testExecutionListenerFieldInjection() {
Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
<emphasis role="bold">variables.put("myVar", "listening!");</emphasis>
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("eventListenersProcess", variables);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionListenersProcess", variables);
Object varSetByListener = runtimeService.getVariable(processInstance.getId(), "var");
assertNotNull(varSetByListener);
......@@ -1820,7 +1823,7 @@ public void testEventListenerFieldInjection() {
</section>
</section>
<section id="bpmnEmailTask">
<section id="bpmnEmailTask">
<title>Email task</title>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册