Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SMILA/Documentation/HowTo/How to write a Pipelet"

(Add link to main integration page)
(General review on content and style)
Line 18: Line 18:
 
== Configuration ==
 
== Configuration ==
  
This step is optional if your pipelet does not need a configuration.
+
If your pipelet requires a configuration:
  
* Add a <tt>&lt;PipeletConfiguration&gt;</tt> to the <tt>&lt;extensionActivity&gt;</tt> of your pipelet in the BPEL pipeline.
+
* Add a <tt>&lt;PipeletConfiguration&gt;</tt> element to the <tt>&lt;extensionActivity&gt;</tt> section of your pipelet in the BPEL pipeline.
  
 
== Example ==
 
== Example ==

Revision as of 04:02, 30 September 2008

This page describes how to implement and configure your own pipelet in case you wish to add functionality to SMILA.

What are pipelets?

Pipelets are not standalone services, but their lifecycle and configuration is managed by the workflow engine. In contrast to processing services they are not shared by multiple workflows, that is, each occurrence of a pipelet in a workflow uses a different pipelet instance.

Implementation

Follow these instructions to implement a pipelet in SMILA:

  • Create a class that implements the interface org.eclipse.smila.processing.SimplePipelet and make sure that the class has a public no-argument constructor.
  • Implement void configure(PipeletConfiguration configuration). This method is called prior to process. Here you can read the PipeletConfiguration provided for the pipelet in the pipeline. To share those properties either store the whole PipeletConfiguration in a member variable or better check the PipeletConfiguration for validity and completeness and store the settings in separate member variables.
  • Implement Id[] process(BlackboardService blackboard, Id[] recordIds). Here you have to place the "business logic" of your pipelet. In most cases the result is the same as the input recordIDs, so just return it. But it is possible to return another list of IDs as result.
  • Register your class in META-INF/MANIFEST.MF of the providing bundle using the header name "*SMILA-Pipelets*". Then they can be detected by the SimplePipeletTracker service. If you would like to register multiple classes, separate them with commas.
  • Consider thread-safeness. As pipelets may be accessed by multiple threads make sure that the access to the member variables (e.g. the configuration) is read-only. For best practices use local variables instead of member variables if possible.

Configuration

If your pipelet requires a configuration:

  • Add a <PipeletConfiguration> element to the <extensionActivity> section of your pipelet in the BPEL pipeline.

Example

This is a template for MyPipelet.java:

package org.eclipse.smila.mypackage

import org.eclipse.smila.blackboard.BlackboardService;
import org.eclipse.smila.datamodel.id.Id;
import org.eclipse.smila.processing.ProcessingException;
import org.eclipse.smila.processing.SimplePipelet;
import org.eclipse.smila.processing.configuration.PipeletConfiguration;
 
public class MyPipelet implements SimplePipelet {
 
  public MyPipelet(){
  }
 
  public void configure(PipeletConfiguration configuration) throws ProcessingException {
    // read the configuration properties
  }
 
  public Id[] process(BlackboardService blackboard, Id[] recordIds) throws ProcessingException {
    // process the recordIds and create a result
  }
}

And this is how to register the pipelet class in the bundle's manifest MANIFEST.MF:

...
SMILA-Pipelets: org.eclipse.smila.mypackage.MyPipelet
...

And finally, this is a sample showing how a pipelet is invoked in the BPEL pipeline using an <extensionActivity>. It also shows how the pipelet is configured using a <PipeletConfiguration>.

...
<extensionActivity name="invokeMyPipelet">
    <proc:invokePipelet>
        <proc:pipelet class="org.eclipse.smila.mypackage.MyPipelet" />
        <proc:variables input="request" output="result" />
        <proc:PipeletConfiguration>
            <proc:Property name="aStringParam">
                <proc:Value>some value</proc:Value>
            </proc:Property>
            <proc:Property name="aDateParam" type="java.util.Date">
                <proc:Value>2008-06-11 16:08:00</proc:Value>
            </proc:Property>
        </proc:PipeletConfiguration>       
    </proc:invokePipelet>
</extensionActivity>
...

Back to the top