Palladio Workflow Engine/Documentation/Job Types

Aus SDQ-Wiki

The workflow engine provides different types of jobs one could either derive from implement his own job or instantiate to compose a set of jobs to be executed sequentially or in parallel.

Job Type Overview

The class diagram below provides an overview on the available job types.

Job-structure.png

Job Types

Job Types to derive From

The following job types are provided to derive custom jobs from with different capabilities.

AbstractJob

The AbstractJob is a basic job providing logging capabilities. A field named "logger" is provided to all subclasses. Using this logger (e.g. calling "logger.info(...);") is automatically printed to the console of the currently active Eclipse instance.

AbstractBlackboardInteractingJob<BlackboardType>

The AbstractBlackboardInteractingJob is the base class for implementing a custom job that makes use of a blackboard to share data with other jobs. Details about using a blackboard within a custom job are described by the Blackboard Concept section.

Composite Jobs

Job types provided to compose and execute a set of jobs. These types of jobs are inteded to be directly instantiated and to be filled with the set of jobs to be executed.

AbstractCompositeJob

An abstract job composing and executing a set of subjobs. It derives the access to a logger from the regular AbstractJob and provides it to sub types as well. It is the base type for all more specific composite jobs described below.

SequentialJob

The sequential composite job executes the composed jobs one after each other.

The default behaviour is to execute a job, call its clean up method and dispose it from the job list before the next job in the sequence is executed. The reason for this is to free object references and resources as soon as possible.
This behaviour can be changed to keep all jobs in the list and call the cleanup methods of all jobs when they all have been finished. To activate this behaviour, the alternative constructor accepting a boolean flag should be called with false as parameter:

 new SequentialJob(false);

SequentialBlackboardInteractingJob<BlackboardType>

This is a composed job executing the jobs in sequential order and injecting a reference to a blackboard to those jobs, if they are able to work with a blackboard.
As the regular sequential job type, a SequentialBlackboardInteractingJob provides an additional constructor to change its behaviour to not immediately cleanup and dispose each job before starting the next one.
Details about using a blackboard within a custom job are described by the Blackboard Concept section.

ParallelJob

A ParallelJob is a composed job executing a set of jobs in parallel. They are started as separate threads. The most important difference to Eclipse task model is, that the execution of the enclosing ParallelJob is not finished until all parallel sub jobs have finished. This represents a joint point in the workflow.

ParallelBlackboardInteractingJob<BlackboardType>

This is a composed job executing the jobs in parallel and injecting a reference to a blackboard to them, if they are able to work with a blackboard.
Details about using a blackboard within a custom job are described by the Blackboard Concept section.

Blackboard Concept

Jobs are encapsulated units of process execution. A workflow is set up and executed at ones afterwards. It is not inteded - and not recommended - to create hard coded references between jobs. This would prevent distribution of jobs and flexibile job combination. However, the Palladio Workflow Engine implements a Blackboard Concept to store and read data.

Blackboard-structure.png

As shown in the class diagram above, jobs implementing the IBlackboardInteractingJob interface reference a typed blackboard. The Palladio Workflow Engine provides a default blackboard implementation. This blackboard itself is typed and contains a map to store objects of this type linked with a key.

To implement a custom blackboard, reference a typed blackboard from you custom job or the composite job you are setting up. The listing below defines a custom job working with a blackboard that stores String values.

 public class MyJob implements IBlackboardInteractingJob<Blackboard<Object>> {
 
   /** The blackboard the job can interact with. **/
   private Blackboard<Object> blackboard = null;
 
   /**
    * Setting the bloack the job can share data with other jobs.
    */
   @override
   public setBlackboard(Blackboard<Object> blackboard){
     this.blackboard = blackboard;
   }
 
   /**
    * Executes all contained jobs. Depending on the jobs configuration, the
    * execution cleans up immediately or when all jobs are done.
    * 
    * @param monitor
    *            the monitor
    * @throws JobFailedException
    *             the job failed exception
    * @throws UserCanceledException
    *             the user canceled exception
    */
   @Override
   public void execute(IProgressMonitor monitor) throws JobFailedException,
   		UserCanceledException {
   	// get the object registered for the key from the blackboard
   	Object myObject = this.blackboard.getPartition("key");
   }
 }