<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Petals planet</title>
	
	<link>http://planet.petalslink.com</link>
	<description>Deals with Petals ESB, Petals Suite, SOA, PetalsLink...</description>
	<lastBuildDate>Thu, 11 Mar 2010 12:52:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
<link>http://planet.petalslink.com</link>
<url>http://planete.petalslink.com/home/wp-content/mbp-favicon/favicon.png</url>
<title>Petals planet</title>
</image>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/PetalsPlanet" /><feedburner:info uri="petalsplanet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Mapping WSDL JBI</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/Xf5WWx0TjLU/</link>
		<comments>http://chamerling.wordpress.com/2010/03/11/mapping-wsdl-jbi/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 12:52:03 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Petals ESB]]></category>
		<category><![CDATA[WebService]]></category>
		<category><![CDATA[jbi]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[ow2]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[wsdl]]></category>
		<category><![CDATA[petalspourlesnuls]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=331</guid>
		<description><![CDATA[Cet article fait suite à une question récurrente des utilisateurs de Petals ESB : &#171;&#160;Pourquoi j&#8217;ai une erreur au déploiement de mon service???&#160;&#187;. Je vais ici tenter de donner une réponse partielle à cette question car il peut y avoir beaucoup de raisons à une erreur de déploiement. La plus courante venant souvent de la [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=331&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Cet article fait suite à une question récurrente des utilisateurs de Petals ESB : &laquo;&nbsp;Pourquoi j&#8217;ai une erreur au déploiement de mon service???&nbsp;&raquo;. Je vais ici tenter de donner une réponse partielle à cette question car il peut y avoir beaucoup de raisons à une erreur de déploiement. La plus courante venant souvent de la configuration. Rien que bien technique ni compliqué dans cet article, juste un mini tutoriel pour mieux comprendre la philosophie Petals &#8211; JBI.</p>
<p>La spécification <a href="http://www.jcp.org/en/jsr/detail?id=208">JBI</a> est basée sur l&#8217;état de l&#8217;art des Web services et donc utilise WSDL pour la description des services &#8216;hostés&#8217; ou liés à l&#8217;implémentation JBI. <a href="http://petals.ow2.org">Petals ESB</a> implémente (et étend &#8211; mais ça sera peut être l&#8217;objet d&#8217;un autre article sur le pourquoi du comment&#8230;) la spécification JBI depuis sa première version. Petals ESB est même certifié compatible JBI par SUN (RIP) après le passage du TCK JBI (Outil de test de compatibilité fournit par SUN). Bref, là n&#8217;est pas la question&#8230; Les descripteurs JBI servent à beaucoup de choses dans une implémentation JBI mais nous allons particulièrement regarder comment nous nous en servons dans l&#8217;exposition de services.</p>
<p>Un service exposé dans le bus fournit donc sa description via un WSDL associé. Ce service est activé dans le bus après le déploiement de ce que l&#8217;on appelle communément une &#8216;SA&#8217; (Service Assembly) qui contient des &#8216;SU&#8217; (Service Unit). Pour exposer un service dans le bus afin qu&#8217;il soit accessible à tout les consommateurs, la SU doit être en mode &#8216;provide&#8217; ie fournisseur. Elle doit aussi définir le Endpoint, le Service et l&#8217;Interface qu&#8217;elle veut exposer. Prenons l&#8217;exemple du bon vieux service HelloWorld définit par le WSDL suivant :</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
&lt;ns2:definitions name=&quot;HelloServiceImplService&quot; targetNamespace=&quot;http://sample.petals.ow.org/&quot; xmlns:ns2=&quot;http://schemas.xmlsoap.org/wsdl/&quot; xmlns:ns3=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;
	xmlns:ns9=&quot;http://www.w3.org/ns/wsdl/http&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:ns5=&quot;http://schemas.xmlsoap.org/wsdl/soap12/&quot; xmlns:ns6=&quot;http://schemas.xmlsoap.org/wsdl/http/&quot;
	xmlns:ns10=&quot;http://schemas.xmlsoap.org/wsdl/mime/&quot; xmlns:ns7=&quot;http://www.w3.org/ns/wsdl&quot; xmlns:ns8=&quot;http://www.w3.org/ns/wsdl/soap&quot;&gt;
	&lt;ns2:types&gt;
		&lt;xs:schema elementFormDefault=&quot;unqualified&quot; attributeFormDefault=&quot;unqualified&quot; targetNamespace=&quot;http://sample.petals.ow.org/&quot;&gt;
			&lt;xs:element name=&quot;sayHello&quot; type=&quot;tns:sayHello&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot; /&gt;
			&lt;xs:element name=&quot;sayHelloResponse&quot; type=&quot;tns:sayHelloResponse&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot; /&gt;
			&lt;xs:complexType name=&quot;sayHello&quot;&gt;
				&lt;xs:sequence&gt;
					&lt;xs:element name=&quot;arg0&quot; minOccurs=&quot;0&quot; type=&quot;xs:string&quot; /&gt;
				&lt;/xs:sequence&gt;
			&lt;/xs:complexType&gt;
			&lt;xs:complexType name=&quot;sayHelloResponse&quot;&gt;
				&lt;xs:sequence&gt;
					&lt;xs:element name=&quot;return&quot; minOccurs=&quot;0&quot; type=&quot;xs:string&quot; /&gt;
				&lt;/xs:sequence&gt;
			&lt;/xs:complexType&gt;
		&lt;/xs:schema&gt;
	&lt;/ns2:types&gt;
	&lt;ns2:message name=&quot;sayHelloResponse&quot;&gt;
		&lt;ns2:part element=&quot;tns:sayHelloResponse&quot; name=&quot;parameters&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot; /&gt;
	&lt;/ns2:message&gt;
	&lt;ns2:message name=&quot;sayHello&quot;&gt;
		&lt;ns2:part element=&quot;tns:sayHello&quot; name=&quot;parameters&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot; /&gt;
	&lt;/ns2:message&gt;
	&lt;ns2:portType name=&quot;HelloService&quot;&gt;
		&lt;ns2:operation name=&quot;sayHello&quot;&gt;
			&lt;ns2:input message=&quot;tns:sayHello&quot; name=&quot;sayHello&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot; /&gt;
			&lt;ns2:output message=&quot;tns:sayHelloResponse&quot; name=&quot;sayHelloResponse&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot; /&gt;
		&lt;/ns2:operation&gt;
	&lt;/ns2:portType&gt;
	&lt;ns2:binding type=&quot;tns:HelloService&quot; name=&quot;HelloServiceImplServiceSoapBinding&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot;&gt;
		&lt;ns3:binding style=&quot;document&quot; transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; /&gt;
		&lt;ns2:operation name=&quot;sayHello&quot;&gt;
			&lt;ns3:operation style=&quot;document&quot; soapAction=&quot;&quot; /&gt;
			&lt;ns2:input name=&quot;sayHello&quot;&gt;
				&lt;ns3:body use=&quot;literal&quot; /&gt;
			&lt;/ns2:input&gt;
			&lt;ns2:output name=&quot;sayHelloResponse&quot;&gt;
				&lt;ns3:body use=&quot;literal&quot; /&gt;
			&lt;/ns2:output&gt;
		&lt;/ns2:operation&gt;
	&lt;/ns2:binding&gt;
	&lt;ns2:service name=&quot;HelloServiceImplService&quot;&gt;
		&lt;ns2:port binding=&quot;tns:HelloServiceImplServiceSoapBinding&quot; name=&quot;HelloServiceImplPort&quot; xmlns:tns=&quot;http://sample.petals.ow.org/&quot;&gt;
			&lt;ns3:address location=&quot;http://localhost:9999/sample/HelloService&quot; /&gt;
		&lt;/ns2:port&gt;
	&lt;/ns2:service&gt;
&lt;/ns2:definitions&gt;
&lt;pre&gt;</pre>
<p>Son descripteur JBI associé sera donc (lié a Petals via le composant Web service dans cet exemple) :</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;jbi:jbi version=&quot;1.0&quot;
        xmlns:generatedNs=&quot;http://sample.petals.ow.org/&quot;
        xmlns:jbi=&quot;http://java.sun.com/xml/ns/jbi&quot;
	xmlns:petalsCDK=&quot;http://petals.ow2.org/components/extensions/version-5&quot;
	xmlns:soap=&quot;http://petals.ow2.org/components/soap/version-4&quot;
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;

	&lt;jbi:services binding-component=&quot;true&quot;&gt;
		&lt;jbi:provides interface-name=&quot;generatedNs:HelloService&quot;
			service-name=&quot;generatedNs:HelloServiceImplService&quot;
			endpoint-name=&quot;HelloServiceImplPort&quot;&gt;

			&lt;!-- CDK specific elements --&gt;
			&lt;petalsCDK:timeout&gt;60000&lt;/petalsCDK:timeout&gt;
			&lt;petalsCDK:wsdl&gt;Service.wsdl&lt;/petalsCDK:wsdl&gt;

			&lt;!-- Component specific elements --&gt;
			&lt;soap:address&gt;http://localhost:9999/sample/HelloService&lt;/soap:address&gt;
			&lt;soap:soap-version&gt;11&lt;/soap:soap-version&gt;
			&lt;soap:add-root&gt;false&lt;/soap:add-root&gt;
			&lt;soap:chunked-mode&gt;false&lt;/soap:chunked-mode&gt;
			&lt;soap:cleanup-transport&gt;true&lt;/soap:cleanup-transport&gt;
			&lt;soap:mode&gt;SOAP&lt;/soap:mode&gt;
		&lt;/jbi:provides&gt;
	&lt;/jbi:services&gt;
&lt;/jbi:jbi&gt;
</pre>
<p>Où on respecte bien que :</p>
<ol>
<li>JBI &#8216;<strong>endpoint-name</strong>&#8216; = Valeur de l&#8217;attribut &#8216;name&#8217; du <strong>Port</strong> dans le WSDL</li>
<li>JBI &#8216;<strong>service-name</strong>&#8216; = Valeur de l&#8217;attribut &#8216;name&#8217; du <strong>Service</strong> dans le WSDL (avec JBI Service NameSpace = targetNamespace du WSDL)</li>
<li>JBI &#8216;<strong>interface-name</strong>&#8216; = Valeur de l&#8217;attribut &#8216;name&#8217; du <strong>PortType</strong> dans le WSDL (avec JBI Interface NameSpace = targetNamespace du WSDL)</li>
</ol>
<p>Petals ESB v3.x ne vous insultera plus lors du déploiement de vos services. Une solution simple pour ne pas se faire insulter, est d&#8217;utiliser le <a href="http://www.petalslink.com/fr/produits/petals-studio">Studio Petals</a> qui facilite grandement la vie des développeurs!</p><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/331/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=331&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/Xf5WWx0TjLU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/03/11/mapping-wsdl-jbi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/03/11/mapping-wsdl-jbi/</feedburner:origLink></item>
		<item>
		<title>Permgen Space with Eclipse</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/X7K3jWDkv4c/</link>
		<comments>http://vzurczak.wordpress.com/2010/03/10/permgen-space-with-eclipse/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:35:23 +0000</pubDate>
		<dc:creator>Vincent Zurczak</dc:creator>
				<category><![CDATA[Eclipse tips]]></category>

		<guid isPermaLink="false">http://vzurczak.wordpress.com/?p=75</guid>
		<description><![CDATA[Hi,
If you develop Eclipse plug-ins, you are always brought to run an Eclipse application.
It means that to test your plug-ins, you have to launch a second Eclipse from the one where you develop.
One common problem in this case is the PermGen Space issue.
This is in particular true if you test GMF plug-ins or if there [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vzurczak.wordpress.com&#38;blog=10081016&#38;post=75&#38;subd=vzurczak&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>If you develop Eclipse plug-ins, you are always brought to run an Eclipse application.<br />
It means that to test your plug-ins, you have to launch a second Eclipse from the one where you develop.</p>
<p>One common problem in this case is the PermGen Space issue.<br />
This is in particular true if you test GMF plug-ins or if there is a lot of class generation.</p>
<p>To solve this, you can modify the permgen space allocated when you run the other Eclipse.<br />
Go into <strong>Run &gt; Debug Configurations</strong>. Select your Eclipse configration and go into the <strong>Arguments</strong> tab.<br />
The field to upate is the <strong>VM Arguments</strong>.</p>
<p>As an example, when running Talend Open Studio in debug, I have to use the following settings.</p>
<pre style="padding-left:30px;">-Xms256m -Xmx1024m -XX:MaxPermSize=512m
</pre>
<p style="text-align:center;"><a href="http://vzurczak.files.wordpress.com/2010/03/configurations1.jpg"><img class="alignnone size-medium wp-image-79" title="Debug Configuration" src="http://vzurczak.files.wordpress.com/2010/03/configurations1.jpg?w=300&#038;h=216" alt="Debug Configuration" width="300" height="216" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vzurczak.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vzurczak.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vzurczak.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vzurczak.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vzurczak.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vzurczak.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vzurczak.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vzurczak.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vzurczak.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vzurczak.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vzurczak.wordpress.com&blog=10081016&post=75&subd=vzurczak&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/X7K3jWDkv4c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://vzurczak.wordpress.com/2010/03/10/permgen-space-with-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://vzurczak.wordpress.com/2010/03/10/permgen-space-with-eclipse/</feedburner:origLink></item>
		<item>
		<title>Axis2 : Rerouter vos appels de services sans modifier vote code client</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/7LJTesrkw0Q/</link>
		<comments>http://chamerling.wordpress.com/2010/03/09/axis2-rerouter-vos-appels-de-services-sans-modifier-vote-code-client/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 16:08:14 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[axis2]]></category>
		<category><![CDATA[soa]]></category>
		<category><![CDATA[wsdl]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[routage]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=317</guid>
		<description><![CDATA[Imaginons que vous ayez à votre disposition un client de Web service et que pour une raison (qui doit être bonne je l&#8217;accorde), vous avez besoin de rerouter vos appels de service vers un nouveau point d&#8217;accès. Le problème est que vous n&#8217;avez pas le droit de modifier le code client (ou que vous ne [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=317&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Imaginons que vous ayez à votre disposition un client de Web service et que pour une raison (qui doit être bonne je l&#8217;accorde), vous avez besoin de rerouter vos appels de service vers un nouveau point d&#8217;accès. Le problème est que vous n&#8217;avez pas le droit de modifier le code client (ou que vous ne l&#8217;avez pas), que vous ne voulez pas regénérer ce code client à partir du WSDL du nouveau service a appeler (qui est exactement le même hormis l&#8217;adresse du endpoint)&#8230; Heureusement, votre client utilise la pile Web service Apache Axis2, et les développeurs d&#8217;Axis2 ont gentiment pensé à introduire des modules dans leur architecture. Une bonne intorduction aux modules est disponible dans <a href="http://ws.apache.org/axis2/1_4_1/Axis2ArchitectureGuide.html">le guide d&#8217;architecture d&#8217;Axis2</a>.</p>
<p>Nous allons donc développer un <a href="http://ws.apache.org/axis2/1_4_1/modules.html">module</a> qui change dynamiquement l&#8217;URL de l&#8217;endpoint à appeler (on utilisera bien sûr Maven2 pour nous aider à créer et packager le projet&#8230;).</p>
<p><strong>1. Créer le projet</strong></p>
<p>Utilisons Maven2 pour créer un projet :</p>
<pre class="brush: bash;">
mvn archetype:generate
</pre>
<p>et je réponds bêtement a Maven quand il me pose des questions sur le groupId, l&#8217;artifactId, etc&#8230; Une fois créé, je génère le projet Eclipse associé et je l&#8217;importe (Eclipse fait aussi parti de mes grand amis) :</p>
<pre class="brush: bash;">
mvn eclipse:eclipse
</pre>
<p>Ill faut modifier le POM pour dire a Maven que l&#8217;on est en train de créer un projet qui n&#8217;est pas une librarie Java mais un module Axis2. Ceci est possible en spécifiant le type de projet dans le POM et en déclarant que l&#8217;on veut utiliser le plugin MAR fournit par Axis2 :</p>
<pre class="brush: xml;">

&lt;project ...&gt;

...

&lt;groupId&gt;foo.bar&lt;/groupId&gt;
&lt;artifactId&gt;reroute&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;mar&lt;/packaging&gt;

...

&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.axis2&lt;/groupId&gt;
&lt;artifactId&gt;axis2-kernel&lt;/artifactId&gt;
&lt;version&gt;1.5.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;

...

&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.axis2&lt;/groupId&gt;
&lt;artifactId&gt;axis2-mar-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;1.5.1&lt;/version&gt;
&lt;extensions&gt;true&lt;/extensions&gt;
&lt;configuration&gt;
&lt;moduleXmlFile&gt;src/main/META-INF/module.xml&lt;/moduleXmlFile&gt;
&lt;includeDependencies&gt;false&lt;/includeDependencies&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
...
&lt;/project&gt;
</pre>
<p><strong>2. Business code</strong></p>
<p>Créons maintenant notre handler (le module est en fait un handler Axis2 packagé dans une archive avec un descripteur de module). Pour faire simple, je vais étendre la classe AbstractHandler pour créer mon Handler de reroutage et remplacer le &#8216;target EPR&#8217; par le nouveau (bien sûr on peut faire quelque chose de beaucoup plus évolué, on va dire qu&#8217;ici tout part vers un seul service) :</p>
<pre class="brush: java;">
package net.chamerling.blog.axis2module.reroute;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.util.LoggingControl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author chamerling
 *
 */
public class ReRouteHandler extends AbstractHandler {
	private static final Log log = LogFactory.getLog(AbstractHandler.class);

	private static final String FINAL_EPR_PREFIX = &quot;http://localhost:8082/petals/proxy/&quot;;

	/**
	 * {@inheritDoc}
	 */
	public InvocationResponse invoke(MessageContext messageContext)
			throws AxisFault {
		EndpointReference toEPR = messageContext.getOptions().getTo();
		String finalEPR = FINAL_EPR_PREFIX + toEPR.getAddress();

		if (LoggingControl.debugLoggingAllowed &amp;&amp; log.isDebugEnabled()) {
			log.debug(&quot;Reroute Handler for message : &quot;
					+ messageContext.getMessageID());
			log.debug(&quot;Initial ToEPR is &quot; + toEPR.getAddress()
					+ &quot; and is changed to &quot; + finalEPR);
		}

		toEPR.setAddress(finalEPR);
		return InvocationResponse.CONTINUE;
	}
}
&lt;pre&gt;</pre>
<p>Avec Axis2 c&#8217;est &#8216;facile&#8217;, tout est dans le message context! Je viens de remplacer le service à appeler par le mien en modifiant le champ &#8216;address&#8217; du &#8216;EndpointReference&#8217;.</p>
<p><strong>3. Packager le module</strong></p>
<p>Pour créer un module avec le Handler que l&#8217;on vient de définir, il faut passer par l&#8217;écriture du fichier de description du module, le &#8216;module.xml&#8217;. Ici c&#8217;est simple :</p>
<pre class="brush: xml;">
&lt;module name=&quot;reroute&quot;&gt;
	&lt;OutFlow&gt;
		&lt;handler name=&quot;ReRouteHandler&quot; class=&quot;net.chamerling.blog.axis2module.reroute.ReRouteHandler&quot;&gt;
			&lt;order phase=&quot;reroutePhase&quot; /&gt;
		&lt;/handler&gt;
	&lt;/OutFlow&gt;
&lt;/module&gt;
&lt;pre&gt;</pre>
<p>Mon module s&#8217;appellera donc &#8216;reroute&#8217; et sera appelé que lors de la phase d&#8217;émission de message &#8216;OutFlow&#8217;. Plus d&#8217;informations sur ce qui est possible avec ce fichier sur le site d&#8217;Axis2.</p>
<p><strong>4. Configurer Axis2</strong></p>
<p>Il y a plusieurs façcons de dire à Axis2 d&#8217;utiliser le module que l&#8217;on vient de développer. En se basant sur la contrainte de départ, je n&#8217;ai pas le droit de modifier mes services donc je ne peux pas modifier le descripteur de service &#8217;service.xml&#8217;. Heureusement, j&#8217;ai accès au serveur et je peux modifier le fichier de configuration d&#8217;Axis2 &#8216;axis2.xml&#8217; :</p>
<pre class="brush: xml;">
...
&lt;!-- Engage the reroute module --&gt;
&lt;module ref=&quot;reroute&quot; /&gt;
...
&lt;phaseOrder type=&quot;OutFlow&quot;&gt;
	&lt;!--      user can add his own phases to this area  --&gt;
	&lt;phase name=&quot;soapmonitorPhase&quot; /&gt;
	&lt;phase name=&quot;OperationOutPhase&quot; /&gt;
	&lt;!--system predefined phase--&gt;
	&lt;!--these phase will run irrespective of the service--&gt;
	&lt;phase name=&quot;PolicyDetermination&quot; /&gt;
	&lt;phase name=&quot;reroutePhase&quot; /&gt;
	&lt;phase name=&quot;MessageOut&quot; /&gt;
	&lt;phase name=&quot;Security&quot; /&gt;
&lt;/phaseOrder&gt;
&lt;pre&gt;</pre>
<p>Je viens d&#8217;engager mon module pour tous les services et je l&#8217;ai aussi ajouté dans la collection de phases qui est appelé lors de l&#8217;émission d&#8217;un message. A chaque fois qu&#8217;un message est envoyé vers un service, on passe donc dans le module que l&#8217;on vient de développer. Je viens donc de modifier les services invoqués sans modifier le code client! Je reviendrais bientôt sur l&#8217;utilisation de ce genre de choses dans un vrai cas d&#8217;usage avec du REST, du SOAP, des PROXYs, de l&#8217;ESB distribué sur le Web (bien sûr avec <a href="http://petals.ow2.org">Petals ESB</a>), etc&#8230;</p>
<p><strong>Resources</strong></p>
<p>Le code de ce &#8216;tutoriel&#8217; est bien sûr disponible sur mon Google Code sous <a href="http://code.google.com/p/chamerling/source/browse/#svn/trunk/blog/reroute-axis2">http://code.google.com/p/chamerling/source/browse/#svn/trunk/blog/reroute-axis2</a>.</p><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/317/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=317&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/7LJTesrkw0Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/03/09/axis2-rerouter-vos-appels-de-services-sans-modifier-vote-code-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/03/09/axis2-rerouter-vos-appels-de-services-sans-modifier-vote-code-client/</feedburner:origLink></item>
		<item>
		<title>Maven2 : Deployer ses artefacts sur un repo alternatif en FTP ‘a la mano’</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/K7A7t9Fm6lU/</link>
		<comments>http://chamerling.wordpress.com/2010/03/08/maven2-deployer-ses-artefacts-sur-un-repo-alternatif-en-ftp-a-la-mano/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 10:24:00 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[maven]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[altDeploymentRepository]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[ftp]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=307</guid>
		<description><![CDATA[Le besoin du jour : &#171;&#160;J&#8217;ai des artefacts packagés avec Maven2 et je dois les partager avec des partenaires sans passer par un déploiement standard de mon projet mais en passant par un serveur FTP&#160;&#187;. En plus, en terme de contrainte majeure, je ne veux absolument pas modifier mes bon vieux POMs&#8230;
Bon, comme je le [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=307&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Le besoin du jour : &laquo;&nbsp;J&#8217;ai des artefacts packagés avec Maven2 et je dois les partager avec des partenaires sans passer par un déploiement standard de mon projet mais en passant par un serveur FTP&nbsp;&raquo;. En plus, en terme de contrainte majeure, je ne veux absolument pas modifier mes bon vieux POMs&#8230;</p>
<p>Bon, comme je le dis souvent &laquo;&nbsp;Google est ton ami&nbsp;&raquo;, mais aujourd&#8217;hui Google ne l&#8217;est pas (comme le temps dehors, de la neige en Mars a Montpellier, mais ou va-t-on?). Bref, faisons le bêtement :</p>
<pre class="brush: bash;">

mvn deploy -DaltDeploymentRepository=chamerling.maven.snapshot::default::ftp://ftpperso.free.fr/maven/repository/snapshot
</pre>
<p>Je viens de dire a Maven2 de déployer mon artefact sur un repository dont l&#8217;ID est chamerling.maven.snapshot (pour rappel, cela veut dire que Maven2 va aller chercher dans mon settings.xml un serveur dont l&#8217;ID est chamerling.maven.snapshot pour récupérer le login et le mot de passe) en FTP sur l&#8217;URL <a href="ftp://ftpperso.free.fr/maven/repository/snapshot" rel="nofollow">ftp://ftpperso.free.fr/maven/repository/snapshot</a>. Et c&#8217;est la que mon autre ami Maven2 (bon OK je n&#8217;ai que des amis virtuels&#8230;) me dit :</p>
<pre class="brush: plain;">

[INFO] Error retrieving previous build number for artifact 'foo:bar:pom': repository metadata for: 'snapshot foo:bar:1-SNAPSHOT' could not be retrieved from repository: chamerling.maven.snapshot due to an error: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp
Component descriptor cannot be found in the component repository: org.apache.maven.wagon.Wagonftp.
</pre>
<p>Ok bon c&#8217;est normal&#8230; Wagon est la librairie de transport abstraite utilisée par Maven2 et par défaut FTP n&#8217;est pas supporté. D&#8217;ailleurs sur le site du plugin deploy de Maven2 on remarque bien qu&#8217;il faut normalement définir dans le POM que l&#8217;on veut utiliser l&#8217;extension FTP de Wagon :</p>
<pre class="brush: xml;">

&lt;build&gt;
&lt;extensions&gt;
&lt;!-- Enabling the use of FTP --&gt;
&lt;extension&gt;
&lt;groupId&gt;org.apache.maven.wagon&lt;/groupId&gt;
&lt;artifactId&gt;wagon-ftp&lt;/artifactId&gt;
&lt;version&gt;1.0-beta-6&lt;/version&gt;
&lt;/extension&gt;
&lt;/extensions&gt;
&lt;/build&gt;
</pre>
<p>Oui mais moi je ne veux pas modifier mon POM! L&#8217;astuce c&#8217;est de rajouter l&#8217;extension FTP-Wagon dans le classpath de Maven2 ie ajouter la librairie Wagon FTP dans M2_HOME/lib et la &#8216;Oh Miracle&#8217;, ca ne marche pas&#8230;</p>
<pre class="brush: plain;">

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------

[INFO] Error retrieving previous build number for artifact 'foo:bar:pom': repository metadata for: 'snapshot foo:bar:1-SNAPSHOT' could not be retrieved from repository: chamerling.maven.snapshot due to an error: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp
org.apache.commons.net.ProtocolCommandListener
[INFO] ------------------------------------------------------------------------
</pre>
<p>Normal, Wagon FTP utilise commons-net pour tout ce qui est communication, j&#8217;ajoute donc le JAR de commons-net  2.0 dans mon M2_HOME/lib et là ça marche beaucoup mieux :</p>
<pre class="brush: plain;">

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
</pre><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/307/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=307&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/K7A7t9Fm6lU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/03/08/maven2-deployer-ses-artefacts-sur-un-repo-alternatif-en-ftp-a-la-mano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/03/08/maven2-deployer-ses-artefacts-sur-un-repo-alternatif-en-ftp-a-la-mano/</feedburner:origLink></item>
		<item>
		<title>Comment utiliser le SE-POJO (en 1 leçon)</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/QMl1_hzyxHg/</link>
		<comments>http://planet.petalslink.com/home/pygibello/2010/03/01/comment-utiliser-le-se-pojo-en-1-lecon/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 15:41:10 +0000</pubDate>
		<dc:creator>gibello</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://planet.petalslink.com/home/pygibello/?p=6</guid>
		<description><![CDATA[Avez-vous entendu parler du SE-POJO ?
Son principal avantage : pouvoir assez simplement scripter en java des traitements internes à Petals, éventuellement complexes. Par exemple :

Consommer des Endpoint, les orchestrer librement en fonction de conditions.
Faire des traitements spécifiques (comme lire un fichier à un format exotique, le convertir en XML, et l&#8217;envoyer à un autre Endpoint)
Etc&#8230;

Le [...]]]></description>
			<content:encoded><![CDATA[<p>Avez-vous entendu parler du SE-POJO ?</p>
<p>Son principal avantage : pouvoir assez simplement scripter en java des traitements internes à Petals, éventuellement complexes. Par exemple :</p>
<ul>
<li>Consommer des Endpoint, les orchestrer librement en fonction de conditions.</li>
<li>Faire des traitements spécifiques (comme lire un fichier à un format exotique, le convertir en XML, et l&#8217;envoyer à un autre Endpoint)</li>
<li>Etc&#8230;</li>
</ul>
<p>Le problème, c&#8217;est que le POJO est assez peu documenté, à ce jour : la doc est quand même utile, donc lisez-là (<a href="http://download.forge.objectweb.org/petals/petals-se-pojo-2.0.2-en.pdf" >http://download.forge.objectweb.org/petals/petals-se-pojo-2.0.2-en.pdf</a>).</p>
<h2>Etape 1 : Développer un POJO compatible avec Petals et le SE-POJO</h2>
<p>Sous PetalsStudio :</p>
<p>- Créer un projet java &#8220;classique&#8221;, qui contiendra le code de votre POJO. Ce projet aura besoin de librairies de Petals, notamment celles du CDK (component development kit).</p>
<p>Le meilleur moyen de se les procurer, c&#8217;est de dézipper un composant : par exemple, téléchargez le SE-POJO (de toutes façons, vous en aurez besoin), et dézippez-le.</p>
<p>Les librairies dont vous aurez besoin sont les suivantes ([version] désigne les numéros de version, qui peuvent varier&#8230; selon la version ! Prenez celles qui sont dans votre composant POJO) :</p>
<ul>
<li>petals-jbi-[version].jar</li>
<li>petals-cdk-jbidescriptor-[version].jar</li>
<li>petals-cdk-api-[version].jar</li>
<li>petals-cdk-core-[version].jar</li>
</ul>
<p>Copiez ces librairies dans un répertoire de votre projet java (par exemple, un répertoire &#8220;lib/&#8221;), et faites pointer le &#8220;Build path&#8221; d&#8217;Eclipse dessus.</p>
<p>- Créez un package et une classe dans les sources : ce sera l&#8217;implémentation de votre POJO.</p>
<p>Voici un exemple (cet exemple consomme un autre EndPoint : dans mon cas, un &#8220;FileTransfer&#8221; pour enregistrer le message, soit une SU déployée sur le BC-FILETRANSFER. Mais vous pouvez commenter tout le code qui consomme cet Endpoint, et vous contenter d&#8217;un POJO genre &#8220;Hello world&#8221; !) :</p>
<div style="border: 2px solid #000000;overflow: scroll;width: 480px;height: 380px;background-color: #ffffff">
<pre><code>
package org.ow2.petals.test;

import java.io.StringReader;

import javax.jbi.component.ComponentContext;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;

import org.ow2.petals.component.framework.api.Message.MEPConstants;
import org.ow2.petals.component.framework.api.message.Exchange;
import org.ow2.petals.component.framework.jbidescriptor.generated.Consumes;
import org.ow2.petals.component.framework.listener.AbstractJBIListener;

public class TestPojo {
  AbstractJBIListener jbiListener;
  ComponentContext ctx;

  public void setJBIListener(AbstractJBIListener jbiListener) {
    this.jbiListener = jbiListener;
  }
  public void setComponentContext(ComponentContext ctx) {
    this.ctx = ctx;
  }

  public boolean onExchange(Exchange exchange)
  throws Exception {

    // Consume a "provides" endpoint (referenced by Interface/Service/Endpoint name,
    // as specified in the "provides" endpoint's jbi.xml)
    Consumes ep = new Consumes();
    ep.setInterfaceName(new QName("http://petals.test.com", "WriteContentInterface"));
    ep.setServiceName(new QName("http://petals.test.com", "WriteContent"));
    ep.setEndpointName("TestFileEndpoint");

    System.out.println("POJO: before consume");
    Exchange out =
       jbiListener.createConsumeExchange(ep,MEPConstants.IN_ONLY_PATTERN);
    out.setInMessageContent(
       new StreamSource(new StringReader(
         "&lt;pojo&gt;Hello from Pojo !&lt;/pojo&gt;")));

    jbiListener.sendSync(out);
    System.out.println("POJO: consume done");

    // Answer if needed (In[Optional]Out)
    if(exchange.isInOutPattern() || exchange.isInOptionalOutPattern()) {
      System.out.println("POJO: sending response");
      exchange.setOutMessageContent(
         new StreamSource(new StringReader("&lt;pojo&gt;Ok&lt;/pojo&gt;")));
    }

    return true;
  }

  public void init() {
    System.out.println("SamplePojo inits.");
  }
}
</code></pre>
</div>
<p>- Une fois votre POJO prêt, vous devrez le packager sous forme de fichier .jar (File/Export/General/Java/Jar file).<br />
Le fichier .jar résultant pourra ensuite être intégré à votre SU POJO.</p>
<h2>Etape 2 : Créer la SU pour y intégrer votre POJO</h2>
<p>Sous PetalsStudio : File / New / Project / Petals / Use a Petals Technical Service / Use POJO.</p>
<p>Dans la fenêtre &#8220;WSDL File&#8221; (etc&#8230;)</p>
<ul>
<li>Spécifiez des &#8220;namespace&#8221; identiques pour l&#8217;interface et le service (çà doit ressembler à des URL&#8230; exemple : http://pojo.test.org).</li>
<li>Nommez vos Interface / Service / Endpoint à votre convenance.</li>
<li>Inutile de spécifier un WSDL.</li>
</ul>
<p>Dans la fenêtre &#8220;Jar Files&#8221; (etc&#8230;)</p>
<ul>
<li>Donnez le chemin d&#8217;accès vers le jar créé lors de l&#8217;étape précédente (bouton &#8220;browse&#8221;, sélectionnez le fichier jar)</li>
<li>Faites ensuite &#8220;Browse&#8221; pour la boîte &#8220;Service Class&#8221;, vous pourrez y choisir la classe du POJO présent dans votre jar.</li>
</ul>
<p>Terminez le processus (allez jusqu&#8217;à &#8220;Finish&#8221;, et cliquez dessus).</p>
<p>PetalsStudio va alors générer un projet &#8220;su-POJO-&lt;nom-du-projet&gt;-provide, avec un dossier &#8220;resources/&#8221; contenant le fichier jar du POJO, et un dossier META-INF contenant le descripteur de déploiement Petals (jbi.xml).</p>
<p><span style="color: #ff0000">Attention : la version 1.0 Beta2 de PetalsStudio comporte un bug&#8230; à tout hasard, éditez META-INF/jbi.xml. Si vous y trouvez la chaîne suivante :<br />
</span></p>
<p><span style="color: #ff0000">&#8220;</span><span style="color: #ff0000">http://petals.ow2.org/components/extensions/version-4.0&#8243;</span></p>
<p><span style="color: #ff0000">remplacez &#8220;4.0&#8243; par &#8220;5&#8243;, comme ceci :</span></p>
<p><span style="color: #ff0000">&#8220;</span><span style="color: #ff0000">http://petals.ow2.org/components/extensions/version-5&#8243;</span></p>
<p><span style="color: #ff0000">(puis sauvegardez).</span></p>
<p>Cliquez le projet avec le bouton droit, puis &#8220;Petals / Package for Petals&#8221;.</p>
<p>Vous aurez alors un fichier &#8220;sa-POJO-&lt;nom-du-projet&gt;-provide.zip&#8221;, prêt à être déployé dans Petals (comme SU associée au SE-POJO).</p>
<h2>Etape 3 : Déploiement sur Petals</h2>
<ul>
<li>Démarrez Petals</li>
<li>Déployez le SE-POJO</li>
<li>Déployez votre SU générée à l&#8217;étape 2 (sa-POJO-&lt;nom-du-projet&gt;-provide.zip).</li>
</ul>
<p>Et voilà le travail !</p>
<img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/QMl1_hzyxHg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/pygibello/2010/03/01/comment-utiliser-le-se-pojo-en-1-lecon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://planet.petalslink.com/home/pygibello/2010/03/01/comment-utiliser-le-se-pojo-en-1-lecon/</feedburner:origLink></item>
		<item>
		<title>Outils Petals ESB : Librarie pour binder des services Web</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/KpnvAbeqRRw/</link>
		<comments>http://chamerling.wordpress.com/2010/03/01/outils-petals-esb-librarie-pour-binder-des-services-web/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 11:29:55 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Petals ESB]]></category>
		<category><![CDATA[WebService]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jbi]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[soa]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=303</guid>
		<description><![CDATA[Dans un précédent article, je décrivais comment &#8216;proxifier&#8217; un Web service dans Petals ESB avec un plugin Maven maison. Ce plugin Maven utilise une librairie Java que j&#8217;ai développé pour lier et exposer des Web services dans/avec Petals ESB.
Le &#8216;problème&#8217; actuel de Petals ESB est qu&#8217;il est pleinement basé sur la spécification JBI, cela veut [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=303&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Dans un <a href="http://chamerling.wordpress.com/2009/06/02/proxify-web-services-in-petals-with-maven/">précédent article</a>, je décrivais comment &#8216;proxifier&#8217; un Web service dans <a href="http://petals.ow2.org">Petals ESB</a> avec un plugin Maven maison. Ce plugin Maven utilise une librairie Java que j&#8217;ai développé pour lier et exposer des Web services dans/avec Petals ESB.</p>
<p>Le &#8216;problème&#8217; actuel de Petals ESB est qu&#8217;il est <strong>pleinement</strong> basé sur la spécification JBI, cela veut dire que actuellement, si on veut exposer un service JBI en tant que Web service, il faut créer un fichier de configuration (le fameux JBI.xml), le packager dans une unité de service (Service Unit &#8211; SU), et packager cette SU dans un assemblage de services (Service Assembly &#8211; SA). Bien sur des outils comme le Petals Studio sont la pour aider les développeurs à intégrer leurs services, moi je me place plus dans la peau du &#8216;Core Developper&#8217; et je pour le moment je n&#8217;ai pas eu l&#8217;utilité d&#8217;outils graphiques pour configurer Petals.</p>
<p>Dans une de mes taches actuelles, je suis en train d&#8217;étendre Petals pour le faire communiquer sur Internet et je développe ce que j&#8217;appelle l&#8217;API de Monitoring &amp; Management (M&amp;M API) qui est exposée (pour le moment seulement) en Web service. La partie Management de l&#8217;API doit permettre à un administrateur de la plateforme, de &#8216;binder&#8217; des services (Web, REST, &#8230;) sans se soucier de la partie JBI.<br />
L&#8217;API fournit donc une opération du style <em>bind(URI wsdl). </em>Coté serveur, j&#8217;utilise :</p>
<ol>
<li>Une librairie maison de génération de SA</li>
<li>Je déploie localement cette SA pour &#8216;binder&#8217; un Web service au bus.</li>
<li>J&#8217;expose ce service de management avec la feature expliquée dans ce <a href="http://chamerling.wordpress.com/2009/10/07/exposing-fractal-components-as-webservices-in-petals-esb/">post</a></li>
</ol>
<p>Un exemple d&#8217;utilisation de la librairie est donné dans le listing suivant (binder au bus, le Service Web Version de Axis2) :</p>
<pre class="brush: java;">

package org.ow2.petals.tools.generator.jbi;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import org.ow2.petals.tools.generator.jbi.api.JBIGenerationException;
import org.ow2.petals.tools.generator.jbi.ws2jbi.WS2Jbi;

public class BindAxis2Version {

public static void main(String[] args) throws JBIGenerationException, URISyntaxException {

String wsdl = &quot;http://localhost:8080/axis2/services/Version?wsdl&quot;;
Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

// let's say that we want to generate SA for SOAP component 4.0
map.put(org.ow2.petals.tools.generator.commons.Constants.COMPONENT_VERSION, &quot;4.0&quot;);

URI wsdlURI = new URI(wsdl);

File f = new WS2Jbi(wsdlURI, map).generate();

System.out.println(&quot;Service Assembly is available at &quot; + f.getAbsolutePath());

}
}
</pre>
<p>Pour utiliser WS2Jbi, utilisez dans votre projet Maven, la dépendance :</p>
<pre class="brush: xml;">

&lt;dependency&gt;

&lt;groupId&gt;org.ow2.petals.sandbox&lt;/groupId&gt;

&lt;artifactId&gt;petals-ws2jbi&lt;/artifactId&gt;

&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;

&lt;/dependency&gt;
</pre>
<p>Celle ci est normalement disponible est mise a jour régulièrement sur le repository Maven d&#8217;OW2 <a href="http://maven.ow2.org/maven2-snapshot/">http://maven.ow2.org/maven2-snapshot/</a>. Les sources sont disponibles dans ma <a href="http://websvn.ow2.org/listing.php?repname=petals&amp;path=%2Fsandbox%2Fchamerling%2F#path_sandbox_chamerling_">Sandbox Petals</a>.</p><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/303/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/303/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=303&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/KpnvAbeqRRw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/03/01/outils-petals-esb-librarie-pour-binder-des-services-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/03/01/outils-petals-esb-librarie-pour-binder-des-services-web/</feedburner:origLink></item>
		<item>
		<title>Maven est ton ami #2 : Effective POM</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/KqYl6bcbPl8/</link>
		<comments>http://chamerling.wordpress.com/2010/03/01/maven-est-ton-ami-2-effective-pom/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 10:34:51 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[maven]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=298</guid>
		<description><![CDATA[Après &#171;&#160;Maven est ton ami #1 : Dependency tree&#171;&#160;, le court article du jour est juste une note pour les personnes qui se (et me) demandent souvent pourquoi ils n&#8217;arrivent pas a releaser (entre autres)&#8230;
Ce qui est bien avec Maven2, c&#8217;est que l&#8217;on peut &#8216;overrider&#8217;, utiliser des parents, définir ses mots de passe sans les [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=298&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Après &laquo;&nbsp;<a href="http://chamerling.wordpress.com/2009/07/22/maven-est-ton-ami-1-dependency-tree/">Maven est ton ami #1 : Dependency tree</a>&laquo;&nbsp;, le court article du jour est juste une note pour les personnes qui se (et me) demandent souvent pourquoi ils n&#8217;arrivent pas a releaser (entre autres)&#8230;<br />
Ce qui est bien avec Maven2, c&#8217;est que l&#8217;on peut &#8216;overrider&#8217;, utiliser des parents, définir ses mots de passe sans les publier publiquement&#8230; Mais ce qui est moins bien, quand on ne maitrise pas Maven, c&#8217;est que l&#8217;on se perd vite dans toutes ses configurations (ajoutez par dessus un proxy, de l&#8217;authentification, des repositories privés&#8230;). Est c&#8217;est la que l&#8217;on se demande comment on peut s&#8217;y retrouver&#8230;</p>
<p>Heureusement, les gens de chez Maven2 ne sont pas si bêtes, le <a href="http://maven.apache.org/plugins/maven-help-plugin/usage.html">plugin Help</a> permet de lister le POM effectif du projet courant en lancant la commande</p>
<blockquote><p><em># mvn help:effective-pom</em></p></blockquote>
<p>Simple et efficace. Les gens qui se demandent, par exemple, pourquoi ils ne sont pas bien authentifiés lors d&#8217;une release peuvent alors verifier dans le POM généré, que leurs login/password ne sont pas définis pour le bon ID de serveur&#8230;</p><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=298&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/KqYl6bcbPl8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/03/01/maven-est-ton-ami-2-effective-pom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/03/01/maven-est-ton-ami-2-effective-pom/</feedburner:origLink></item>
		<item>
		<title>One more JBI component : SOAP Proxy</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/gCw3dShqZhk/</link>
		<comments>http://chamerling.wordpress.com/2010/02/02/one-more-jbi-component-soap-proxy/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 14:38:22 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Petals ESB]]></category>
		<category><![CDATA[WebService]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jbi]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[ow2]]></category>
		<category><![CDATA[soa]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=287</guid>
		<description><![CDATA[I just developped a new JBI component for Petals ESB. This component, named &#8216;petals-bc-soapproxy&#8217; is based on the work I did on the standard SOAP binding component and provide an easy way to proxify SOAP based Web services with Petals ESB.
This component, based on Apache Axis2, uses a small part of WS-Addressing to provide the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=287&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I just developped a new JBI component for <a href="http://petals.ow2.org">Petals ESB</a>. This component, named &#8216;petals-bc-soapproxy&#8217; is based on the work I did on the standard SOAP binding component and provide an easy way to proxify SOAP based Web services with Petals ESB.</p>
<p>This component, based on Apache Axis2, uses a small part of WS-Addressing to provide the proxy feature. &#8216;Small part&#8217; means that for now, by using Axis2, I need to bypass the mustUnderstand attribute of the WS-Addressing elements. Why? Because I need to use the WSA:To element to specify the Web service I want to finally invoke and I need to set the mustUnderstand attribute to false to bypass one implementation detail on Axis2 which is not &#8216;friendly&#8217; with my own implementation. Why (again)?&#8230; By setting some mustUnderstand attribute to true in the SOAP message header, it means that the SOAP engine (ie Axis2) must understand the header during message processing. A mustUnderstand attribute set to true in the WS-Addressing header means that the SOAP engine must handle the WS-Addressing information and here I do not want to. If I set this attribute to true, I need to add the Axis2 addressing module, which will handle the WS-Addressing header, and will put all the addressing information in the Axis2 message context. I can do that and get the information from this context for for some reason it does not work like I expect&#8230; Maybe an Axis2 update will fix this&#8230;Need some time to investigate, and for now time is not my friend&#8230; So, here is how it work :</p>
<p><strong>1.</strong> The SOAP client sends the SOAP message to the Petals SOAP Proxy (by default this service is exposed at <a href="http://localhost:8085/petals/services/SOAPProxyWebService)" rel="nofollow">http://localhost:8085/petals/services/SOAPProxyWebService)</a>. The SOAP message header contains the WS-Addressing information which will be used to reach the final Web service. A SOAP message sample is for example :</p>
<pre class="brush: xml;">

&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:wsap=&quot;http://wsapi.petals.dsb.soa4all.eu/&quot;&gt;
&lt;soapenv:Header xmlns:wsa=&quot;http://www.w3.org/2005/08/addressing&quot;&gt;
&lt;wsa:Action&gt;http://wsapi.petals.dsb.soa4all.eu/HelloService/sayHello&lt;/wsa:Action&gt;
&lt;wsa:To&gt;http://localhost:7600/petals/ws/HelloService&lt;/wsa:To&gt;
&lt;/soapenv:Header&gt;
&lt;soapenv:Body&gt;
&lt;wsap:sayHello&gt;
&lt;!--Optional:--&gt;
&lt;arg0&gt;Say hello!&lt;/arg0&gt;
&lt;/wsap:sayHello&gt;
&lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;
</pre>
<p>where <a href="http://localhost:7600/petals/ws/HelloService" rel="nofollow">http://localhost:7600/petals/ws/HelloService</a> is the final Web service I want to invoke.</p>
<p><strong>2.</strong> The SOAP message is handled by the SOAP proxy component, transformed as JBI message and sent to the right JBI endpoint.</p>
<p><strong>3.</strong> The JBI endpoint gets the WS-Addressing information from the JBI message, the SOAP message from the JBI message payload and send all of this stuff to the final Web service. Invokcation response is sent back to the initial consumer through the ESB.</p>
<p>A simple schema of what happens with three ESB nodes is given in the figure below :</p>
<p><a href="http://chamerling.files.wordpress.com/2010/02/diapositive5.jpg"><img class="aligncenter size-full wp-image-288" title="Diapositive5" src="http://chamerling.files.wordpress.com/2010/02/diapositive5.jpg?w=500&#038;h=375" alt="" width="500" height="375" /></a></p>
<p>So, the main question is why using such a proxy and why not invoking the service directly? There are many answers to these questions and since I already said that the time is a missing resource, it will be probably part of a future article&#8230;</p>
<p>The first version of the component is available on the OW2 SVN repository under my sandbox (have a look to <a href="http://websvn.ow2.org/listing.php?repname=petals&amp;path=%2Fsandbox%2Fchamerling%2Fproxy%2Fpetals-bc-soap%2F#path_sandbox_chamerling_proxy_petals-bc-soap_">http://websvn.ow2.org/listing.php?repname=petals&amp;path=%2Fsandbox%2Fchamerling%2Fproxy%2Fpetals-bc-soap%2F#path_sandbox_chamerling_proxy_petals-bc-soap_</a>)</p>
<p>Note : Using <a href="http://soapui.org">SOAPUI</a> for WS-Addressing testing works fine (even if I had some exchanges with SOAPUI guy (<a href="http://twitter.com/olensmar" rel="nofollow">http://twitter.com/olensmar</a>) on Twitter&#8230;)&#8230; Sorry to have doubts on SOAPUI!</p><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/287/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=287&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/gCw3dShqZhk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/02/02/one-more-jbi-component-soap-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/02/02/one-more-jbi-component-soap-proxy/</feedburner:origLink></item>
		<item>
		<title>PetalsStudio ou Eclipse Linux : problème de clic souris sur les boutons ?</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/mvul5P65OTY/</link>
		<comments>http://planet.petalslink.com/home/pygibello/2010/01/25/petalsstudio-ou-eclipse-linux-probleme-de-clic-souris-sur-les-boutons/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 15:48:03 +0000</pubDate>
		<dc:creator>gibello</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[PetalsStudio / Eclipse]]></category>
		<category><![CDATA[PetalsStudio Eclipse souris]]></category>

		<guid isPermaLink="false">http://planet.petalslink.com/home/pygibello/2010/01/25/petalsstudio-ou-eclipse-linux-probleme-de-clic-souris-sur-les-boutons/</guid>
		<description><![CDATA[Symptôme : le clic sur certains boutons (particulièrement les wizards de création de projet &#8211; boutons &#8220;next&#8221;, &#8220;cancel&#8221;, etc&#8230;) reste sans effet, alors que les raccourcis clavier fonctionnent.
Le même problème se produit sur un Eclipse &#8220;standard&#8221;.
Constaté sur un Ubuntu 9.10, ce problème a également été signalé sur d&#8217;autres Linux.
Solution : positionner la variable d&#8217;environnement GDK_NATIVE_WINDOWS [...]]]></description>
			<content:encoded><![CDATA[<p>Symptôme : le clic sur certains boutons (particulièrement les wizards de création de projet &#8211; boutons &#8220;next&#8221;, &#8220;cancel&#8221;, etc&#8230;) reste sans effet, alors que les raccourcis clavier fonctionnent.<br />
Le même problème se produit sur un Eclipse &#8220;standard&#8221;.<br />
Constaté sur un Ubuntu 9.10, ce problème a également été signalé sur d&#8217;autres Linux.</p>
<p>Solution : positionner la variable d&#8217;environnement GDK_NATIVE_WINDOWS à &#8220;true&#8221;.</p>
<p>Exemple :<br />
$ GDK_NATIVE_WINDOWS=true PetalsStudio</p>
<p>Ou:<br />
$ export GDK_NATIVE_WINDOWS=true<br />
$ PetalsStudio</p>
<img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/mvul5P65OTY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/pygibello/2010/01/25/petalsstudio-ou-eclipse-linux-probleme-de-clic-souris-sur-les-boutons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://planet.petalslink.com/home/pygibello/2010/01/25/petalsstudio-ou-eclipse-linux-probleme-de-clic-souris-sur-les-boutons/</feedburner:origLink></item>
		<item>
		<title>Adding Routing modules in Petals ESB</title>
		<link>http://feedproxy.google.com/~r/PetalsPlanet/~3/tay8fhIpCsk/</link>
		<comments>http://chamerling.wordpress.com/2010/01/21/adding-routing-modules-in-petals-esb/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 14:01:46 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Petals ESB]]></category>
		<category><![CDATA[fractal]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ow2]]></category>
		<category><![CDATA[soa]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">http://chamerling.wordpress.com/?p=279</guid>
		<description><![CDATA[Petals ESB is based on a highly modular architecture built using software components based on the Fractal component model.
In a previous article about WSDM monitoring (http://chamerling.wordpress.com/2009/11/04/petals-esb-live-monitoring-with-wsdm-and-gwt/), I was speaking about adding routing modules to the ESB router to intercept messages and to notify the monitoring system that messages are transmitted and received between service consumers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&#38;blog=3069558&#38;post=279&#38;subd=chamerling&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://petals.ow2.org">Petals ESB</a> is based on a highly modular architecture built using software components based on the <a href="http://fractal.ow2.org">Fractal</a> component model.</p>
<p>In a previous article about WSDM monitoring (<a href="http://chamerling.wordpress.com/2009/11/04/petals-esb-live-monitoring-with-wsdm-and-gwt/">http://chamerling.wordpress.com/2009/11/04/petals-esb-live-monitoring-with-wsdm-and-gwt/</a>), I was speaking about adding routing modules to the ESB router to intercept messages and to notify the monitoring system that messages are transmitted and received between service consumers and providers.</p>
<p>In the current article, I am going to show you how you can add modules to the routing layer of the service bus. In short, the routing layer is the component which select the right endpoint(s) to send the current message to. The routing layer has been decomposed into routing modules which are all called when a message is sent or received.</p>
<p>There are two types of routing modules the SenderModule (org.ow2.petals.jbi.messaging.routing.module.SenderModule) and the ReceiverModule (org.ow2.petals.jbi.messaging.routing.module.ReceiverModule) which both have right names <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . All the sender modules will be called on message emission, the receiver ones will be called at message reception&#8230; Here are the Java APIs :</p>
<p><strong><em>org.ow2.petals.jbi.messaging.routing.module.SenderModule</em></strong></p>
<pre class="brush: java;">

package org.ow2.petals.jbi.messaging.routing.module;

import java.util.Map;
import org.ow2.petals.jbi.component.context.ComponentContext;
import org.ow2.petals.jbi.messaging.endpoint.ServiceEndpoint;
import org.ow2.petals.jbi.messaging.exchange.MessageExchange;
import org.ow2.petals.jbi.messaging.routing.RoutingException;
import org.ow2.petals.transport.util.TransportSendContext;

public interface SenderModule {

void electEndpoints(final Map&lt;ServiceEndpoint, TransportSendContext&gt; electedEndpoints,

final ComponentContext sourceComponentContext, final MessageExchange exchange)

throws RoutingException;

}
</pre>
<p><strong><em>org.ow2.petals.jbi.messaging.routing.module.ReceieverModule</em></strong></p>
<pre class="brush: java;">

package org.ow2.petals.jbi.messaging.routing.module;

import org.ow2.petals.jbi.component.context.ComponentContext;
import org.ow2.petals.jbi.messaging.exchange.MessageExchange;
import org.ow2.petals.jbi.messaging.routing.RoutingException;

public interface ReceiverModule {

boolean receiveExchange(final MessageExchange exchange,

final ComponentContext sourceComponentContext) throws RoutingException;

}
</pre>
<p>Implementing and adding modules to the Petals ESB router steps</p>
<p>1. Step one : Create your routing module by implementing the Sender and/or Receiver module interface(s) like, for example, just logging exchange information and date :</p>
<pre class="brush: java;">

package com.googlecode.chamerling.blog.petals.router;

import java.util.Date;

import java.util.Map;

import org.objectweb.fractal.fraclet.annotation.annotations.FractalComponent;

import org.objectweb.fractal.fraclet.annotation.annotations.Interface;

import org.objectweb.fractal.fraclet.annotation.annotations.LifeCycle;

import org.objectweb.fractal.fraclet.annotation.annotations.Monolog;

import org.objectweb.fractal.fraclet.annotation.annotations.Provides;

import org.objectweb.fractal.fraclet.annotation.annotations.type.LifeCycleType;

import org.objectweb.util.monolog.api.Logger;

import org.ow2.petals.jbi.component.context.ComponentContext;

import org.ow2.petals.jbi.messaging.endpoint.ServiceEndpoint;

import org.ow2.petals.jbi.messaging.exchange.MessageExchange;

import org.ow2.petals.jbi.messaging.routing.RoutingException;

import org.ow2.petals.jbi.messaging.routing.module.ReceiverModule;

import org.ow2.petals.jbi.messaging.routing.module.SenderModule;

import org.ow2.petals.transport.util.TransportSendContext;

import org.ow2.petals.util.LoggingUtil;

@FractalComponent

@Provides(interfaces = {

@Interface(name = &quot;logSender&quot;, signature = SenderModule.class),

@Interface(name = &quot;logReceiver&quot;, signature = ReceiverModule.class) })

public class LogModule implements SenderModule, ReceiverModule {

@Monolog(name = &quot;logger&quot;)

private Logger logger;

private LoggingUtil log;

/**

* {@inheritDoc}

*/

public void electEndpoints(

Map&lt;ServiceEndpoint, TransportSendContext&gt; electedEndpoints,

ComponentContext sourceComponentContext, MessageExchange exchange)

throws RoutingException {

this.log.info(LogModule.class.getCanonicalName()

+ &quot; router module is sending a message exchange with ID = &quot;

+ exchange.getExchangeId() + &quot; at &quot; + new Date());

for (ServiceEndpoint endpoint : electedEndpoints.keySet()) {

this.log.info(&quot;Selected endpoint : &quot; + endpoint.getEndpointName());

}

// Do what you want...

}

/**

* {@inheritDoc}

*/

public boolean receiveExchange(MessageExchange exchange,

ComponentContext sourceComponentContext) throws RoutingException {

this.log.info(LogModule.class.getCanonicalName()

+ &quot; router module is receiving a message exchange with ID = &quot;

+ exchange.getExchangeId() + &quot; at &quot; + new Date());

// Do what you want...

return false;

}

@LifeCycle(on = LifeCycleType.START)

protected void start() {

this.log = new LoggingUtil(this.logger);

this.log.debug(&quot;Starting...&quot;);

}

@LifeCycle(on = LifeCycleType.STOP)

protected void stop() {

this.log.debug(&quot;Stopping...&quot;);

}

}
</pre>
<p>Note that the Fractal annotations are mandatory!</p>
<p>2. Add the modules to the Fractal descriptor files. The modules MUST be added to the JBI-Messaging.fractal configuration file (located in the src/main/resources of your favorite Petals ESB distribution) :</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;!DOCTYPE definition PUBLIC &quot;-//ow2.objectweb//DTD Fractal ADL 2.0//EN&quot; &quot;classpath://org/objectweb/fractal/adl/xml/standard.dtd&quot;&gt;

&lt;definition extends=&quot;JBI-MessagingType&quot; name=&quot;JBI-Messaging&quot;&gt;

&lt;component definition=&quot;org.ow2.petals.jbi.messaging.registry.DistributedEndpointRegistryImpl&quot; name=&quot;EndpointRegistryImpl&quot;/&gt;

&lt;component definition=&quot;org.ow2.petals.jbi.messaging.routing.RouterServiceImpl&quot; name=&quot;RouterServiceImpl&quot;/&gt;

&lt;component definition=&quot;org.ow2.petals.jbi.messaging.routing.module.TransportResolverModule&quot; name=&quot;TransportResolverModule&quot;/&gt;

&lt;component definition=&quot;org.ow2.petals.jbi.messaging.routing.module.EndpointResolverModule&quot; name=&quot;EndpointResolverModule&quot;/&gt;

&lt;component definition=&quot;org.ow2.petals.jbi.messaging.control.JMXExchangeCheckerClientImpl&quot; name=&quot;ExchangeCheckerClientImpl&quot;/&gt;

&lt;!-- My logging module --&gt;
&lt;component definition=&quot;com.googlecode.chamerling.blog.petals.router.LogModule&quot; name=&quot;LogModuleImpl&quot;/&gt;

&lt;!-- Expose --&gt;

&lt;binding client=&quot;this.router&quot; server=&quot;MonitoringModuleImpl.service&quot;/&gt;

&lt;binding client=&quot;this.transportlistener&quot; server=&quot;RouterServiceImpl.transportlistener&quot;/&gt;

&lt;binding client=&quot;this.endpoint&quot; server=&quot;EndpointRegistryImpl.service&quot;/&gt;

&lt;binding client=&quot;this.exchangechecker&quot; server=&quot;ExchangeCheckerClientImpl.service&quot;/&gt;

&lt;binding client=&quot;this.storage&quot; server=&quot;MonitoringStorageServiceImpl.service&quot;/&gt;

&lt;binding client=&quot;MonitoringModuleImpl.router&quot; server=&quot;RouterServiceImpl.service&quot;/&gt;

&lt;binding client=&quot;MonitoringModuleImpl.storageService&quot; server=&quot;MonitoringStorageServiceImpl.service&quot;/&gt;

&lt;binding client=&quot;EndpointRegistryImpl.configuration&quot; server=&quot;this.configuration&quot;/&gt;

&lt;binding client=&quot;EndpointRegistryImpl.topology&quot; server=&quot;this.topology&quot;/&gt;

&lt;!-- Add logging module to router --&gt;

&lt;binding client=&quot;RouterServiceImpl.sendermodule-3&quot; server=&quot;LogModuleImpl.logSender&quot;/&gt;

&lt;binding client=&quot;RouterServiceImpl.receivermodule-1&quot; server=&quot;LogModuleImpl.logReceiver&quot;/&gt;

&lt;!-- router --&gt;

&lt;binding client=&quot;RouterServiceImpl.transporter-local&quot; server=&quot;this.transporter-local&quot;/&gt;

&lt;binding client=&quot;RouterServiceImpl.transporter-tcp&quot; server=&quot;this.transporter-tcp&quot;/&gt;

&lt;!--the order of collection of bindings is alphabetically inversed --&gt;

&lt;binding client=&quot;RouterServiceImpl.sendermodule-2&quot; server=&quot;EndpointResolverModule.service&quot;/&gt;

&lt;binding client=&quot;RouterServiceImpl.sendermodule-1&quot; server=&quot;TransportResolverModule.service&quot;/&gt;

&lt;binding client=&quot;EndpointResolverModule.configuration&quot; server=&quot;this.configuration&quot;/&gt;

&lt;binding client=&quot;EndpointResolverModule.topology&quot; server=&quot;this.topology&quot;/&gt;

&lt;binding client=&quot;EndpointResolverModule.endpoint&quot; server=&quot;EndpointRegistryImpl.service&quot;/&gt;

&lt;binding client=&quot;EndpointResolverModule.checker&quot; server=&quot;ExchangeCheckerClientImpl.service&quot;/&gt;

&lt;binding client=&quot;TransportResolverModule.configuration&quot; server=&quot;this.configuration&quot;/&gt;

&lt;binding client=&quot;ExchangeCheckerClientImpl.jmx&quot; server=&quot;this.jmx&quot;/&gt;
&lt;/definition&gt;
</pre>
<p>Important things here are :</p>
<p>1. Instantiate the component with line</p>
<pre class="brush: xml;">
&lt;component definition=&quot;com.googlecode.chamerling.blog.petals.router.LogModule&quot; name=&quot;LogModuleImpl&quot;/&gt;
</pre>
<p>2. Adding the module to sender and receiver modules list :</p>
<pre class="brush: xml;">

&lt;binding client=&quot;RouterServiceImpl.sendermodule-3&quot; server=&quot;LogModuleImpl.logSender&quot;/&gt;

&lt;binding client=&quot;RouterServiceImpl.receivermodule-1&quot; server=&quot;LogModuleImpl.logReceiver&quot;/&gt;
</pre>
<p>Note that the lists are alphabetically inversed (The logger module &laquo;&nbsp;sendermodule-3&#8243; will be called before the sendermodule-2 and the sendermodule-1 modules).</p>
<p>Here we are, the module will be called at each message emission/reception. Note that this is a basic usage of routing modules, you can do many things with these modules like real time monitoring, security check, authentication, endpoint filtering, content based routing, etc etc etc</p><br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chamerling.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chamerling.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chamerling.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chamerling.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chamerling.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chamerling.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chamerling.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chamerling.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chamerling.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chamerling.wordpress.com/279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chamerling.wordpress.com&blog=3069558&post=279&subd=chamerling&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/PetalsPlanet/~4/tay8fhIpCsk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://chamerling.wordpress.com/2010/01/21/adding-routing-modules-in-petals-esb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://chamerling.wordpress.com/2010/01/21/adding-routing-modules-in-petals-esb/</feedburner:origLink></item>
	</channel>
</rss>
