Palladio Workflow Engine/Documentation/Integrated Workflows

Aus SDQ-Wiki
Wechseln zu: Navigation, Suche

Summary

The workflow engine provides infrastructure to integrate workflows with the Eclipse workbench ui. The necessary integration is provided by the plugin de.uka.ipd.sdq.workflow.workbench

Start Workflow by Mouse Listener

For example, you can write a jface-MouseAdapter to register on a button and react on a click event. You can implement other UI listeners or triggers as well. The jface implementation is just an example.

To realize the integration you need

  • An AbstractWorkflowDelegate implementation to create the workflow
  • A Listener triggering the delegate to create and run the workflow

Workflow Delegate

Implementing an AbstractWorkflowDelegate is an easy task if you know how to implement your workflow. Just extend the class and override you

public class MainWorkflowDelegate extends AbstractWorkbenchDelegate<MainWorkflowConfiguration , Workflow>{

	@Override
	protected IJob createWorkflowJob(MainWorkflowConfiguration config) {
		HelloWorldJob job = new HelloWorldJob("World");
		return new Workflow(job);
	}

	@Override
	protected MainWorkflowConfiguration getConfiguration() {
		return new MyWorkflowConfiguration();
	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
	}

	@Override
	protected boolean useSeparateConsoleForEachJobRun() {
		return false;
	}

}

The most important methods to override are getConfiguration() and createWorkflowJob(). getConfiguration() implements the logic how to get the required configuration parameters for your specific job configuration. You listener must know where to get the configuration information from. For example, it can be coupled with the UI to read from configuration fields or others. The listener can be regsitered to any selection changes and selectionChanged() can be used to react on any changes. useSeparateConsoleForEachJobRun() can be used to decide if the workflow should initialize a new Eclipse console with every run.

Button Listener

In Addition to the delegate you need a listener for example to react on a button click.

import org.eclipse.jface.action.Action;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

public class StartButtonListener extends MouseAdapter {

	@Override
	public void mouseUp(MouseEvent e) {
		super.mouseUp(e);
		MainWorkflowDelegate delegate = new MainWorkflowDelegate();
		Action action = new Action() {};
		delegate.run(action);
	}
}

Required Dependencies

Required Plugin dependencies:

  1. org.eclipse.jface
  2. de.uka.ipd.sdq.workflow
  3. de.uka.ipd.sdq.workflow.workbench


UI Interaction

It is strongly recommended to design your workflow without UI dependencies as much as possible. This allows you to run them in the background without freezing Eclipse for the user. Furthermore, this allows to still send some information to the console, which is not possible when the UI is blocked.

Old Documentation

The Workflow Engine supports defining workflows that can be launched inside an Eclipse workbench, but are not defined as Eclipse launch configurations.

This is a short guideline about how to create a workflow that is launched inside the workbench (but without a launch configuration)


The workflows also support log4j logging and print log statements to an Eclipse console.



To define such a workflow, do the following steps:

  • Specify an Eclipse plugin that has a dependency to the de.uka.ipd.sdq.workflow.workbench plugin
  • Inside the plugin, create a class X that inherits from de.uka.ipd.sdq.workflow.AbstractJobConfiguration
    • This class contains the configuration parameters which will be passed to the workflow engine job
  • Inside the plugin, create a class Y that inherits from de.uka.ipd.sdq.workflow.workbench.AbstractWorkbenchDelegate
    • This class has to be specified with two generic types
      • The first type is X
      • The second type is UIBasedWorkflow<Blackboard<...> or UIBasedWorkflow<MDSDBlackboard>
    • Besides, the class has to specify a workflow similar to a launchconfig-based workflow
    • The method createWorkflowJob() is used for specifying the workflow job to be executed.
    • The method useSeparateConsoleForEachJobRun() indicates whether a new console instance should be used for every workflow run, or a shared console should be reused.
    • The method getConfiguration() creates a configuration object. Compared to a launchconfig-based workflow, no eclipse-based launch configuration object is passed to this method, but the workflow has to provide own logic for retrieving and creating the configuration.
    • The method setupLogging(Level logLevel) specifies the list with logger information (similar to a launchconfig-based workflow)
    • If the workflow is to be started by specifying a UI action, the class Y has to implement the interface IWorkbenchWindowActionDelegate as well.
  • Create an action extension in the plugin's plugin.xml (org.eclipse.ui.actionSets).
    • This extension specified how the workflow is launched (for example by clicking a button).
    • In the class attribute, specify the class Y defined above that specifies the workflow.