Skip to main content

Notice: This Wiki is now read only and edits are no longer 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"

Line 14: Line 14:
  
 
* The class name must be registered in META-INF/MANIFEST.MF of the providing bundle using the header name "*EILF-Pipelets*". Then they can be detected by the SimplePipeletTracker service. Multiple classes can be registered separeted by comma.
 
* The class name must be registered in META-INF/MANIFEST.MF of the providing bundle using the header name "*EILF-Pipelets*". Then they can be detected by the SimplePipeletTracker service. Multiple classes can be registered separeted by comma.
 +
 +
 +
== Configuration ==
 +
 +
This step is optional if your Pipelet does not need a configuration.
 +
 +
* add a PipeletConfiguration to the extensionActivity of your Pipelet in the BPEL pipeline
 +
  
  
Line 51: Line 59:
 
...
 
...
 
</pre>
 
</pre>
 +
 +
 +
This is a sample how a Pipelet is invoked in a BPEL pipeline using an extensionActivity. It also shows how the Pipelet is configured using a PipeletConfiguration.
 +
 +
<source lang="xml">
 +
...
 +
<extensionActivity name="invokeMyPipelet">
 +
    <proc:invokePipelet>
 +
        <proc:pipelet class="org.eclipse.eilf.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>
 +
...
 +
</source>
  
 
[[Category:SMILA]]
 
[[Category:SMILA]]

Revision as of 04:00, 25 September 2008

What are Pipelets

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


Implementation

  • Create a class that implements interface org.eclipse.eilf.processing.SimplePipelet.
  • The class must have 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 completness and store the settings in seperate memeber 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.
  • The class name must be registered in META-INF/MANIFEST.MF of the providing bundle using the header name "*EILF-Pipelets*". Then they can be detected by the SimplePipeletTracker service. Multiple classes can be registered separeted by comma.


Configuration

This step is optional if your Pipelet does not need a configuration.

  • add a PipeletConfiguration to the extensionActivity of your Pipelet in the BPEL pipeline


Example

This is a template for MyPipelet.java

package org.eclipse.eilf.mypackage

import org.eclipse.eilf.blackboard.BlackboardService;
import org.eclipse.eilf.datamodel.id.Id;
import org.eclipse.eilf.processing.ProcessingException;
import org.eclipse.eilf.processing.SimplePipelet;
import org.eclipse.eilf.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 manifest MANIFEST.MF:

...
EILF-Pipelets: org.eclipse.eilf.mypackage.MyPipelet
...


This is a sample how a Pipelet is invoked in a 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.eilf.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