blob: 32aaef07ac1bc96e7b123b6abae7ef73d3b83b51 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="SMILA/Documentation/HowTo/How to write a Pipelet,SMILA/BPEL Designer,SMILA/Documentation/ParameterDefinition,SMILA/Documentation/Pipelets,SMILA/Glossary,SMILA/Howto integrate a component in SMILA" />
<link rel="shortcut icon" href="http://wiki.eclipse.org/SMILA/Documentation/HowTo/favicon.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="http://wiki.eclipse.org/opensearch_desc.php" title="Eclipsepedia (English)" />
<link rel="alternate" type="application/rss+xml" title="Eclipsepedia RSS Feed" href="http://wiki.eclipse.org/index.php?title=Special:Recentchanges&amp;feed=rss" />
<link rel="alternate" type="application/atom+xml" title="Eclipsepedia Atom Feed" href="http://wiki.eclipse.org/index.php?title=Special:Recentchanges&amp;feed=atom" />
<title>SMILA/Documentation/HowTo/How to write a Pipelet - Eclipsepedia</title>
<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "http://wiki.eclipse.org/skins/eclipsenova/novaWide.css?116"; /*]]>*/</style>
<link rel="stylesheet" type="text/css" media="print" href="http://wiki.eclipse.org/skins/eclipsenova/eclipsenovaPrint.css?116" />
<link rel="stylesheet" type="text/css" media="handheld" href="http://wiki.eclipse.org/skins/eclipsenova/handheld.css?116" />
<link rel="stylesheet" type="text/css" href="http://wiki.eclipse.org/skins/eclipsenova/Nova/css/header.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://wiki.eclipse.org/skins/eclipsenova/tabs.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://wiki.eclipse.org/skins/eclipsenova/Nova/css/visual.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://wiki.eclipse.org/skins/eclipsenova/Nova/css/layout.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://wiki.eclipse.org/skins/eclipsenova/Nova/css/footer.css" media="screen" />
<!--[if IE]><link rel="stylesheet" type="text/css" href="/skins/eclipsenova/IEpngfix.css" media="screen" /><![endif]-->
<!--[if lt IE 5.5000]><style type="text/css">@import "/skins/eclipsenova/IE50Fixes.css?116";</style> <![endif]-->
<!--[if IE 5.5000]><style type="text/css">@import "/skins/eclipsenova/IE55Fixes.css?116";</style><![endif]-->
<!--[if IE 6]><style type="text/css">@import "/skins/eclipsenova/IE60Fixes.css?116";</style><![endif]-->
<!--[if IE 7]><style type="text/css">@import "/skins/eclipsenova/IE70Fixes.css?116";</style><![endif]-->
<!--[if lt IE 7]><script type="text/javascript" src="/skins/common/IEFixes.js?116"></script>
<meta http-equiv="imagetoolbar" content="no" /><![endif]-->
<script type= "text/javascript">/*<![CDATA[*/
var skin = "eclipsenova";
var stylepath = "/skins";
var wgArticlePath = "/$1";
var wgScriptPath = "";
var wgScript = "/index.php";
var wgServer = "http://wiki.eclipse.org";
var wgCanonicalNamespace = "";
var wgCanonicalSpecialPageName = false;
var wgNamespaceNumber = 0;
var wgPageName = "SMILA/Documentation/HowTo/How_to_write_a_Pipelet";
var wgTitle = "SMILA/Documentation/HowTo/How to write a Pipelet";
var wgAction = "view";
var wgRestrictionEdit = [];
var wgRestrictionMove = [];
var wgArticleId = "15195";
var wgIsArticle = true;
var wgUserName = null;
var wgUserGroups = null;
var wgUserLanguage = "en";
var wgContentLanguage = "en";
var wgBreakFrames = false;
var wgCurRevisionId = "293404";
var wgVersion = "1.12.0";
var wgEnableAPI = true;
var wgEnableWriteAPI = false;
/*]]>*/</script>
<script type="text/javascript" src="http://wiki.eclipse.org/skins/common/wikibits.js?116"><!-- wikibits js --></script>
<!-- Performance mods similar to those for bug 166401 -->
<script type="text/javascript" src="http://wiki.eclipse.org/index.php?title=-&amp;action=raw&amp;gen=js&amp;useskin=eclipsenova"><!-- site js --></script>
<!-- Head Scripts -->
<script type="text/javascript" src="http://wiki.eclipse.org/skins/common/ajax.js?116"></script>
<style type="text/css">/*<![CDATA[*/
.source-java {line-height: normal; font-size: medium;}
.source-java li {line-height: normal;}
/**
* GeSHi Dynamically Generated Stylesheet
* --------------------------------------
* Dynamically generated stylesheet for java
* CSS class: source-java, CSS id:
* GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter)
*/
.source-java .de1, .source-java .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;}
.source-java {}
.source-java .head {}
.source-java .foot {}
.source-java .imp {font-weight: bold; color: red;}
.source-java .ln-xtra {color: #cc0; background-color: #ffc;}
.source-java li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;}
.source-java li.li2 {font-weight: bold;}
.source-java .kw1 {color: #7F0055; font-weight: bold;}
.source-java .kw2 {color: #7F0055; font-weight: bold;}
.source-java .kw3 {color: #000000; font-weight: normal}
.source-java .kw4 {color: #7F0055; font-weight: bold;}
.source-java .co1 {color: #3F7F5F; font-style: italic;}
.source-java .co2 {color: #3F7F5F;}
.source-java .co3 {color: #3F7F5F; font-style: italic; font-weight: bold;}
.source-java .coMULTI {color: #3F5FBF; font-style: italic;}
.source-java .es0 {color: #000000;}
.source-java .br0 {color: #000000;}
.source-java .st0 {color: #2A00ff;}
.source-java .nu0 {color: #000000;}
.source-java .me1 {color: #000000;}
.source-java .me2 {color: #000000;}
/*]]>*/
</style>
<style type="text/css">/*<![CDATA[*/
@import "http://wiki.eclipse.org/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-xml {line-height: normal; font-size: medium;}
.source-xml li {line-height: normal;}
/**
* GeSHi Dynamically Generated Stylesheet
* --------------------------------------
* Dynamically generated stylesheet for xml
* CSS class: source-xml, CSS id:
* GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter)
*/
.source-xml .de1, .source-xml .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;}
.source-xml {}
.source-xml .head {}
.source-xml .foot {}
.source-xml .imp {font-weight: bold; color: red;}
.source-xml .ln-xtra {color: #cc0; background-color: #ffc;}
.source-xml li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;}
.source-xml li.li2 {font-weight: bold;}
.source-xml .coMULTI {color: #808080; font-style: italic;}
.source-xml .es0 {color: #000099; font-weight: bold;}
.source-xml .br0 {color: #66cc66;}
.source-xml .st0 {color: #ff0000;}
.source-xml .nu0 {color: #cc66cc;}
.source-xml .sc0 {color: #00bbdd;}
.source-xml .sc1 {color: #ddbb00;}
.source-xml .sc2 {color: #339933;}
.source-xml .sc3 {color: #009900;}
.source-xml .re0 {color: #000066;}
.source-xml .re1 {font-weight: bold; color: black;}
.source-xml .re2 {font-weight: bold; color: black;}
/*]]>*/
</style>
<style type="text/css">/*<![CDATA[*/
@import "http://wiki.eclipse.org/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
/*]]>*/
</style><link rel="stylesheet" type="text/css" href="How_to_write_a_Pipelet.html" /> </head>
<body class="mediawiki ns-0 ltr page-SMILA_Documentation_HowTo_How_to_write_a_Pipelet">
<div id="globalWrapper">
<div id="column-one">
<!-- Eclipse Additions for the Top Nav start here M. Ward-->
<div id="header">
<div id="header-graphic">
<img src="http://wiki.eclipse.org/skins/eclipsenova/eclipse.png" alt="Eclipse Wiki">
</div>
<!-- Pulled 101409 Mward -->
<div class="portlet" id="p-personal">
<div class="pBody">
<ul>
<li id="pt-login"><a href="http://wiki.eclipse.org/index.php?title=Special:Userlogin&amp;returnto=SMILA/Documentation/HowTo/How_to_write_a_Pipelet">Log in</a></li>
</ul>
</div>
</div>
<div id="header-icons">
<div id="sites">
<ul id="sitesUL">
<li><a href="http://www.eclipse.org"><img src="http://dev.eclipse.org/custom_icons/eclipseIcon.png" width="28" height="28" alt="Eclipse Foundation" title="Eclipse Foundation" /><div>Eclipse Foundation</div></a></li>
<li><a href="http://marketplace.eclipse.org"><img src="http://dev.eclipse.org/custom_icons/marketplace.png" width="28" height="28" alt="Eclipse Marketplace" title="Eclipse Marketplace" /><div>Eclipse Marketplace</div></a></li>
<li><a href="https://bugs.eclipse.org/bugs"><img src="http://dev.eclipse.org/custom_icons/system-search-bw.png" width="28" height="28" alt="Bugzilla" title="Bugzilla" /><div>Bugzilla</div></a></li>
<li><a href="http://live.eclipse.org"><img src="http://dev.eclipse.org/custom_icons/audio-input-microphone-bw.png" width="28" height="28" alt="Live" title="Live" /><div>Eclipse Live</div></a></li>
<li><a href="http://planeteclipse.org"><img src="http://dev.eclipse.org/large_icons/devices/audio-card.png" width="28" height="28" alt="PlanetEclipse" title="Planet" /><div>Planet Eclipse</div></a></li>
<li><a href="http://portal.eclipse.org"><img src="http://dev.eclipse.org/custom_icons/preferences-system-network-proxy-bw.png" width="28" height="28" alt="Portal" title="Portal" /><div>My Foundation Portal</div></a></li>
</ul>
</div>
</div>
</div>
<!-- NEW HEADER STUFF HERE -->
<div id="header-menu">
<div id="header-nav">
<ul> <li><a class="first_one" href="http://wiki.eclipse.org/" target="_self">Home</a></li> <li><a href="http://www.eclipse.org/downloads/" target="_self">Downloads</a></li>
<li><a href="http://www.eclipse.org/users/" target="_self">Users</a></li>
<li><a href="http://www.eclipse.org/membership/" target="_self">Members</a></li>
<li><a href="http://wiki.eclipse.org/index.php/Development_Resources" target="_self">Committers</a></li>
<li><a href="http://www.eclipse.org/resources/" target="_self">Resources</a></li>
<li><a href="http://www.eclipse.org/projects/" target="_self">Projects</a></li>
<li><a href="http://www.eclipse.org/org/" target="_self">About Us</a></li>
</ul>
</div>
<div id="header-utils">
<!-- moved the search window here -->
<form action="http://wiki.eclipse.org/Special:Search" >
<input class="input" name="search" type="text" accesskey="f" value="" />
<input type='submit' onclick="this.submit();" name="go" id="searchGoButton" class="button" title="Go to a page with this exact name if one exists" value="Go" />&nbsp;
<input type='submit' onclick="this.submit();" name="fulltext" class="button" id="mw-searchButton" title="Search Eclipsepedia for this text" value="Search" />
</form>
</div>
</div>
<!-- Eclipse Additions for the Header stop here -->
<!-- Additions and mods for leftside nav Start here -->
<!--Started nav rip here-->
<!-- these are the nav controls main page, changes etc -->
<div id="novaContent" class="faux">
<div id="leftcol">
<ul id="leftnav">
<!-- these are the page controls, edit history etc -->
<li class="separator"><a class="separator">Navigation &#160;&#160;</li>
<li id="n-mainpage"><a href="http://wiki.eclipse.org/Main_Page">Main Page</a></li>
<li id="n-portal"><a href="http://wiki.eclipse.org/Eclipsepedia:Community_Portal">Community portal</a></li>
<li id="n-currentevents"><a href="http://wiki.eclipse.org/Eclipsepedia:Current_events">Current events</a></li>
<li id="n-recentchanges"><a href="http://wiki.eclipse.org/Special:Recentchanges">Recent changes</a></li>
<li id="n-randompage"><a href="http://wiki.eclipse.org/Special:Random">Random page</a></li>
<li id="n-help"><a href="http://wiki.eclipse.org/Help:Contents">Help</a></li>
<li class="separator"><a class="separator">Toolbox &#160;&#160;</a></li>
<li id="t-whatlinkshere"><a href="http://wiki.eclipse.org/Special:Whatlinkshere/SMILA/Documentation/HowTo/How_to_write_a_Pipelet">What links here</a></li>
<li id="t-recentchangeslinked"><a href="http://wiki.eclipse.org/Special:Recentchangeslinked/SMILA/Documentation/HowTo/How_to_write_a_Pipelet">Related changes</a></li>
<!-- This is the toolbox section -->
<li id="t-upload"><a href="http://wiki.eclipse.org/Special:Upload">Upload file</a></li>
<li id="t-specialpages"><a href="http://wiki.eclipse.org/Special:Specialpages">Special pages</a></li>
<li id="t-print"><a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Pipelet&amp;printable=yes">Printable version</a></li> <li id="t-permalink"><a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Pipelet&amp;oldid=293404">Permanent link</a></li> </ul>
</div>
<!-- Additions and mods for leftside nav End here -->
<div id="column-content">
<div id="content">
<a name="top" id="top"></a>
<div id="tabs">
<ul class="primary">
<li class="active"><a href="How_to_write_a_Pipelet.html"><span class="tab">Page</span></a></li>
<li><a href="http://wiki.eclipse.org/index.php?title=Talk:SMILA/Documentation/HowTo/How_to_write_a_Pipelet&amp;action=edit"><span class="tab">Discussion</span></a></li>
<li><a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Pipelet&amp;action=edit"><span class="tab">View source</span></a></li>
<li><a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Pipelet&amp;action=history"><span class="tab">History</span></a></li>
<li><a href="http://wiki.eclipse.org/index.php?title=Special:Userlogin&amp;returnto=SMILA/Documentation/HowTo/How&#32;to&#32;write&#32;a&#32;Pipelet"><span class="tab">Edit</span></a></li>
</ul>
</div>
<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
<h1 class="firstHeading">SMILA/Documentation/HowTo/How to write a Pipelet</h1>
<div id="bodyContent">
<h3 id="siteSub">From Eclipsepedia</h3>
<div id="contentSub"><span class="subpages">&lt; <a href="../../../SMILA.html" title="SMILA">SMILA</a> | <a href="../../Documentation.1.html" title="SMILA/Documentation">Documentation</a> | <a href="../HowTo.html" title="SMILA/Documentation/HowTo">HowTo</a></span></div>
<div id="jump-to-nav">Jump to: <a href="How_to_write_a_Pipelet.html#column-one">navigation</a>, <a href="How_to_write_a_Pipelet.html#searchInput">search</a></div> <!-- start content -->
<p>This page describes how to implement and configure your own <a href="../../Glossary.html#P" title="SMILA/Glossary">pipelet</a> in case you wish to <a href="../../Howto_integrate_a_component_in_SMILA.html" class="mw-redirect" title="SMILA/Howto integrate a component in SMILA">add functionality</a> to SMILA.
</p>
<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="How_to_write_a_Pipelet.html#What_are_pipelets.3F"><span class="tocnumber">1</span> <span class="toctext">What are pipelets?</span></a></li>
<li class="toclevel-1"><a href="How_to_write_a_Pipelet.html#Implementation"><span class="tocnumber">2</span> <span class="toctext">Implementation</span></a>
<ul>
<li class="toclevel-2"><a href="How_to_write_a_Pipelet.html#Further_reading"><span class="tocnumber">2.1</span> <span class="toctext">Further reading</span></a></li>
</ul>
</li>
<li class="toclevel-1"><a href="How_to_write_a_Pipelet.html#Configuration"><span class="tocnumber">3</span> <span class="toctext">Configuration</span></a></li>
<li class="toclevel-1"><a href="How_to_write_a_Pipelet.html#Examples"><span class="tocnumber">4</span> <span class="toctext">Examples</span></a>
<ul>
<li class="toclevel-2"><a href="How_to_write_a_Pipelet.html#Pipelet_Usage"><span class="tocnumber">4.1</span> <span class="toctext">Pipelet Usage</span></a></li>
<li class="toclevel-2"><a href="How_to_write_a_Pipelet.html#Piplet_configuration_usage"><span class="tocnumber">4.2</span> <span class="toctext">Piplet configuration usage</span></a></li>
</ul>
</li>
</ul>
</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
<a name="What_are_pipelets.3F"></a><h2> <span class="mw-headline"> What are pipelets? </span></h2>
<p>Pipelets are not standalone services, but their lifecycle and configuration is managed by the workflow engine. Each occurrence of a pipelet in a workflow uses a different pipelet instance. For more information take a look at <a href="../Pipelets.html" title="SMILA/Documentation/Pipelets">Pipelets</a>.
</p><p><b>Before writing your own pipelet we recommend you to take a look at the </b><a href="https://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/examples/org.eclipse.smila.integration.pipelet/code/src/org/eclipse/smila/integration/pipelet/HelloWorldPipelet.java" class="external text" title="https://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/examples/org.eclipse.smila.integration.pipelet/code/src/org/eclipse/smila/integration/pipelet/HelloWorldPipelet.java" rel="nofollow">HelloWorldPipelet.java</a>. This pipelet is an example of a very simple processing pipelet and can be used as a template for your pipelets. You can also get it by exporting the <a href="http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/examples" class="external text" title="http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/examples" rel="nofollow">example bundles</a> from SMILA's repository and import it into your SMILA workspace and use them as templates:
</p>
<ul><li> <a href="http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/examples/org.eclipse.smila.integration.pipelet" class="external text" title="http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/examples/org.eclipse.smila.integration.pipelet" rel="nofollow">org.eclipse.smila.integration.pipelet</a>: template bundle for pipelet development
</li></ul>
<p>You can also download these examples from the <a href="http://www.eclipse.org/smila/downloads.php" class="external text" title="http://www.eclipse.org/smila/downloads.php" rel="nofollow">release downloads</a> or the <a href="http://build.eclipse.org/rt/smila/nightly/" class="external text" title="http://build.eclipse.org/rt/smila/nightly/" rel="nofollow">nightly build downloads</a>.
</p>
<a name="Implementation"></a><h2> <span class="mw-headline"> Implementation </span></h2>
<p>Follow these instructions to implement a pipelet in SMILA:
</p>
<ul><li> If needed, create a new plugin project. You can add multiple pipelets to a single project. See <a href="../../Development_Guidelines.1.html#Creation_of_bundles" class="external text" title="http://wiki.eclipse.org/SMILA/Development_Guidelines#Creation_of_bundles" rel="nofollow">Development Guidelines: Bundle creation</a> for details.
</li></ul>
<ul><li> In the MANIFEST.MF, add at least these as "Imported Packages" (of course, you will need more to develop your pipelet, depending on what you want to do):
<ul><li> <tt>org.eclipse.smila.blackboard</tt>
</li><li> <tt>org.eclipse.smila.datamodel</tt>
</li><li> <tt>org.eclipse.smila.processing</tt>
</li><li> <tt>org.eclipse.smila.utils</tt>
</li><li> <tt>org.eclipse.smila.processing.parameters</tt> (to use <tt>ParameterAccessor</tt>)
</li><li> <tt>org.eclipse.smila.processing.util</tt> (to use <tt>ResultCollector</tt>)
</li></ul>
</li></ul>
<ul><li> Create a class that implements the interface <tt>org.eclipse.smila.processing.Pipelet</tt> and make sure that the class has a public no-argument constructor (or none at all).
</li></ul>
<ul><li> Implement <tt>void configure(AnyMap configuration)</tt>. This method is called prior to process. Here you can read the configuration provided for the pipelet in the <a href="../../Glossary.html#P" title="SMILA/Glossary">pipeline</a>. To share those properties store the whole configuration in a member variable or better check the configuration for validity and completeness and then store the settings in a member variable. You can later access the configuration with the ParameterAccessor (see code sample below). The advantage of using the parameter accessor is that you can also override your configuration with configuration parameters set in the single records (e.g. the task parameters are included in the record by <tt>PipelineProcessorWorker</tt>, so you could override the pipelets configuration with job parameters as long as you use the <tt>ParameterAccessor</tt> to access parameters in the <tt>process</tt> method).
</li></ul>
<ul><li> Implement <tt>String[] process(Blackboard blackboard, String[] recordIds)</tt>. Here you have to place the "business logic" of your pipelet. In most cases the result is the same as the input recordIDs. But it is possible to return another list of IDs as result. Use the <tt>ResultCollector.addResult(...)</tt> to collect the ids you want to return and <tt>ResultCollector.addFailedResult(...)</tt> to control the error handling behaviour of your pipelet. When creating the ResultCollector you have to determine if the Collector should drop the ids that caused errors from the result id list it creates (using <tt>resultCollector.getResultIds()</tt>)or if these ids should still be part of the result id set. The ResultCollector will also control exception handling for you when setting failed record ids (depending on the existence and value of the parameter <tt>_failOnError</tt>, default is <tt>false</tt>). If <tt>_failOnError</tt> is set to true the ResultCollector will throw a ProcessingException, if not, the error will just be logged (on how to use the ResultCollector see the code sample below).
</li></ul>
<ul><li> Create a pipelet description json file for your pipelet in the <tt>SMILA-INF</tt> folder of the providing bundle. The file name is arbitrary but must have ".json" extension and the file content must contain at least the class name of the pipelet (<tt>{"class"&nbsp;: "your.class.name.here"}</tt>). Then they can be detected by the <tt>PipeletTracker</tt> service. If you would like to register multiple classes, use one separate description file for each class. Don't forget to add the <tt>SMILA-INF</tt> folder to the <tt>bin.includes</tt> entry of the bundle's <tt>build.properties</tt> file.
</li></ul>
<ul><li> Consider thread-safe-ness. Because pipelets may be accessed by multiple threads, make sure that access to member variables (e.g. the configuration) is read-only. For best practices: use local variables instead of member variables if possible.
</li></ul>
<a name="Further_reading"></a><h3> <span class="mw-headline"> Further reading </span></h3>
<p>For more information on the <tt>ResultCollector</tt> see <a href="http://build.eclipse.org/rt/smila/javadoc/current/org/eclipse/smila/processing/util/ResultCollector.html" class="external text" title="http://build.eclipse.org/rt/smila/javadoc/current/org/eclipse/smila/processing/util/ResultCollector.html" rel="nofollow">JavaDoc</a>.
</p>
<a name="Configuration"></a><h2> <span class="mw-headline"> Configuration </span></h2>
<p>If your pipelet requires a configuration:
</p>
<ul><li> Add a <tt>&lt;configuration&gt;</tt> element to the <tt>&lt;extensionActivity&gt;</tt> section of your pipelet in the BPEL pipeline.
</li></ul>
<a name="Examples"></a><h2> <span class="mw-headline"> Examples </span></h2>
<a name="Pipelet_Usage"></a><h3> <span class="mw-headline"> Pipelet Usage </span></h3>
<p>This is a template for <tt>MyPipelet.java</tt>:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-java"><span class="kw1">package</span> org.<span class="me1">eclipse</span>.<span class="me1">smila</span>.<span class="me1">mypackage</span>
&nbsp;
<span class="kw1">import</span> org.<span class="me1">eclipse</span>.<span class="me1">smila</span>.<span class="me1">blackboard</span>.<span class="me1">Blackboard</span>;
<span class="kw1">import</span> org.<span class="me1">eclipse</span>.<span class="me1">smila</span>.<span class="me1">processing</span>.<span class="me1">ProcessingException</span>;
<span class="kw1">import</span> org.<span class="me1">eclipse</span>.<span class="me1">smila</span>.<span class="me1">processing</span>.<span class="me1">Pipelet</span>;
<span class="kw1">import</span> org.<span class="me1">eclipse</span>.<span class="me1">smila</span>.<span class="me1">datamodel</span>.<span class="me1">AnyMap</span>;
&nbsp;
<span class="kw1">public</span> <span class="kw1">class</span> MyPipelet <span class="kw1">implements</span> Pipelet <span class="br0">&#123;</span>
&nbsp;
<span class="kw1">public</span> <span class="kw4">void</span> configure<span class="br0">&#40;</span>AnyMap configuration<span class="br0">&#41;</span> <span class="kw1">throws</span> ProcessingException <span class="br0">&#123;</span>
<span class="co1">// read the configuration properties</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw1">public</span> <span class="kw3">String</span><span class="br0">&#91;</span><span class="br0">&#93;</span> process<span class="br0">&#40;</span>Blackboard blackboard, <span class="kw3">String</span><span class="br0">&#91;</span><span class="br0">&#93;</span> recordIds<span class="br0">&#41;</span> <span class="kw1">throws</span> ProcessingException <span class="br0">&#123;</span>
<span class="co1">// process the records and create a result</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div>
<p>And this is how to register the pipelet class in the bundle:
Create a folder <tt>SMILA-INF</tt> in the bundle and add a file <tt>MyPipelet.json</tt> to this folder:
</p>
<pre>
{
&quot;class&quot;: &quot;org.eclipse.smila.mypackage.MyPipelet&quot;,
&quot;parameters&quot;: [
&lt;put your parameter descriptions here&gt;
],
&quot;description&quot;: &quot;The textual description of my pipelet. This is optional but good style.&quot;
}
</pre>
<div class="messagebox" style="background-color: #def3fe; border: 1px solid #c5d7e0; color: black; padding: 5px; margin: 1ex 0; min-height: 35px; padding-left: 45px;">
<div style="float: left; margin-left: -40px;"><a href="http://wiki.eclipse.org/Image:Note.png" class="image" title="Note.png"><img alt="" src="http://wiki.eclipse.org/images/c/cc/Note.png" width="35" height="35" border="0" /></a></div>
<div>
The description as well as the parameters section is optional but gives users a hint on which parameters you pipelet uses and what they mean as well as what your pipelet does. The parameters section follows the same restrictions as the workers' parameter descriptions, see <a href="../ParameterDefinition.html" title="SMILA/Documentation/ParameterDefinition">SMILA/Documentation/ParameterDefinition</a> for details.<b><br /></div></b>
</div>
<p>Now add the folder <tt>SMILA-INF</tt> to the build.properties (or just check it in the <tt>Build</tt> view of the <tt>MANIFEST.MF</tt> file in your IDE.
</p><p>And finally, this is a sample showing how a pipelet is invoked in the BPEL pipeline using an <tt>&lt;extensionActivity&gt;</tt>. It also shows how the pipelet is configured using a <tt>&lt;configuration&gt;</tt> section.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-xml">...
<span class="sc3"><span class="re1">&lt;extensionActivity<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;proc:invokePipelet</span> <span class="re0">name</span>=<span class="st0">&quot;invokeMyPipelet&quot;</span><span class="re2">&gt;</span></span>
<span class="sc3"><span class="re1">&lt;proc:pipelet</span> <span class="re0">class</span>=<span class="st0">&quot;org.eclipse.smila.mypackage.MyPipelet&quot;</span> <span class="re2">/&gt;</span></span>
<span class="sc3"><span class="re1">&lt;proc:variables</span> <span class="re0">input</span>=<span class="st0">&quot;request&quot;</span> <span class="re0">output</span>=<span class="st0">&quot;request&quot;</span> <span class="re2">/&gt;</span></span>
<span class="sc3"><span class="re1">&lt;proc:configuration<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;rec:Val</span> <span class="re0">key</span>=<span class="st0">&quot;aStringParam&quot;</span><span class="re2">&gt;</span></span>some value<span class="sc3"><span class="re1">&lt;/rec:Val<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;rec:Val</span> <span class="re0">key</span>=<span class="st0">&quot;aDateParam&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;datetime&quot;</span><span class="re2">&gt;</span></span>2008-06-11T16:08:00.000+0200<span class="sc3"><span class="re1">&lt;/rec:Val<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/proc:configuration<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/proc:invokePipelet<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/extensionActivity<span class="re2">&gt;</span></span></span>
...</pre></div>
<div class="messagebox" style="background-color: #def3fe; border: 1px solid #c5d7e0; color: black; padding: 5px; margin: 1ex 0; min-height: 35px; padding-left: 45px;">
<div style="float: left; margin-left: -40px;"><a href="http://wiki.eclipse.org/Image:Note.png" class="image" title="Note.png"><img alt="" src="http://wiki.eclipse.org/images/c/cc/Note.png" width="35" height="35" border="0" /></a></div>
<div>
You can also configure Pipelines with SMILA's BPEL designer. See <a href="../../BPEL_Designer.html" title="SMILA/BPEL Designer">BPEL Designer</a> for more information and how to install it.<b><br /></div></b>
</div>
<a name="Piplet_configuration_usage"></a><h3> <span class="mw-headline"> Piplet configuration usage </span></h3>
<p>The following example shows the usage of multiple values for properties:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-xml">...
<span class="sc3"><span class="re1">&lt;extensionActivity<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;proc:invokePipelet</span> <span class="re0">name</span>=<span class="st0">&quot;addValuesToNonExistingAttribute&quot;</span><span class="re2">&gt;</span></span>
<span class="sc3"><span class="re1">&lt;proc:pipelet</span> <span class="re0">class</span>=<span class="st0">&quot;org.eclipse.smila.processing.pipelets.AddValuesPipelet&quot;</span> <span class="re2">/&gt;</span></span>
<span class="sc3"><span class="re1">&lt;proc:variables</span> <span class="re0">input</span>=<span class="st0">&quot;request&quot;</span> <span class="re0">output</span>=<span class="st0">&quot;request&quot;</span><span class="re2">/&gt;</span></span>
<span class="sc3"><span class="re1">&lt;proc:configuration<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;rec:Val</span> <span class="re0">key</span>=<span class="st0">&quot;outputAttribute&quot;</span><span class="re2">&gt;</span></span>out<span class="sc3"><span class="re1">&lt;/rec:Val<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;rec:Seq</span> <span class="re0">key</span>=<span class="st0">&quot;valuesToAdd&quot;</span><span class="re2">&gt;</span></span>
<span class="sc3"><span class="re1">&lt;rec:Val<span class="re2">&gt;</span></span></span>value1<span class="sc3"><span class="re1">&lt;/rec:Val<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;rec:Val<span class="re2">&gt;</span></span></span>value2<span class="sc3"><span class="re1">&lt;/rec:Val<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/rec:Seq<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/proc:configuration<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/proc:invokePipelet<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/extensionActivity<span class="re2">&gt;</span></span></span>
...</pre></div>
<div dir="ltr" style="text-align: left;"><pre class="source-java"><span class="kw1">public</span> <span class="kw1">class</span> AddValuesPipelet <span class="kw1">implements</span> Pipelet <span class="br0">&#123;</span>
&nbsp;
<span class="coMULTI">/** config property name for attribute name to add values to. */</span>
<span class="kw1">private</span> <span class="kw1">static</span> <span class="kw1">final</span> <span class="kw3">String</span> PARAM_ATTRIBUTE = <span class="st0">&quot;outputAttribute&quot;</span>;
&nbsp;
<span class="coMULTI">/** config property name for the values to add. */</span>
<span class="kw1">private</span> <span class="kw1">static</span> <span class="kw1">final</span> <span class="kw3">String</span> PARAM_VALUES = <span class="st0">&quot;valuesToAdd&quot;</span>;
&nbsp;
<span class="coMULTI">/** the pipelet's configuration. */</span>
<span class="kw1">private</span> AnyMap _config;
&nbsp;
<span class="coMULTI">/** local logger. */</span>
<span class="kw1">private</span> <span class="kw1">final</span> Log _log = LogFactory.<span class="me1">getLog</span><span class="br0">&#40;</span>getClass<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
&nbsp;
<span class="coMULTI">/** add Any values to an attribute as described in pipelet config or parameters. */</span>
@Override
<span class="kw1">public</span> <span class="kw3">String</span><span class="br0">&#91;</span><span class="br0">&#93;</span> process<span class="br0">&#40;</span><span class="kw1">final</span> Blackboard blackboard, <span class="kw1">final</span> <span class="kw3">String</span><span class="br0">&#91;</span><span class="br0">&#93;</span> recordIds<span class="br0">&#41;</span> <span class="kw1">throws</span> ProcessingException <span class="br0">&#123;</span>
<span class="kw1">final</span> ParameterAccessor paramAccessor = <span class="kw1">new</span> ParameterAccessor<span class="br0">&#40;</span>blackboard, _config<span class="br0">&#41;</span>;
<span class="kw1">final</span> ResultCollector resultCollector =
<span class="kw1">new</span> ResultCollector<span class="br0">&#40;</span>paramAccessor, _log, ProcessingConstants.<span class="me1">DROP_ON_ERROR_DEFAULT</span><span class="br0">&#41;</span>;
<span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw1">final</span> <span class="kw3">String</span> id&nbsp;: recordIds<span class="br0">&#41;</span> <span class="br0">&#123;</span>
paramAccessor.<span class="me1">setCurrentRecord</span><span class="br0">&#40;</span>id<span class="br0">&#41;</span>;
<span class="co1">// the attribute to which to add the values.</span>
<span class="kw1">final</span> <span class="kw3">String</span> outputAttribute = paramAccessor.<span class="me1">getParameter</span><span class="br0">&#40;</span>PARAM_ATTRIBUTE, <span class="kw2">null</span><span class="br0">&#41;</span>;
<span class="co1">// the values to add.</span>
<span class="kw1">final</span> <span class="kw3">Any</span> values = paramAccessor.<span class="me1">getParameterAny</span><span class="br0">&#40;</span>PARAM_VALUES<span class="br0">&#41;</span>;
<span class="kw1">if</span> <span class="br0">&#40;</span>values&nbsp;!= <span class="kw2">null</span> &amp;&amp; outputAttribute&nbsp;!= <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
<span class="kw1">try</span> <span class="br0">&#123;</span>
<span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw1">final</span> <span class="kw3">Any</span> value&nbsp;: values<span class="br0">&#41;</span> <span class="br0">&#123;</span>
blackboard.<span class="me1">getMetadata</span><span class="br0">&#40;</span>id<span class="br0">&#41;</span>.<span class="me1">add</span><span class="br0">&#40;</span>outputAttribute, value<span class="br0">&#41;</span>;
<span class="br0">&#125;</span>
resultCollector.<span class="me1">addResult</span><span class="br0">&#40;</span>id<span class="br0">&#41;</span>;
<span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><span class="kw1">final</span> <span class="kw3">Exception</span> ex<span class="br0">&#41;</span> <span class="br0">&#123;</span>
resultCollector.<span class="me1">addFailedResult</span><span class="br0">&#40;</span>id, ex<span class="br0">&#41;</span>;
<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="kw1">return</span> resultCollector.<span class="me1">getResultIds</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
<span class="br0">&#125;</span>
&nbsp;
<span class="coMULTI">/** {@inheritDoc} */</span>
@Override
<span class="kw1">public</span> <span class="kw4">void</span> configure<span class="br0">&#40;</span><span class="kw1">final</span> AnyMap configuration<span class="br0">&#41;</span> <span class="kw1">throws</span> ProcessingException <span class="br0">&#123;</span>
_config = configuration;
<span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div>
<!--
NewPP limit report
Preprocessor node count: 132/1000000
Post-expand include size: 2555/2097152 bytes
Template argument size: 1495/2097152 bytes
#ifexist count: 0/100
-->
<!-- Saved in parser cache with key wikidb:pcache:idhash:15195-0!1!0!!en!2!edit=0 and timestamp 20120710093511 -->
<div class="printfooter">
Retrieved from "<a href="How_to_write_a_Pipelet.html">http://wiki.eclipse.org/SMILA/Documentation/HowTo/How_to_write_a_Pipelet</a>"</div>
<div id="catlinks"><p class='catlinks'><a href="http://wiki.eclipse.org/Special:Categories" title="Special:Categories">Category</a>: <span dir='ltr'><a href="http://wiki.eclipse.org/Category:SMILA" title="Category:SMILA">SMILA</a></span></p></div> <!-- end content -->
<div class="visualClear"></div>
</div>
</div>
</div>
<!-- Yoink of toolbox for phoenix moved up -->
</div>
</div>
<div id="clearFooter"/>
<div id="footer" >
<ul id="footernav">
<li class="first"><a href="http://www.eclipse.org/">Home</a></li>
<li><a href="http://www.eclipse.org/legal/privacy.php">Privacy Policy</a></li>
<li><a href="http://www.eclipse.org/legal/termsofuse.php">Terms of Use</a></li>
<li><a href="http://www.eclipse.org/legal/copyright.php">Copyright Agent</a></li>
<li><a href="http://www.eclipse.org/org/foundation/contact.php">Contact</a></li>
<li><a href="http://wiki.eclipse.org/Eclipsepedia:About" title="Eclipsepedia:About">About Eclipsepedia</a></li>
</ul>
<span id="copyright">Copyright &copy; 2012 The Eclipse Foundation. All Rights Reserved</span>
<p id="footercredit">This page was last modified 14:53, 9 March 2012 by <a href="http://wiki.eclipse.org/index.php?title=User:Juergen.schumacher.attensity.com&amp;action=edit" class="new" title="User:Juergen.schumacher.attensity.com">Juergen Schumacher</a>. Based on work by <a href="http://wiki.eclipse.org/User:Igor.novakovic.attensity.com" title="User:Igor.novakovic.attensity.com">Igor Novakovic</a>, <a href="http://wiki.eclipse.org/User:Andreas.schank.attensity.com" title="User:Andreas.schank.attensity.com">A. Schank</a> and <a href="http://wiki.eclipse.org/User:Andreas.Weber.empolis.com" title="User:Andreas.Weber.empolis.com">Andreas Weber</a> and <a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Pipelet&amp;action=credits" title="SMILA/Documentation/HowTo/How to write a Pipelet">others</a>.</p>
<p id="footerviews">This page has been accessed 5,013 times.</p>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-910670-4");
pageTracker._trackPageview();
</script>
<!-- <div class="visualClear"></div> -->
<script type="text/javascript">if (window.runOnloadHook) runOnloadHook();</script>
</div>
<!-- Served in 0.053 secs. --></body></html>