<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>redstream &#187; Technical</title>
	<atom:link href="http://www.redstream.nl/category/technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redstream.nl</link>
	<description>Pragmatic Integrators</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Parameters in Your Mule Configuration Files</title>
		<link>http://www.redstream.nl/2012/01/27/using-parameters-in-your-mule-configuration-files/</link>
		<comments>http://www.redstream.nl/2012/01/27/using-parameters-in-your-mule-configuration-files/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:31:59 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Mule3]]></category>
		<category><![CDATA[XML/ XSD/ XSLT]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2915</guid>
		<description><![CDATA[Although I am not always happy with the online documentation of the Mule ESB I found this article quite good. I have set up our configuration of Mule ESB implementation on several projects this way and it has proved to &#8230; <a href="http://www.redstream.nl/2012/01/27/using-parameters-in-your-mule-configuration-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2012%2F01%2F27%2Fusing-parameters-in-your-mule-configuration-files%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2012%2F01%2F27%2Fusing-parameters-in-your-mule-configuration-files%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Although I am not always happy with the online documentation of the <a href="http://www.mulesoft.org/">Mule ESB</a> I found <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Using+Parameters+in+Your+Configuration+Files">this article</a> quite good. I have set up our configuration of Mule ESB implementation on several projects this way and it has proved to be working nicely. Although last time I got into the following issue. To use a datasource in my Mule3 project I had configured it like this in my Mule config file:</p>

<div class="wp_codebox"><table><tr id="p29153"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p2915code3"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jdbc:oracle-data-source</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbcDataSource&quot;</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;${db.username}&quot;</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;${db.password}&quot;</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">host</span>=<span style="color: #ff0000;">&quot;${db.host}&quot;</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;${db.port}&quot;</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">sid</span>=<span style="color: #ff0000;">&quot;{db.sid}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>However, when I deployed the application on my Mule instance I got the following XML parse exception:</p>
<blockquote><p>
org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: &#8216;${db.port}&#8217; is not a valid value for &#8216;integer&#8217;.
</p></blockquote>
<p>This is caused by the fact that the XML is validated against its XSD before the parameters are resolved. Although I found threads in several forums that described a solution for this issue I chose the following (pragmatic) solution. I decided to configure the datasource like this:</p>

<div class="wp_codebox"><table><tr id="p29154"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p2915code4"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jdbc:oracle-data-source</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbcDataSource&quot;</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;${db.username}&quot;</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;${db.password}&quot;</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;jdbc:oracle:thin:@//${db.host}:${db.port}/${db.sid}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>This way the XML validates fine against its XSD and during runtime the parameters are resolved.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2012/01/27/using-parameters-in-your-mule-configuration-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Mule3 as WS-Security proxy</title>
		<link>http://www.redstream.nl/2012/01/22/use-mule3-as-ws-security-proxy/</link>
		<comments>http://www.redstream.nl/2012/01/22/use-mule3-as-ws-security-proxy/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 13:48:05 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Mule3]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[CXF]]></category>
		<category><![CDATA[WSS4J]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2902</guid>
		<description><![CDATA[As I wrote before it is quite easy to set up a web service proxy with Mule3. in this example I take it a step further and I describe how you can add WS-Security implementation to it. Although in the &#8230; <a href="http://www.redstream.nl/2012/01/22/use-mule3-as-ws-security-proxy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2012%2F01%2F22%2Fuse-mule3-as-ws-security-proxy%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2012%2F01%2F22%2Fuse-mule3-as-ws-security-proxy%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>As I wrote <a href="http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/" title="Set up Web Service Proxy with Mule3">before</a> it is quite easy to set up a web service proxy with Mule3. in this example I take it a step further and I describe how you can add WS-Security implementation to it. Although in the end this also is quite easy you have to make the correct configuration choices to get everything to work.</p>
<p>The first thing I had to do in my Mule config was to drop the pattern prefix. This took me a while to discover because I think this isn&#8217;t very clear in the documentation. Anyway, after that change it is fairly straight forward.<br />
<span id="more-2902"></span><br />
Here is the Mule config I ended up with:</p>

<div class="wp_codebox"><table><tr id="p29027"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
</pre></td><td class="code" id="p2902code7"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/core&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:cxf</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/cxf&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:spring</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:http</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/http&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.2/mule-cxf.xsd</span>
<span style="color: #009900;">        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;flow</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;create-client&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;http:inbound-endpoint</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://localhost:8080/create-client&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cxf:proxy-service</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/http:inbound-endpoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;http:outbound-endpoint</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://localhost:8081/create-client&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cxf:proxy-client<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cxf:outInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;action&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Timestamp Signature&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;user&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${signature.user}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;signaturePropFile&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;ws-security.properties&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;passwordCallbackClass&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nl.redstream.adapter.MyKeystorePasswordCallback&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.cxf.interceptor.LoggingOutInterceptor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cxf:outInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cxf:proxy-client<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/http:outbound-endpoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/flow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;flow</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;get-client-status&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;http:inbound-endpoint</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://localhost:8081/get-status&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cxf:proxy-service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cxf:inInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.cxf.interceptor.LoggingInInterceptor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;action&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Signature&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;signaturePropFile&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;ws-security.properties&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cxf:inInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cxf:proxy-service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/http:inbound-endpoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;http:outbound-endpoint</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://localhost:8080/get-status&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cxf:proxy-client</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/http:outbound-endpoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/flow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>As you can see I have added two flows. The first flow is &#8216;create-client&#8217;. I receive the incoming call from my own &#8216;inside&#8217;-application and add a signature and timestamp to it before I forward it to the &#8216;outside&#8217; service.<br />
The second flow works the other way around: I receive a signed message from the &#8216;outside&#8217; client app and I need to validate this before I pas the message to my &#8216;inside&#8217; application. To create the signature I need the password for to make use of my private key in the keystore. To supply this password I simply implemented the PasswordCallbackHandler that returns the corresponding password by looking it up in a property file. For more info about configuring the WS-security with CFX see <a href="https://cwiki.apache.org/CXF20DOC/ws-security.html" title="CXF ws-security" target="_blank">here</a> and also I found <a href="http://ws.apache.org/wss4j/config.html" title="Apache WSS4J" target="_blank">this</a> entry about Apache WSS4J quite handy.<br />
The security property file that is referred to in my Mule config file contains the following:</p>

<div class="wp_codebox"><table><tr id="p29028"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p2902code8"><pre class="text" style="font-family:monospace;">org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=JKS
org.apache.ws.security.crypto.merlin.file=/KeyStores/redstreamKeystore.jks
org.apache.ws.security.crypto.merlin.keystore.password=myPassword</pre></td></tr></table></div>

<p>For both flows I added the logging interceptor which is quite handy during testing and developing to see what is received and sent out. In the next post I will show how to generate the keystores and configure SoapUI to test the proxy manually.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2012/01/22/use-mule3-as-ws-security-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automagically deploy your web application using the Maven Cargo plugin.</title>
		<link>http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/</link>
		<comments>http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 12:09:01 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2863</guid>
		<description><![CDATA[Last week I optimized the deployment process of a number of Mavenized projects. I noticed that the way I automated the project was not yet (fully) known by the developers. This is why I decided to write this blogpost. It &#8230; <a href="http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F07%2Fautomagically-deploy-your-web-application-using-the-maven-cargo-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F07%2Fautomagically-deploy-your-web-application-using-the-maven-cargo-plugin%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week I optimized the deployment process of a number of Mavenized projects. I noticed that the way I automated the project was not yet (fully) known by the developers. This is why I decided to write this blogpost. </p>
<p>It appeared to be a true eyeopener for the developers. </p>
<p><span id="more-2863"></span></p>
<p>This example assumes that you have a local instance of <a href="http://tomcat.apache.org/" target="_blank">Apache Tomcat 7.x</a> running.</p>
<p>First, create a new project using Maven: </p>
<pre>
mvn archetype:create -DgroupId=nl.redstream.demo
                     -DartifactId=simplewebapp
                     -DarchetypeArtifactId=maven-archetype-webapp
</pre>
<p>Add the <a href="http://cargo.codehaus.org/" target="_blank">Cargo plugin</a> to the <code>pom.xml</code> (inside the <code>&lt;build&gt;</code> tag)</p>

<div class="wp_codebox"><table><tr id="p286314"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p2863code14"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.cargo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cargo-maven2-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.1.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deployer-redeploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;container<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.containerId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>remote<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/container<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>runtime<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.server.settings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.serverId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.server.settings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The Cargo plugin is attached to the <code>deploy</code> lifecycle phase of Maven. Which means that the <code>deployer-redeploy</code> goal will be executed whenever you type: <code>mvn deploy</code>. The plugin uses the defined configuration at runtime. I used the <code>depoyer-redeploy</code> goal, because this goal will deploy your app if it is not yet deployed, and undeploy first when it is already deployed. More info on the Cargo plugin <a href="http://cargo.codehaus.org/" target="_blank">here</a>.</p>
<p>The properties will be resolved from your <code>settings.xml</code> in which we have defined several profiles: one for each target environment (i.e. develop, test, qa).</p>
<p>Here&#8217;s an example for a development environment (you can add the profiles for the other target environment yourself):</p>
<p>Add the following (inside the <code>&lt;profiles&gt;</code> tag) to your <code>~/.m2/settings.xml</code>:</p>

<div class="wp_codebox"><table><tr id="p286315"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p2863code15"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule.deploy.containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>tomcat7x<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>                
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule.deploy.serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activeByDefault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activeByDefault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>env<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>dev<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Also, add a <code><server></code> definition with id=develop (inside the <code>&lt;servers&gt;</code> tag):</p>

<div class="wp_codebox"><table><tr id="p286316"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p2863code16"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.remote.uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://localhost:8080/manager/text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.remote.uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.remote.username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.remote.username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.remote.password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.remote.password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The trick here is to add the Cargo configuration to the server definition. The defined properties are used by Maven to automagically deploy your webapp. In this demo I used localhost, but it could also be a remote host.</p>
<p>Note that I used a username and password for the deployment process. Add these in your <code>$CATALINA_HOME/conf/tomcat-users.xml</code>:</p>

<div class="wp_codebox"><table><tr id="p286317"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2863code17"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;user</span> <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;deploy&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;deploy&quot;</span> <span style="color: #000066;">roles</span>=<span style="color: #ff0000;">&quot;manager-script&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Note: user <strong>_must_</strong> have the <code>manager-script</code> role!</p>
<p>Now, all that&#8217;s left is deploying your application by executing <code>mvn clean deploy -Denv=dev</code>. The property <code>env=dev</code> will activate the correct profile in your <code>settings.xml</code> and resolve the earlier mentioned properties. BUT, the <code>deploy</code> phase requires a <code>distributionManagement</code> tag in your <code>pom.xml</code>. Mine looks like this (PS: I use <a href="http://www.jfrog.com/products.php" title="JFrog Artifactory" target="_blank">JFrog Artifactory</a>):</p>

<div class="wp_codebox"><table><tr id="p286318"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p2863code18"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>artifactory<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://dev.foobar.local:8080/artifactory/libs-release-local/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;snapshotRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>artifactory<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://dev.foobar.local:8080/artifactory/libs-snapshot-local<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/snapshotRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>After you&#8217;ve added this to your pom, you&#8217;re ready to deploy your application.</p>
<p>Result:</p>
<pre>
...
[INFO]
[INFO] --- cargo-maven2-plugin:1.1.2:deployer-redeploy (default) @ simplewebapp ---
[INFO] [mcat7xRemoteDeployer] [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war] is not deployed. Doing a fresh deployment.
[INFO] [mcat7xRemoteDeployer] Deploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.569s
[INFO] Finished at: Fri Oct 07 13:20:24 CEST 2011
[INFO] Final Memory: 7M/554M
[INFO] ------------------------------------------------------------------------
</pre>
<p>Goto: http://localhost:8080/simplewebapp et voila: your web app!</p>
<p>A redeploy would look something like this:</p>
<pre>
...
[INFO] --- cargo-maven2-plugin:1.1.2:deployer-redeploy (default) @ simplewebapp ---
[INFO] [mcat7xRemoteDeployer] Redeploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
[INFO] [mcat7xRemoteDeployer] Undeploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
[INFO] [mcat7xRemoteDeployer] Deploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set up Web Service Proxy with Mule3</title>
		<link>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/</link>
		<comments>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 14:06:48 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Mule3]]></category>
		<category><![CDATA[SoapUI]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2826</guid>
		<description><![CDATA[In this post I show you how I setup a little test to see if and how easy I could manage to route the traffic to and from a web service through Mule ESB. The business case for this is &#8230; <a href="http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F09%2F24%2Fset-up-web-service-proxy-with-mule3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F09%2F24%2Fset-up-web-service-proxy-with-mule3%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post I show you how I setup a little test to see if and how easy I could manage to route the traffic to and from a web service through <a href="http://www.mulesoft.org/">Mule ESB</a>. The business case for this is an issue that one of our customers ran into when using web services. In a program hundreds of calls are done in a relative short period. Most of the time this isn&#8217;t a problem but sometimes vague issues occur. To get a better insight in this issue I want to put Mule in the middle so I can log the request and response and hopefully get a better idea about what is sent across the line. This is called the Web Service Proxy pattern and is commonly used to validate and audit the web service calls. For more background info about this pattern see <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern">this article</a>.<br />
<span id="more-2826"></span><br />
To get started I downloaded the <a href="http://www.mulesoft.org/download-mule-esb-community-edition">Mule Standalone edition</a> here and installed it. That isn&#8217;t very hard, just untar the thing and set the MULE_HOME property. Go to the bin directory and give &#8216;./mule&#8217; and off you go (except for a warning when running on MacOS 64-bit, but it doesn&#8217;t seem to harm so far…):<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/warning.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/warning-300x222.jpg" alt="" title="warning" width="300" height="222" class="aligncenter size-medium wp-image-2829" /></a></p>
<p>To create a test web service I setup a MockService in SoapUI. Like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.45.06.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.45.06-300x193.jpg" alt="" title="SoapUI MockService" width="300" height="193" class="aligncenter size-medium wp-image-2846" /></a><br />
All you need is a WSDL available. I just picked one from a previous project for testing purposes. With this MockService started you can fire your SOAP requests and will receive a (predefined) response from the MockService:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.47.54.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.47.54-300x137.jpg" alt="" title="SoapUi Response" width="300" height="137" class="aligncenter size-medium wp-image-2847" /></a></p>
<p>Next step is create a new Mule project (I still favor <a href="http://maven.apache.org/">Maven</a> above the <a href="http://www.mulesoft.org/documentation/display/MULESTUDIO/Home">Mule Studio</a>):</p>
<ul>
<li>create new Maven project with</li>
<p><code>mvn mule-project-archetype:create -DartifactId=WSProxy -DmuleVersion=3.1.2</code></p>
<li>Set up the WS Proxy</li>
<p>To create WS Proxy I followed the description <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern">here</a><br />
Note: to make use of the pre-defined &#8216;pattern&#8217; you must add the following dependency to the pom:</p>

<div class="wp_codebox"><table><tr id="p282621"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2826code21"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.mule.patterns<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mule-patterns-all<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>provided<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>My Mule config file looks like this:</p>

<div class="wp_codebox"><table><tr id="p282622"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p2826code22"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/core&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:pattern</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/pattern&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    Proxies a Web Service
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;custom-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;my-transformer&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.proxy.wsproxy.MyTransformer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object-to-string-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ObjectToStringTransformer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pattern:web-service-proxy</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;my-order-ws-proxy&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">inboundAddress</span>=<span style="color: #ff0000;">&quot;http://Pascal-Almas-MacBook-Pro.local:8090/my-order&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">responseTransformer-refs</span>=<span style="color: #ff0000;">&quot;ObjectToStringTransformer my-transformer&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">outboundAddress</span>=<span style="color: #ff0000;">&quot;http://Pascal-Almas-MacBook-Pro.local:8088/mockDataServiceSoapBinding&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<li>Fire up the proxy</li>
<p>To run the Mule application just make sure your Mule installation is running and in your project execute the command &#8216;mvn clean install&#8217;<br />
You should see a message in your Mule console like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-07-at-21.25.54.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-07-at-21.25.54-300x82.jpg" alt="" title="Mule console" width="300" height="82" class="aligncenter size-medium wp-image-2840" /></a>
</ul>
<p>Now we can put the proxy at work by redirecting the SoapUI request to the url: http://Pascal-Almas-MacBook-Pro.local:8090/my-order. It should the be forwarded to the original url and the translator I put in between should output the content to the Mule console:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.57.57.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.57.57-300x114.jpg" alt="" title="MuleLogging" width="300" height="114" class="aligncenter size-medium wp-image-2849" /></a> </p>
<p>However if you try this for the first time big chance you will run into <a href="http://www.mulesoft.org/jira/browse/MULE-5363">this</a> issue (at least I did). To get around this issue modify the soapUI settings like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-16.01.52.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-16.01.52-300x219.jpg" alt="" title="soapui-prefs" width="300" height="219" class="aligncenter size-medium wp-image-2850" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Unit test your Spring/Hibernate and MongoDB setup</title>
		<link>http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/</link>
		<comments>http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 08:00:12 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2807</guid>
		<description><![CDATA[In my previous post I described how you can setup Spring and Hibernate in combination with the MongoDB. In this post I show you how you can write your unit test for this setup including a workaround for the fact &#8230; <a href="http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F27%2Funit-test-your-springhibernate-and-mongodb-setup%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F27%2Funit-test-your-springhibernate-and-mongodb-setup%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In my <a href="http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/">previous</a> post I described how you can setup <a href="http://www.springsource.org/">Spring</a> and <a href="http://www.hibernate.org/">Hibernate</a> in combination with the <a href="http://www.mongodb.org/">MongoDB</a>. In this post I show you how you can write your unit test for this setup including a workaround for the fact that there isn&#8217;t an embedded version of MongoDB.<br />
<span id="more-2807"></span><br />
Of course you can check manually if your code works by checking the content of the MongoDB. You can use <a href="http://www.mongodb.org/display/DOCS/mongo+-+The+Interactive+Shell">the MongoDB shell</a> or the REST interface by using &#8216;curl&#8217; (when using REST make sure you start the database with the &#8216;&#8211;rest&#8217; option). For example see the result of <code>curl 'http://localhost:28017/redstream/logItem/'</code> </p>
<blockquote><p>
pascal@~$ curl &#8216;http://localhost:28017/redstream/logItem/&#8217;<br />
{<br />
  &#8220;offset&#8221; : 0,<br />
  &#8220;rows&#8221;: [<br />
    { "_id" : { "$oid" : "4e1c2ffca0eee881985e04f0" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 0" } ,<br />
    { "_id" : { "$oid" : "4e1c2ffda0eee881985e04f1" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 1" } ,<br />
    { "_id" : { "$oid" : "4e1c2ffda0eee881985e04f2" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 2" } ,<br />
    { "_id" : { "$oid" : "4e1c4289a0ee3d15a8af39d3" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 0" }<br />
  ],<br />
  &#8220;total_rows&#8221; : 3 ,<br />
  &#8220;query&#8221; : {} ,<br />
  &#8220;millis&#8221; : 0<br />
}<br />
pascal@~$
</p></blockquote>
<p>However, when building software you want your test to be performed automatically so we use JUnit to perform the tests and checks. And I use JUnit to start and stop my local MongoDB instance. Here is how it works (I assume you have the same project setup as I created in my <a href="http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/">previous</a> post):</p>
<ul>
<li>Wire the Spring beans in your test context</li>
<p>I created a SpringContext class for testing purposes:</p>

<div class="wp_codebox"><table><tr id="p280726"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code" id="p2807code26"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.context.ApplicationContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Only to be used in test classes!!
 * 
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyTestApplicationContext <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> MyTestApplicationContext testContext <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    ApplicationContext context <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> MyTestApplicationContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> MyTestApplicationContext getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>testContext <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            testContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyTestApplicationContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            testContext.<span style="color: #006633;">initialise</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> testContext<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initialise<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassPathXmlApplicationContext<span style="color: #009900;">&#40;</span>
                <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;spring-config.xml&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> getBean<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> context.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ApplicationContext getSpringContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> context<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>With this class I can access my Spring beans easily in my Unit tests.</p>
<li>Write the test class</li>
<p>I use <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/ProcessBuilder.html">ProcessBuilder</a> to start and stop the local MongoDB instance before the test class is executed. The base Testclass looks like this:</p>

<div class="wp_codebox"><table><tr id="p280727"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code" id="p2807code27"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.After</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.AfterClass</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.BeforeClass</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MongoDBTest <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger logger <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>MongoDBTest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprocess+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Process</span></a> p <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    @Before
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//@Todo Run mongo with a test specific .js file to produce initial data state</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @After
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//@Todo Drop database</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @BeforeClass
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> beforeClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> command <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;/Users/pascal/development/mongodb-osx-x86_64-1.8.2/bin/mongod&quot;</span>, <span style="color: #0000ff;">&quot;--dbpath&quot;</span>, <span style="color: #0000ff;">&quot;/Users/pascal/development/mongodb/data&quot;</span>, <span style="color: #0000ff;">&quot;--rest&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        ProcessBuilder pb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ProcessBuilder<span style="color: #009900;">&#40;</span>command<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        p <span style="color: #339933;">=</span> pb.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Process started with pid: &quot;</span> <span style="color: #339933;">+</span> p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @AfterClass
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> afterClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Stop mongod process</span>
        <span style="color: #000066; font-weight: bold;">boolean</span> processClosed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>p <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>processClosed<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                    p.<span style="color: #006633;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    processClosed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; Process destroyed: &quot;</span> <span style="color: #339933;">+</span> p.<span style="color: #006633;">exitValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalthreadstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalThreadStateException</span></a> itse<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    logger.<span style="color: #006633;">warn</span><span style="color: #009900;">&#40;</span>itse<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    processClosed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And the actual test class:</p>

<div class="wp_codebox"><table><tr id="p280728"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code" id="p2807code28"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">junit.framework.Assert</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.mongo.entity.LogItem</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.mongo.services.LogService</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.bson.types.ObjectId</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LogServiceTest <span style="color: #000000; font-weight: bold;">extends</span> MongoDBTest <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger logger <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>LogServiceTest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> LogService<span style="color: #339933;">&lt;</span>LogItem<span style="color: #339933;">&gt;</span> service <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCreateAndFindLog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
&nbsp;
        ObjectId id <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            LogItem log <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LogItem<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            log.<span style="color: #006633;">setMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;just some text &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            id <span style="color: #339933;">=</span> service.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>log<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log.id = &quot;</span> <span style="color: #339933;">+</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        LogItem logFound <span style="color: #339933;">=</span> service.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log = &quot;</span> <span style="color: #339933;">+</span> logFound.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertNotNull</span><span style="color: #009900;">&#40;</span>logFound<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Before
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;setting up test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        service <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LogService<span style="color: #339933;">&lt;</span>LogItem<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> MyTestApplicationContext.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;logService&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//@TODO Run mongo with a test specific .js file to produce initial data state</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<li>Run it!</li>
<p>The test output shows it ran successfully:</p>
<blockquote><p>
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 T E S T S<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Running nl.redstream.mongo.LogServiceTest<br />
DEBUG [main] nl.redstream.mongo.MongoDBTest: Process started with pid: java.lang.UNIXProcess@603b1d04<br />
INFO  [main] nl.redstream.mongo.LogServiceTest: setting up test<br />
DEBUG [main] nl.redstream.mongo.services.MongoDBLoggerServiceImpl: Adding a new LogItem instance<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log.id = 4e2fc241a0eea3de77684fdf<br />
DEBUG [main] nl.redstream.mongo.services.MongoDBLoggerServiceImpl: Adding a new LogItem instance<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log.id = 4e2fc241a0eea3de77684fe0<br />
DEBUG [main] nl.redstream.mongo.services.MongoDBLoggerServiceImpl: Adding a new LogItem instance<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log.id = 4e2fc241a0eea3de77684fe1<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log = LogItem [id=4e2fc241a0eea3de77684fe1, message=just some text 2, timestamp=null]<br />
INFO  [main] nl.redstream.mongo.MongoDBTest:  Process destroyed: 12<br />
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.798 sec</p>
<p>Results :</p>
<p>Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</p></blockquote>
</ul>
<p>There is definitely room for improvement, like adding the possibility to run &#8216;.js&#8217; scripts to set the database in a predefined state in the @Before method of the test class and remove the database in the @After method.<br />
Another thing that bothered me is the &#8216;Thread.sleep&#8217; that I had to add at some places to make it work. Nevertheless I showed how to setup a basic test case with MongoDB/Spring combination and if you have a better solution please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use Spring and Hibernate with MongoDB</title>
		<link>http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/</link>
		<comments>http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 09:12:53 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2801</guid>
		<description><![CDATA[One of the requirements we have for one of our Mule ESB implementations is to log the messages that went through the ESB (especially handy during development and testing). There has been written a lot already about logging with Mule &#8230; <a href="http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F14%2Fuse-spring-and-hibernate-with-mongodb%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F14%2Fuse-spring-and-hibernate-with-mongodb%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the requirements we have for one of our Mule ESB implementations is to log the messages that went through the ESB (especially handy during development and testing). There has been written a lot already about logging with Mule so I am not going to discuss that again. In this post I&#8217;ll only show you how you can use Spring/Hibernate and <a href="http://www.mongodb.org/">MongoDB</a> to store your messages in the MongoDB, because a document-oriented database like MongoDB is a nice fit for this requirement.<br />
<span id="more-2801"></span></p>
<p>The first thing to do is to install MongoDB on your machine (unfortunately it is not yet possible to run it embedded so we use a local instance instead). For installation see <a href="http://www.mongodb.org/display/DOCS/Quickstart+OS+X">this</a>.</p>
<p>After MongoDB is installed we can create a new standard Maven project and modify the generated pom.xml to the following <a href="http://www.redstream.nl/wp-content/uploads/2011/07/pom.xml">pom.xml</a>.</p>
<p>Next step is the creation of the Hibernate Entity class like this:</p>

<div class="wp_codebox"><table><tr id="p280132"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code" id="p2801code32"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo.entity</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.bson.types.ObjectId</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Model object 
 * @author pascal
 */</span>
@<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aentity+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Entity</span></a>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;logItems&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LogItem <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aserializable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Serializable</span></a> <span style="color: #009900;">&#123;</span>
&nbsp;
    @Id
    <span style="color: #000000; font-weight: bold;">private</span> ObjectId id<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> timestamp<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ObjectId getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span>ObjectId id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> message<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setMessage<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">message</span> <span style="color: #339933;">=</span> message<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getTimestamp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> timestamp<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setTimestamp<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> timestamp<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">timestamp</span> <span style="color: #339933;">=</span> timestamp<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;LogItem [id=&quot;</span> <span style="color: #339933;">+</span> id <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;, message=&quot;</span> <span style="color: #339933;">+</span> message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;, timestamp=&quot;</span> <span style="color: #339933;">+</span> timestamp <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;]&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you might notice I have used the ObjectId as primary Id. I was forced to this by bug <a href="https://jira.springsource.org/browse/DATADOC-176">DATADOC-176</a> which only recently got fixed.</p>
<p>The Dao and Service object classes that are used to access the MongoDB are:</p>
<ul>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/BaseDao.java">BaseDao.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/AbstractBaseDao.java">AbstractBaseDao.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/LogItemDaoImpl.java">LogItemDaoImpl.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/LogService.java">LogService.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/MongoDBLoggerServiceImpl.java">MongoDBLoggerServiceImpl.java</a></li>
</ul>
<p>Now wire this all together with the following spring config files:</p>

<div class="wp_codebox"><table><tr id="p280133"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p2801code33"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=</span>
<span style="color: #009900;">               <span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans</span>
<span style="color: #009900;">                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;spring-mongodb-config.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;logService&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.mongo.services.MongoDBLoggerServiceImpl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dao&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;logDao&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;logDao&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.mongo.dao.LogItemDaoImpl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mongoTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;mongoTemplate&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>and the &#8216;spring-mongodb-config.xml&#8217; (as described <a href="http://static.springsource.org/spring-data/data-document/docs/1.0.0.M3/reference/html/#mongodb-connectors">here</a>):</p>

<div class="wp_codebox"><table><tr id="p280134"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p2801code34"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:mongo</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/data/mongo&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=</span>
<span style="color: #009900;">               <span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans</span>
<span style="color: #009900;">                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</span>
<span style="color: #009900;">                http://www.springframework.org/schema/data/mongo</span>
<span style="color: #009900;">                http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Default bean name is 'mongo' --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mongo:mongo</span> <span style="color: #000066;">host</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span> <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;27017&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- OPTIONAL: configure &lt;mongo:options /&gt; --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mongo:mongo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mongo:db-factory</span> <span style="color: #000066;">dbname</span>=<span style="color: #ff0000;">&quot;redstream&quot;</span> <span style="color: #000066;">mongo-ref</span>=<span style="color: #ff0000;">&quot;mongo&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mongoTemplate&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.data.document.mongodb.MongoTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;mongoDbFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>That&#8217;s it. Now you have a foundation to start using MongoDB with Spring and Hibernate classes. In the next post I will show how you can test this setup without manually having to start and stop MongoDB.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use Mule to sync WordPress sites</title>
		<link>http://www.redstream.nl/2011/07/11/use-mule-to-sync-wordpress-sites/</link>
		<comments>http://www.redstream.nl/2011/07/11/use-mule-to-sync-wordpress-sites/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 18:31:49 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Mule iON]]></category>
		<category><![CDATA[Mule3]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2780</guid>
		<description><![CDATA[I got triggered by my previous post to create a process with which I could keep two instances of WordPress in sync. I wanted to see if I could do this with Mule. I came up with the following solution: &#8230; <a href="http://www.redstream.nl/2011/07/11/use-mule-to-sync-wordpress-sites/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F11%2Fuse-mule-to-sync-wordpress-sites%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F11%2Fuse-mule-to-sync-wordpress-sites%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I got triggered by my <a href="http://www.redstream.nl/2011/06/30/redstream-goes-cloud/">previous</a> post to create a process with which I could keep two instances of <a href="http://wordpress.org/">WordPress</a> in sync. I wanted to see if I could do this with Mule. I came up with the following solution:</p>
<ul>
<li>Receive the RSS feed of a new post in Mule flow</li>
<li>Use the content of the RSS feed to post to the other wordpress instance by using XML-RPC</li>
<li>Have it running on <a href="www.mulesoft.com/mule-ion-ipaas-cloud-based-integration-demand ">Mule iON</a> so I don&#8217;t have to setup my own Muleserver</li>
</ul>
<p><span id="more-2780"></span><br />
So lets start a new Mule iON project. Since I am a big fan of <a href="http://netbeans.org/">Netbeans</a> I use <a href="http://www.mulesoft.org/documentation/display/ION/Build+your+First+Project+with+Maven+and+Command+Line">the Maven based approach</a> (I must admit I have tried to use <a href="http://www.mulesoft.org/documentation/display/MULESTUDIO/Getting+Started+with+Mule+Studio">MuleStudio</a> for this but it didn&#8217;t bring me the productivityboost I hoped for).<br />
I created the Mule project with:<br />
<code><br />
mvn org.mule.tools:mule-project-archetype:create -DartifactId=wordpress-copy-service -DgroupId=nl.redstream.mule-ion -Dinteractive=false -Dmodules=rss -DmuleVersion=3.1.1<br />
</code></p>
<p>The Mule config looks like:</p>

<div class="wp_codebox"><table><tr id="p278038"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p2780code38"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/core&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:http</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/http&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:rss</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/rss&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:spring</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/rss http://www.mulesoft.org/schema/mule/rss/3.1/mule-rss.xsd</span>
<span style="color: #009900;">        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;xmlRpcHelper&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.rss.XmlRpcHelper&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:constructor-arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://www.pragmatic-integrators.com/xmlrpc.php&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java.lang.String&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:constructor-arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;UserName&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java.lang.String&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:constructor-arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Password&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java.lang.String&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;entryReceiver&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.rss.EntryReceiver&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:constructor-arg</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;xmlRpcHelper&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/spring:bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;flow</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;poll-and-post&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;poll</span> <span style="color: #000066;">frequency</span>=<span style="color: #ff0000;">&quot;36000000&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;http:outbound-endpoint</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://www.redstream.nl/feed/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/poll<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rss:feed-splitter</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring-object</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;entryReceiver&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/flow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>As you can see I poll the website &#8216;www.redstream.nl&#8217; once each 10 hours. The RSS feed I receive is split and sent to my custom made component &#8216;entryReceiver&#8217;. It would be nice to use a XML-RPC endpoint here but this isn&#8217;t created <a href="http://www.mulesoft.org/documentation/display/XMLRPC/Home">yet</a> (and actually I don&#8217;t feel like it neither).</p>
<p>The EntryReceiver looks like:</p>
<blockquote><p>Disclaimer: just wanted to see if it worked, I did not try to build a robust solution that had to work for every WordPress site, so you are warned!</p></blockquote>

<div class="wp_codebox"><table><tr id="p278039"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p2780code39"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.rss</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.annotations.param.Payload</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.syndication.feed.synd.SyndEntry</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EntryReceiver <span style="color: #009900;">&#123;</span>
&nbsp;
    XmlRpcHelper xmlRpcHelper <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> EntryReceiver<span style="color: #009900;">&#40;</span>XmlRpcHelper helper<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        xmlRpcHelper <span style="color: #339933;">=</span> helper<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> readEntry<span style="color: #009900;">&#40;</span>@Payload SyndEntry entry<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Get the title</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> title <span style="color: #339933;">=</span> entry.<span style="color: #006633;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Check if title exist in current blogs on the new blogsite</span>
       <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>xmlRpcHelper.<span style="color: #006633;">titleExists</span><span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            xmlRpcHelper.<span style="color: #006633;">post</span><span style="color: #009900;">&#40;</span>entry<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Skip this post</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And the bean where the dirty work is done:</p>

<div class="wp_codebox"><table><tr id="p278040"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
</pre></td><td class="code" id="p2780code40"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.rss</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.MalformedURLException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.URL</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.xmlrpc.XmlRpcException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.xmlrpc.client.XmlRpcClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.xmlrpc.client.XmlRpcClientConfigImpl</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.syndication.feed.synd.SyndContentImpl</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.syndication.feed.synd.SyndEntry</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> XmlRpcHelper <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> url<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> userName<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> password<span style="color: #339933;">;</span>
    XmlRpcClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlRpcClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> XmlRpcHelper<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> url, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> u, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">url</span> <span style="color: #339933;">=</span> url<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userName</span> <span style="color: #339933;">=</span> u<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">password</span> <span style="color: #339933;">=</span> p<span style="color: #339933;">;</span>
&nbsp;
        XmlRpcClientConfigImpl config <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlRpcClientConfigImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            config.<span style="color: #006633;">setServerURL</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aurl+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">URL</span></a><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amalformedurlexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">MalformedURLException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
            e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        client.<span style="color: #006633;">setConfig</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> titleExists<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> getRecentTitles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">contains</span><span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> post<span style="color: #009900;">&#40;</span>SyndEntry entry<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        StringBuilder content <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;content&gt;&lt;title&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>entry.<span style="color: #006633;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/title&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        List<span style="color: #339933;">&lt;</span>SyndContentImpl<span style="color: #339933;">&gt;</span> contents <span style="color: #339933;">=</span> entry.<span style="color: #006633;">getContents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>SyndContentImpl syndContent <span style="color: #339933;">:</span> contents<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            content.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>syndContent.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        content.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/content&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            client.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;blogger.newPost&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;bla&quot;</span>, <span style="color: #cc66cc;">1</span>,
                        userName, password, content.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>XmlRpcException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
            e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> getRecentTitles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> titles <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> token <span style="color: #339933;">=</span> client.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;blogger.getRecentPosts&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;bla&quot;</span>, <span style="color: #cc66cc;">1</span>,
                        userName, password, <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> result <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> token<span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> result.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                titles.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>getTitle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>HashMap<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>XmlRpcException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
            e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">// return null;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> titles<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getTitle<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amap+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Map</span></a> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> title <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> content <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#41;</span> response.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>content <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            title <span style="color: #339933;">=</span> content.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>content.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;title&gt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">7</span>,
                    content.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/title&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> title<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<blockquote><p>One thing that kept me busy for a while was that the first String in the Object array that is supplied with the XmlRpc call may contain anything as long as it contains something. An emptry String &#8220;&#8221; is ignored in the call and will lead to an invalid Username/Password message.
</p></blockquote>
<p>If all this is in place you can build the project with: &#8216;mvn clean install&#8217;. This will create a zip file in the target directory. This zip file can then be uploaded with your dashboard to your Mule iON instance:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/07/Screen-shot-2011-07-11-at-20.20.17.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/07/Screen-shot-2011-07-11-at-20.20.17-300x147.jpg" alt="" title="Screen shot 2011-07-11 at 20.20.17" width="300" height="147" class="aligncenter size-medium wp-image-2792" /></a></p>
<p>And that&#8217;s it! As you can see the two sites &#8216;www.redstream.nl&#8217; and &#8216;www.pragmatic-integrators.com&#8217; are know kept in sync (with a max. gap of 10 hrs). Of course the copied post is not an exact clone of the original (I am loosing info about the Author, Categories, etc. and images are referred to at the original location) but it shows that the main idea works!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/11/use-mule-to-sync-wordpress-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing your own Altova MapForce Extension</title>
		<link>http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/</link>
		<comments>http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 20:24:00 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MapForce]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2703</guid>
		<description><![CDATA[In a previous post, I mentioned that you could extend the function library in Altova MapForce and add your own functions. In this post I&#8217;ll show you (briefly) how to do this using the Java methods from the previous post. &#8230; <a href="http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F05%2Fwriting-your-own-altova-mapforce-extension%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F05%2Fwriting-your-own-altova-mapforce-extension%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In a <a href="http://www.redstream.nl/2011/03/29/xslt-2-0-and-java-extensions/">previous</a> post, I mentioned that you could extend the function library in Altova MapForce and add your own functions. In this post I&#8217;ll show you (briefly) how to do this using the Java methods from the previous post.</p>
<p><span id="more-2703"></span></p>
<p>The MapForce documentation only contains a little information on how to add your own custom functions. </p>
<p>The base directory in which you installed MapForce contains a directory called <code>MapForceLibraries</code>. Here, you will find a number of, so called, <code>mff</code> files, which stands for MapForce Functions. Inside, the definition is stored of the functions you are able to select from the library when working on a mapping. We will be using this principle to add an extension of our own. The only thing we need to do, is create such a <code>mff</code> file. </p>
<p>As I already said, the MapForce documentation does not contain a lot of information on this subject. But &#8230; what it does include is the XML Schema for the <code>mff</code> file. It is called <code>mff.xsd</code> and it is also located in the <code>MapForceLibraries</code> directory. Open the XML Schema in XMLSpy (or any other XML editor) and select element <code>mapping</code> to get an overview of the library structure. Notice that the XML Schema is well-documented (at least better than the actual MapForce documentation). </p>
<p>We will, briefly, walk through the most important elements. First, element <code>mapping</code>: the root element. </p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-mapping.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-mapping.png" alt="" title="mapforce-mff-mapping" width="338" height="227" class="alignnone size-full wp-image-2709" /></a><br/></p>
<p>First, element <code>implementations</code>. This element refers to the possible implementations of your extension (e.g. Java, XSLT, C#, etc).</p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-implementations.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-implementations.png" alt="" title="mapforce-mff-implementations" width="627" height="253" class="alignnone size-full wp-image-2708" /></a></p>
<p>Functions can be grouped, hence the <code>group</code> element. The <code>component</code> element inside describes how your extension should be called. The <code>target</code> describe your input parameters (if any) and <code>output</code> describes your output.</p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-group.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-group.png" alt="" title="mapforce-mff-group" width="499" height="427" class="alignnone size-full wp-image-2706" /></a></p>
<p>Here&#8217;s what an example XML could look like. We used an <code>xslt2</code> implementation that points to a xslt stylesheet.</p>

<div class="wp_codebox"><table><tr id="p270344"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p2703code44"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mapping</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:noNamespaceSchemaLocation</span>=<span style="color: #ff0000;">&quot;file:///C:/Program%20Files/Altova/MapForce2011/MapForceLibraries/mff.xsd&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #000066;">library</span>=<span style="color: #ff0000;">&quot;redstream&quot;</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span style="color: #000066;">xmlns:mf</span>=<span style="color: #ff0000;">&quot;http://www.altova.com/MapForce/2010/standard&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;xslt2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setting</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;xsltfilename&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;xlst-redstream-library.xsl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;group</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;demo functions&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;greeting&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;datapoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;targets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;datapoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;result&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/targets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;xslt2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;function</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;rs:greeting&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;java:nl.redstream.XsltUtils&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;short<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>result = 'Hello ' + name + ' !'<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/short<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;long<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Returns friendly message.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/long<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/group<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The related XSLT file looks like this:</p>

<div class="wp_codebox"><table><tr id="p270345"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p2703code45"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:fn</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2005/xpath-functions&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:rs</span>=<span style="color: #ff0000;">&quot;java:nl.redstream.utils.XsltUtils&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:function</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;rs:greeting&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;rs:greeting($name)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:function<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Once, you&#8217;ve created your <code>mff</code> and <code>xslt</code> file, copy them into <code>MapForceLibraries</code> directory (make sure MapForce is not running, otherwise you will not be able to write in that directory). Start Altova MapForce, create a new mapping (implemenation <code>xslt2</code> and behold &#8230; your extension will show up in the Library. </p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-custom-library.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-custom-library.png" alt="" title="mapforce-custom-library" width="286" height="165" class="alignnone size-full wp-image-2729" /></a></p>
<p>Now, you can drag-and-drop the function onto your mapping.</p>
<p>The resulting XSLT will look like this:</p>

<div class="wp_codebox"><table><tr id="p270346"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p2703code46"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">This file was generated by Altova MapForce 2011sp1</span>
&nbsp;
<span style="color: #808080; font-style: italic;">YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE</span>
<span style="color: #808080; font-style: italic;">OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.</span>
&nbsp;
<span style="color: #808080; font-style: italic;">Refer to the Altova MapForce Documentation for further details.</span>
<span style="color: #808080; font-style: italic;">http://www.altova.com/mapforce</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> </span>
<span style="color: #009900;">                                              <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> </span>
<span style="color: #009900;">                                              <span style="color: #000066;">xmlns:fn</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2005/xpath-functions&quot;</span> </span>
<span style="color: #009900;">                                              <span style="color: #000066;">xmlns:rs</span>=<span style="color: #ff0000;">&quot;java:nl.redstream.XsltUtils&quot;</span> <span style="color: #000066;">exclude-result-prefixes</span>=<span style="color: #ff0000;">&quot;xs fn rs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;xml&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">indent</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dataset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;row<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;dataset/row/column&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;rs:greeting(fn:string(@name))&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/row<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dataset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Unfortunately, you cannot display the results of the customized mapping in MapForce (#featurerequest). Instead, you could use XMLSpy and use the settings from the <a href="http://www.redstream.nl/2011/03/29/xslt-2-0-and-java-extensions/">previous</a> post.</p>
<p>That&#8217;s it &#8230; enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Redstream goes Cloud</title>
		<link>http://www.redstream.nl/2011/06/30/redstream-goes-cloud/</link>
		<comments>http://www.redstream.nl/2011/06/30/redstream-goes-cloud/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 13:19:24 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[Mule iON]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Cloud]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2755</guid>
		<description><![CDATA[Last week I migrated our site and blog to the Cloud. I got triggered by this article. That in the combination with the free account at Amazon&#8217;s EC2 was enough for me give it a try. Now, if you came &#8230; <a href="http://www.redstream.nl/2011/06/30/redstream-goes-cloud/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F30%2Fredstream-goes-cloud%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F30%2Fredstream-goes-cloud%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week I migrated our site and blog to the Cloud. I got triggered by <a href="http://www.agileweboperations.com/migrate-your-wordpress-blog-to-a-bitnami-ec2-instance">this</a> article. That in the combination with <a href="http://aws.amazon.com/free/">the free account</a> at Amazon&#8217;s EC2 was enough for me give it a try.<span id="more-2755"></span><br />
Now, if you came here via <a href="http://www.redstream.nl">&#8216;www.redstream.nl&#8217;</a> you are looking at the version hosted at our own server. But if you got here via &#8216;<a href="http://www.pragmatic-integrators.com">www.pragmatic-integrators.com</a>&#8216; you are looking at the version hosted in the Cloud.<br />
After I migrated the site I realized how easy it is to use a server in the cloud and made me wonder why you should ever want your own physical &#8216;web&#8217;server. For the time being I will keep both instances alive so I can compare both solutions.<br />
Now I have to find a way to keep these two instances in sync… That would be a nice use case using <a href="http://www.mulesoft.com/mule-ion-ipaas-cloud-based-integration-demand">Mule iON</a> to stay in the Clouds&#8230; I&#8217;ll post the solution here as soon as I have worked it out ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/06/30/redstream-goes-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mule in the Cloud: First impression</title>
		<link>http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/</link>
		<comments>http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 07:24:34 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Mule iON]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2746</guid>
		<description><![CDATA[Like I posted before Mulesoft has released a new platform: iPAAS. I just went through the starters guide and I am pretty impressed. Of course the use case in the tutorial is very simple but the whole idea of just &#8230; <a href="http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F17%2Fmule-in-the-cloud-first-impression%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F17%2Fmule-in-the-cloud-first-impression%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Like I posted <a href="http://www.redstream.nl/2011/06/16/new-products-from-mulesoft/">before</a> Mulesoft has released a new platform: <a href="http://www.mulesoft.com/ipaas-integration-platform-as-a-service">iPAAS</a>. I just went through <a href="http://www.mulesoft.org/documentation/display/ION/Build+Your+First+Project+with+Mule+Studio">the starters guide</a> and I am pretty impressed. Of course the use case in the tutorial is very simple but the whole idea of just putting your Mule config into the cloud and it runs sounds good. And I have seen it working (you can check for yourself by submitting text to <a href="http://redstream.muleion.com/services/EchoUMO/echo/text/put%20your%20text%20here">this url</a>. <span id="more-2746"></span><br />
Here is a snapshot of the dashboard you get with you <a href="http://www.mulesoft.org/documentation/display/ION/Getting+Started">Mule iON</a> account:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/06/Screen-shot-2011-06-16-at-10.59.44.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/06/Screen-shot-2011-06-16-at-10.59.44-300x219.jpg" alt="" title="Screen shot 2011-06-16 at 10.59.44" width="300" height="219" class="aligncenter size-medium wp-image-2747" /></a><br />
Although it looks pretty nice at first sight it does raise questions and some topics for further investigation: what about security and in what use cases will this be the best solution? Mulesoft already has answers to those questions (<a href="http://www.mulesoft.org/documentation/display/ION/Secure+Data+Gateway">security</a> and <a href="http://www.mulesoft.org/documentation/display/ION/Use+Cases">use cases</a>) but I am going to find out myself and let you know my opinion. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

