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.
Difference between revisions of "SMILA/Documentation/HowTo/How to integrate the HelloWorld webservice as a Pipelet"
Line 35: | Line 35: | ||
== Implementation == | == Implementation == | ||
+ | |||
+ | * create a package <tt>org.eclipse.smila.sample.pipelet</tt> and a Java class <tt>HelloWorldPipelet</tt> | ||
+ | * use the following code as a template for your new class (for your conveninace you may also download the complete source file [[Media:HelloWorldPipelet.java|HelloWorldPipelet.java]]) | ||
+ | <source lang="Java"> | ||
+ | package org.eclipse.smila.sample.pipelet | ||
+ | |||
+ | 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 HelloWorldPipelet implements SimplePipelet { | ||
+ | |||
+ | public HelloWorldPipelet(){ | ||
+ | } | ||
+ | |||
+ | 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 | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | === Read PipeletConfiguration === | ||
+ | * first let's create two member variables that store the names of the in- and output Attributes as well as String constants for the property names used in the configuration | ||
+ | <source lang="Java"> | ||
+ | private final String PROP_IN_ATT_NAME= "IN_ATT_NAME"; | ||
+ | private final String PROP_OUT_ATT_NAME= "OUT_ATT_NAME"; | ||
+ | |||
+ | private String _inAttName; | ||
+ | private String _outAttName; | ||
+ | </source> | ||
+ | |||
+ | * then we will fill those members with the Attribute names provided by the PipeletConfiguration in method <tt>configure(PipeletConfiguration configuration)</tt>. The method <tt>getPropertyFirstValueNotNull(String)</tt> will check that the value of the property is not null. If it is null a <tt>ProcessingException</tt> will be thrown. In addition we should ensure, that the provided String is not empty or consists only of whitespaces. | ||
+ | <source lang="Java"> | ||
+ | public void configure(PipeletConfiguration configuration) throws ProcessingException { | ||
+ | _inAttName = (String) configuration.getPropertyFirstValueNotNull(PROP_IN_ATT_NAME); | ||
+ | if (_elementId.trim().length() == 0) { | ||
+ | throw new ProcessingException("Property " + PROP_IN_ATT_NAME + " must not be an empty String"); | ||
+ | } | ||
+ | |||
+ | _outAttName = (String) configuration.getPropertyFirstValueNotNull(OUT_ATT_NAME); | ||
+ | if (_elementId.trim().length() == 0) { | ||
+ | throw new ProcessingException("Property " + OUT_ATT_NAME + " must not be an empty String"); | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | === Read Input Data === | ||
comming soon ... | comming soon ... | ||
+ | === Process Input Data === | ||
+ | comming soon ... | ||
− | == | + | === Write Output Data === |
comming soon ... | comming soon ... | ||
+ | == Configuration and Invocation in BPEL == | ||
+ | In this sample we will integrate the HelloWorldPipelet in the SMILA indexing process just before the Record is stored in the Lucene index. With this configuration the input for the HelloWorldPipelet will be read from Attribute ''Title'' and the modified output will be stored in the same Attribute, overwriting the previous value. | ||
+ | * edit file configuration\org.eclipse.eilf.processing.bpel\pipelines\addpipeline.bpel and add the following right between <tt><extensionActivity name="convertDocument"></tt> and <tt><extensionActivity name="invokeLuceneService"></tt> | ||
+ | <source lang="XML"> | ||
+ | <extensionActivity name="invokeHelloWorldPipelet"> | ||
+ | <proc:invokePipelet> | ||
+ | <proc:pipelet class="org.eclipse.smila.sample.pipelet.HelloWorldPipelet" /> | ||
+ | <proc:variables input="request" output="result" /> | ||
+ | <proc:PipeletConfiguration> | ||
+ | <proc:Property name="IN_ATT_NAME"> | ||
+ | <proc:Value>Title</proc:Value> | ||
+ | </proc:Property> | ||
+ | <proc:Property name="OUT_ATT_NAME"> | ||
+ | <proc:Value>Title</proc:Value> | ||
+ | </proc:Property> | ||
+ | </proc:PipeletConfiguration> | ||
+ | </proc:invokePipelet> | ||
+ | </extensionActivity> | ||
+ | </source> | ||
+ | |||
+ | |||
+ | == Test your Pipelet == | ||
+ | comming soon ... | ||
[[Category:SMILA]] | [[Category:SMILA]] |
Revision as of 09:32, 26 September 2008
This tutorial illustrates all steps that need to be performed in order to integrate the HelloWorld webservice as a Pipelet in SMILA
Contents
Preparations
It may be helpful to first take a look at the SMILA Development_Guidelines as many topics that are beyond the scope of this tutorial are illustrated there in detail.
Create a new Bundle
- First you have to create a new bundle that will contain the Pipelet. Please follow the instructions on How to create a bundle and use the following settings:
Project name: org.eclipse.smila.sample.pipelet Plug-in ID: org.eclipse.smila.sample.pipelet Plug-in Version: 1.0.0 Plug-in Name: Sample Pipelet Bundle Plug-in Provider: your name or company
- Then you have to integrate your new bundle into the SMILA build process. Therefore please follow the instructions on How to integrate new bundle into build process.
- Edit file META-INF/MANIFEST.MF and add the following import-package dependencies as those are required to implement the basic functionalities of your Pipelet:
Import-Package: org.eclipse.smila.blackboard.BlackboardService;version="0.5.0" org.eclipse.smila.datamodel.id.Id;version="0.5.0" org.eclipse.smila.processing.ProcessingException;version="0.5.0" org.eclipse.smila.processing.SimplePipelet;version="0.5.0" org.eclipse.smila.processing.configuration.PipeletConfiguration;version="0.5.0"
- In order for the PipeletTrackerService to detect your new Pipelet you have to add the following line to file META-INF/MANIFEST.MF to register the class that will implement your SMILA Pipelet:
SMILA-Pipelets: org.eclipse.smila.sample.pipelet.HelloWorldPipelet
Create Java classes from WSDL
comming soon ...
Implementation
- create a package org.eclipse.smila.sample.pipelet and a Java class HelloWorldPipelet
- use the following code as a template for your new class (for your conveninace you may also download the complete source file HelloWorldPipelet.java)
package org.eclipse.smila.sample.pipelet 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 HelloWorldPipelet implements SimplePipelet { public HelloWorldPipelet(){ } 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 } }
Read PipeletConfiguration
- first let's create two member variables that store the names of the in- and output Attributes as well as String constants for the property names used in the configuration
private final String PROP_IN_ATT_NAME= "IN_ATT_NAME"; private final String PROP_OUT_ATT_NAME= "OUT_ATT_NAME"; private String _inAttName; private String _outAttName;
- then we will fill those members with the Attribute names provided by the PipeletConfiguration in method configure(PipeletConfiguration configuration). The method getPropertyFirstValueNotNull(String) will check that the value of the property is not null. If it is null a ProcessingException will be thrown. In addition we should ensure, that the provided String is not empty or consists only of whitespaces.
public void configure(PipeletConfiguration configuration) throws ProcessingException { _inAttName = (String) configuration.getPropertyFirstValueNotNull(PROP_IN_ATT_NAME); if (_elementId.trim().length() == 0) { throw new ProcessingException("Property " + PROP_IN_ATT_NAME + " must not be an empty String"); } _outAttName = (String) configuration.getPropertyFirstValueNotNull(OUT_ATT_NAME); if (_elementId.trim().length() == 0) { throw new ProcessingException("Property " + OUT_ATT_NAME + " must not be an empty String"); } }
Read Input Data
comming soon ...
Process Input Data
comming soon ...
Write Output Data
comming soon ...
Configuration and Invocation in BPEL
In this sample we will integrate the HelloWorldPipelet in the SMILA indexing process just before the Record is stored in the Lucene index. With this configuration the input for the HelloWorldPipelet will be read from Attribute Title and the modified output will be stored in the same Attribute, overwriting the previous value.
- edit file configuration\org.eclipse.eilf.processing.bpel\pipelines\addpipeline.bpel and add the following right between <extensionActivity name="convertDocument"> and <extensionActivity name="invokeLuceneService">
<extensionActivity name="invokeHelloWorldPipelet"> <proc:invokePipelet> <proc:pipelet class="org.eclipse.smila.sample.pipelet.HelloWorldPipelet" /> <proc:variables input="request" output="result" /> <proc:PipeletConfiguration> <proc:Property name="IN_ATT_NAME"> <proc:Value>Title</proc:Value> </proc:Property> <proc:Property name="OUT_ATT_NAME"> <proc:Value>Title</proc:Value> </proc:Property> </proc:PipeletConfiguration> </proc:invokePipelet> </extensionActivity>
Test your Pipelet
comming soon ...