WorkflowEventListener

A WorkflowEventListener listens to events during the execution of a workflow. This mechanism is used in the Results Perspective of Taverna 1.7.x Workbench to monitor the state of an execution.

A new listener to events during the execution of a workflow can be added to Taverna 1.7.x by a class that implements the org.embl.ebi.escience.scufl.enactor.WorkflowEventListener interface or extends the org.embl.ebi.escience.scufl.enactor.WorkflowEventAdapter class. If the listener directly implements org.embl.ebi.escience.scufl.enactor.WorkflowEventListener then the name of the new class must be specified within a org.embl.ebi.escience.scufl.enactor.WorkflowEventListener file within the appropriate resources/META-INF/services directory.

Example

nl.utwente.ewi.hmi.taverna.scuflworkers.rshell.RshellConnectionManager extends the org.embl.ebi.escience.scufl.enactor.WorkflowEventAdapter class.

public class RshellConnectionManager extends WorkflowEventAdapter {
	public static final RshellConnectionManager INSTANCE =
	new RshellConnectionManager();

	private HashMap settingsToConnectionsMap;

	private int numberOfWorkflowInstances;

	private RshellConnectionManager() {
		settingsToConnectionsMap = new HashMap();
		numberOfWorkflowInstances = 0;
	}

	/**
	 *
	 */
	public void workflowCreated(WorkflowCreationEvent e) {
		numberOfWorkflowInstances++;
	}

	/**
	 * Method which is called when a workflow is completed
	 */
	public void workflowCompleted(WorkflowCompletionEvent e) {
		assert (numberOfWorkflowInstances > 0);

		if (–numberOfWorkflowInstances == 0)
			releaseConnections();
	}
        ...
}