<?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>byte bohemian</title>
	<atom:link href="http://www.niclas-meier.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.niclas-meier.de</link>
	<description>Thechophile bogging</description>
	<lastBuildDate>Wed, 07 Dec 2011 16:18:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The curl cheat sheet to myself</title>
		<link>http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/</link>
		<comments>http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 14:11:53 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=109</guid>
		<description><![CDATA[It has been not even a full week building REST style interfaces for the Playmaker Studio mobile platform and I am very annoyed of all the curl guides how to access your REST API with curl. So here is my cheat sheet on this topic. Be aware that the I will update this frequently. Common [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It has been not even a full week building REST style interfaces for the <a href="http://www.playmakerstudio.com/">Playmaker Studio</a> mobile platform and I am very annoyed of all the <code>curl</code> guides how to access your REST API with <code>curl</code>. So here is my cheat sheet on this topic. Be aware that the I will update this frequently.<br />
<span id="more-109"></span></p>
<h2>Common use cases</h2>
<h3>GETting data from a URL</h3>
<p>This is a very simple use case just use:</p>
<pre class="brush:bash">
curl https://graph.facebook.com/740999649
{"id":"740999649","name":"Niclas Meier"}
</pre>
<p><code>curl</code> will automatically use the HTTP method <code>GET</code>.</p>
<h3>POSTting updates</h3>
<p>In the REST dictionary the HTTP method <code>POST</code> represents the verb &#8216;update&#8217;. So updating data implies a <code>POST</code> request to an URL.</p>
<h4>Basic</h4>
<p>Let&#8217;s have a look at the basics, I added some (revised / half the original) debugging output by supplying the <code>-v</code> option.</p>
<pre class="brush:bash">
curl -v -X POST http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d 'name=Niclas'

&gt; POST /1/stuff/23f96c6bd4c87910c.json HTTP/1.1
&gt; Host: localhost:8080
&gt; Accept: */*
&gt; Content-Length: 11
&gt; Content-Type: application/x-www-form-urlencoded
&gt;
&lt; HTTP/1.1 200 OK
&lt; Content-Type: text/plain; charset=utf-8
&lt; Content-Length: 25
&lt;
Stuff: 23f96c6bd4c87910c
</pre>
<p>There are some options involved:</p>
<ul>
<li><code>-v</code> added the request/response header for debugging</li>
<li><code>-X</code> specified the request method (<code>POST</code>) to use.</li>
<li><code>-d</code> added some data in the request (<code>POST</code>) body.</li>
</ul>
<p>So the <code>'name=Niclas'</code> was sent to the server using the request body, but <code>curl</code> does not display the request body using the <code>-v</code> option.</p>
<h4>Using a JSON body</h4>
<p>So this is nice, when you want to post key-value pairs to your server, but many applications (e.g. <a href="http://couchdb.apache.org/">CouchDB</a> want to post JSON objects to the server. The initial guess</p>
<pre class="brush:bash">
curl -v -X POST http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d '{"name":"Niclas"}'

Stuff: 23f96c6bd4c87910c, JSON body:
</pre>
<p>does not work. That&#8217;s where the content type comes in. If you post the JSON whiteout supplying the proper content type <code>curl</code> and/or the server will try to use  <code>application/x-www-form-urlencoded</code><a href="http://www.w3.org/TR/html4/interact/forms.html"><sup>*</sup></a> content type. This is the same content type your browser uses when submitting a form to a web server. Doesn&#8217;t sound bad, does it?</p>
<p>But it&#8217;s bad because the JSON will be ignored/dropped/whatever and the server is unable to understand the request. To solve the problem use:</p>
<pre class="brush:bash">
curl -H "Content-Type: application/json" -X POST  http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d '{"name":"Niclas"}'

Stuff: 23f96c6bd4c87910c, JSON body: {"name":"Niclas"}
</pre>
<p>So these options are involved</p>
<ul>
<li><code>-X</code> specified the request method (<code>POST</code>) to use.</li>
<li><code>-H</code> added the header <code>Content-Type: application/json</code> to the request.</li>
<li><code>-d</code> defined the data used for the request body (<code>{"name":"Niclas"}</code>).</li>
</ul>
<h4>A JSON file as body</h4>
<p>So far so good. But if you have huge JSON requests, you don&#8217;t want to type all the JSON into the console. You may use the <code>@</code> symbol in conjunction with the <code>-d</code> option so <code>curl</code> will read the request body contents from a file. This may look like this.</p>
<pre class="brush:bash">
curl -H "Content-Type: application/json" -X POST  http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d @some-huge-request.json

Stuff: 23f96c6bd4c87910c, JSON body: {"name":"Niclas", ..., "foo":"Bar"}
</pre>
<p>A nice trick is, that if you use the <code>-d</code> with <code>@-</code>. <code>curl</code> will read the request body from the standard input. So you can do stuff like this:</p>
<pre class="brush:bash">
cat some-huge-request.json | curl -H "Content-Type: application/json" -X POST  http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d @-

Stuff: 23f96c6bd4c87910c, JSON body: {"name":"Niclas", ..., "foo":"Bar"}
</pre>
<h3>PUTting stuff</h3>
<p>Is much like <code>POST</code>, so if you can <code>POST</code> you can <code>PUT</code>. One nasty little difference is, that you don&#8217;t have to supply a <code>Content-Type</code> HTTP header for <code>PUT</code>. <code>curl</code> does not use <code>application/x-www-form-urlencoded</code> as content type for <code>PUT</code>. Lost an hour (or so), because I did some <code>PUT</code> stuff before switching to  <code>POST</code>.</p>
<h2>Debugging</h2>
<h4>Detailed information</h4>
<p>The key to get almost every information by supplying the <code>-v</code> option to curl.</p>
<pre class="brush:bash">
curl -v https://graph.facebook.com/740999649

* About to connect() to graph.facebook.com port 443 (#0)
*   Trying 66.220.147.38... connected
* Connected to graph.facebook.com (66.220.147.38) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-MD5
* Server certificate:
* 	 subject: C=US; ST=California; L=Palo Alto; O=Facebook, Inc.; CN=*.facebook.com
* 	 start date: 2010-01-13 00:00:00 GMT
* 	 expire date: 2013-04-11 23:59:59 GMT
* 	 common name: *.facebook.com (matched)
* 	 issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance CA-3
* 	 SSL certificate verify ok.
&gt; GET /740999649 HTTP/1.1
&gt; User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
&gt; Host: graph.facebook.com
&gt; Accept: */*
&gt;
&lt; HTTP/1.1 200 OK
&lt; Access-Control-Allow-Origin: *
&lt; Cache-Control: private, no-cache, no-store, must-revalidate
&lt; Content-Type: text/javascript; charset=UTF-8
&lt; ETag: "f89bfe40c87e487ae641d427c96746b226a91f3c"
&lt; Expires: Sat, 01 Jan 2000 00:00:00 GMT
&lt; Pragma: no-cache
&lt; X-FB-Rev: 482216
&lt; X-FB-Server: 10.36.50.102
&lt; X-Cnection: close
&lt; Date: Wed, 07 Dec 2011 13:14:19 GMT
&lt; Content-Length: 183
&lt;
* Connection #0 to host graph.facebook.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
{"id":"740999649","name":"Niclas Meier","first_name":"Niclas","last_name":"Meier","link":"http:\/\/www.facebook.com\/people\/Niclas-Meier\/740999649","gender":"male","locale":"de_DE"}</pre>
<p>But for may occasions that is simply too much, so check out the <code>-i</code> option.</p>
<h4>Header information</h4>
<p>Often it&#8217;s enough to get only the response headers for debugging. To get only these headers just use the <code>-i</code> option in <code>curl</code>.</p>
<pre class="brush:bash">
curl -i https://graph.facebook.com/740999649
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: text/javascript; charset=UTF-8
ETag: "f89bfe40c87e487ae641d427c96746b226a91f3c"
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
X-FB-Rev: 482216
X-FB-Server: 10.42.67.29
X-Cnection: close
Date: Wed, 07 Dec 2011 13:18:24 GMT
Content-Length: 183

{"id":"740999649","name":"Niclas Meier","first_name":"Niclas","last_name":"Meier","link":"http:\/\/www.facebook.com\/people\/Niclas-Meier\/740999649","gender":"male","locale":"de_DE"}</pre>
<div class="shr-publisher-109"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a new move &#8211; again</title>
		<link>http://www.niclas-meier.de/2011/12/making-a-new-move-again/</link>
		<comments>http://www.niclas-meier.de/2011/12/making-a-new-move-again/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 12:33:24 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Privat]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=107</guid>
		<description><![CDATA[After been almost 10 years at SinnerSchrader it&#8217;s very confusing for me to be on the move again. On the 1st of December I joined Playmaker Studio after being at gamigo for 18 month.You now may ask why? I don&#8217;t want to explain every thought that led to the decision, but I can say I [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/12/making-a-new-move-again/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>After been almost 10 years at <a href="http://www.sinnerschrader.de/">SinnerSchrader</a> it&#8217;s very confusing for me to be on the move again. On the 1<sup>st</sup> of December I joined <a href="http://www.playmakerstudio.com/">Playmaker Studio</a> after being at <a href="http://www.gamigo.de">gamigo</a> for 18 month.<span id="more-107"></span>You now may ask why? I don&#8217;t want to explain every thought that led to the decision, but I can say I enjoyed my job at gamigo. I learned damn much, especially stuff I never anticipated (I am not saying that I didn&#8217;t wanted to learn most of it <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). I had a great team making a giant leap in the software development processes, nice colleagues and we brought the company a huge step ahead.</p>
<p>But it was more than about time to get a new direction in working life. At gamigo my job drifted to a pure management position and I was  nudging around <a href="http://www.atlassian.com/de/software/jira/overview">JIRA tickets</a> and <a href="http://office.microsoft.com/de-de/excel/">Excel files</a> (okay some of them where <a href="https://docs.google.com/">Google Docs</a> <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) the whole day. But now I joined the Ranks of technicians again <code>&lt;cheer /&gt;</code>!</p>
<p>Hopefully I will have some time for reviving this blog. For now I am trying to learn some new stuff &#8211; like <a href="http://clojure.org/">Clo<i>j</i>ure</a>, <a href="http://webnoir.org/">Noir</a>, <a href="http://www.heroku.com/">Heroku</a> or <a href="http://www.mongodb.org/">mongoDB</a>for my new job. For me, this sounds like lots of fun!</p>
<div class="shr-publisher-107"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/12/making-a-new-move-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing around with Scala</title>
		<link>http://www.niclas-meier.de/2011/05/playing-around-with-scala/</link>
		<comments>http://www.niclas-meier.de/2011/05/playing-around-with-scala/#comments</comments>
		<pubDate>Sun, 29 May 2011 15:39:20 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=100</guid>
		<description><![CDATA[After some inspiration the last few weeks, I decided to scrape together some spare time and have a closer look at the Scala programming language. This was kind of overdue because I am trying to have a look at new technologies at least once a year. One major challenge is always finding an interesting topic [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/05/playing-around-with-scala/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>After some inspiration the last few weeks, I decided to scrape together some spare time and have a closer look at the <a href="http://www.scala-lang.org">Scala</a> programming language. This was kind of overdue because I am trying to have a look at new technologies at least once a year. </p>
<p>One major challenge is always finding an interesting topic which also has an appropriate level of difficulty. For my venture into  <a href="http://www.scala-lang.org">Scala</a> I choose a small open source project which I initiated two years ago called <a href="http://code.google.com/p/jaev/"></a>. This small framework validates an e-mail address and also checks the domain (via the DNS). This project seemed to have the right size and so I decided to build a scala variant called <a href="https://github.com/niclasmeier/saev">saev</a>.</p>
<p>This turned out to be a very demanding venture which challenges a lot of knowledge and beliefs which I have from my activities in the Java environment.<span id="more-100"></span>I would be lying if wouldn&#8217;t tell you, that I already head some doubts on the proceedings in the Java community. Things like having no update on the JDK for about two years now, including the unfortunate discussions on lambda expressions in Java, are paralyzing the development on the language basis. On the other hand side I have no idea how to judge the acquisition of Sun Microsystems by Oracle.</p>
<p>I first stumbled over Scala when I still was working at <a href="http://www-de.scoyo.com">scoyo</a>, when my former boss was building a small script which was converting localized text into an XML format. I found the language it self quite interesting but when you are in the middle of a Java team it was not easy to get started with it and had other things occupying me more.</p>
<p>Beginning this year I was willing to give <a href="http://www.scala-lang.org">Scala</a> a new chance after having a quick look at <a href="http://www.php.net">PHP</a> and <a href="http://www.ruby-lang.org/de">Ruby</a>. Both of PHP and Ruby didn&#8217;t convince me so I bought a <a href="http://www.amazon.com/Programming-Scala-Comprehensive-Step---Step/dp/0981531644/ref=sr_1_1?ie=UTF8&amp;qid=1306680866&amp;sr=8-1">Scala book</a> and read it. But I must confess after this lecture I still was interested but nothing more. But after attending the <a href="http://www.devcon-hamburg.de/">Developer Conference Hamburg 2011</a> I decided to give Scala a real try.  So I bought another <a href="http://www.amazon.de/Scala-für-Umsteiger-Friedrich-Esser/dp/3486596934/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1306681065&amp;sr=8-1">book</a> especially written by <a href="http://www.informatik.haw-hamburg.de/esser.html">Prof. Dr. Friedrich Esser</a> for guys who want to change form e.g. Java to Scala. I just want to take the take the time to recommend this <a href="http://www.amazon.de/Scala-für-Umsteiger-Friedrich-Esser/dp/3486596934/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1306681065&amp;sr=8-1">book</a> &#8220;<a href="http://www.amazon.de/Scala-für-Umsteiger-Friedrich-Esser/dp/3486596934/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1306681065&amp;sr=8-1">Scala für Umsteiger</a>&#8220;. Very well written book which shows you in the first chapter (approx. 100 pages) how to write the stuff you do in Java in the Scala language. An then fasten your seat belts <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I am playing around with Scala for about a week right now, but I have to confess that I am somehow impressed and also a little bit scared. Let me explain why:<br />
Fist of all the syntactical power of this &#8220;post functional&#8221; language is impressive for someone who did Java for over ten years. You can describe many of your problem solution in a very simple way. But when you want/need you can always fall back into Java because Scala uses the Java VM as foundation. On the other hand side I met a couple of programmers which are nice people, but who would be overstrained by this. And to be honest there are always situations where I take both of my books and google to figure out what some code is doing and why it&#8217;s working.<br />
Don&#8217;t get me wrong I am pretty good programmer and I am using even complex concepts like AOP (aspect oriented programming) or dependency injection for a couple of years now. And I know the can cause lots of trouble and I am not sure if I should like <code>@Transactional</code> or not.</p>
<p>For my personal development I am quite sure, that I will continue to investigate Scala a little further. On the business side I am not sure if Scala will find a place in my development team. I said already ten years ago that you can use a bunch of trained apes to finish you Java project. It will take some time but the apes will figure it out. And that robustness is what you want on enterprise projects. Maybe for innovative companies or startups Scala is the language of choice or for companies which are willing to have polyglot development environment.</p>
<div class="shr-publisher-100"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/05/playing-around-with-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mind the gap</title>
		<link>http://www.niclas-meier.de/2011/05/mind-the-gap/</link>
		<comments>http://www.niclas-meier.de/2011/05/mind-the-gap/#comments</comments>
		<pubDate>Sun, 22 May 2011 19:35:22 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Software development]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=96</guid>
		<description><![CDATA[It&#8217;s sunday and I am fed up, sitting lazy behind my computer and taking a review of the last week. I attended two conferences this week so I am full of new ideas (don&#8217;t know if they are good yet) and wan&#8217;t to take a closer look on so many topics. The first conference was [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/05/mind-the-gap/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It&#8217;s sunday and I am fed up, sitting lazy behind my computer and taking a review of the last week. I attended two conferences this week so I am full of new ideas (don&#8217;t know if they are good yet) and wan&#8217;t to take a closer look on so many topics.</p>
<p>The first conference was the <a href="http://nextconf.eu">next conference</a> in Berlin which was initiated some years a go by my former employer <a href="http://www.sinnerschrader.de">SinnerSchrader</a>. So the focus of the <a href="http://nextconf.eu">next conference</a> was mixture of brand, media, entrepreneurship and technology. Due to the fact that I meet a couple of former colleagues &#8211; some of them still working for <a href="http://www.sinnerschrader.de">SinnerSchrader</a>.</p>
<p>The second conference was the <a href="http://www.devcon-hamburg.de/">Developer Conference Hamburg 2011</a> which had a sole technology focus.<span id="more-96"></span>I heard couple of very good talks on both conferences. My highlight was the the keynote of <a href="http://www.cardcloud.com/werner">Werner Vogels</a> the CTO of Amazon which spoke about the analysis of big dataset which are regularly produced by modern IT infrastructures. If you generate a couple of gigabytes of data every day you should get the information out of them.</p>
<p>Another highlight of both conferences where the <a href="http://couchdb.apache.org/">Couch DB</a> talks. Both held by <a href="http://twitter.com/#!/janl">Jan Lehnhardt</a>, one of the <a href="http://couchdb.apache.org/">Couch DB</a> core commiters who works for <a href="http://www.couchbase.com/">Couchbase</a>. Jan can talk very fast in his talks, especially when he had some coffee <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . But there is no bull*** and he definitely knows what he is talking about. Because I attended the <a href="http://nextconf.eu">next</a> and the <a href="http://www.devcon-hamburg.de/">devcon</a> I was able to get a 10.000m overview and a 100m close look on the <a href="http://couchdb.apache.org/">Couch DB</a>. I am very fascinated by this topic, but I have at the moment no idea where to use it.</p>
<p>A dilemma what <a href="http://couchdb.apache.org/">Couch DB</a> shares with <a href="http://nodejs.org/">node.js</a>. I heard of <a href="http://nodejs.org/">node</a> on both conference too. On the next <a href="http://nodejs.org/">node.js</a> was presented by <a href="http://blog.izs.me/">Isaac Z. Schlueter</a>. The topic was how <a href="http://nodejs.org/">node.js</a> performs on DIRT (<u>d</u>ata <u>i</u>ntensive <u>r</u>eal <u>t</u>ime) applications. At <a href="http://www.devcon-hamburg.de/">devcon</a> <a href="http://nodejs.org/">node.js</a> was presented by <a href="http://twitter.com/#!/felixge">Felix Geisendörfer</a> which gave a more wide range overview on the capabilites of <a href="http://nodejs.org/">node.js</a>. Unfortunately my <a href="http://www.gamigo.de">current employer</a> does at the moment some kind of &#8220;boring&#8221; <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  e-commerce stuff, so no real use for node here. Some <a href="http://www.sinnerschrader.de">SinnerSchrader</a> guys had a very innovative idea using node building the <a href="http://digitalfoosball.com/">The World’s First Digital Foosball Table</a> &#8211; nice one!</p>
<p>But the most influencing talks where from <a href="http://www.informatik.haw-hamburg.de/esser.html">Prof. Dr. Friedrich Esser</a> from the <a href="http://www.haw-hamburg.de/">HAW Hamburg</a> about <a href="http://www.scala-lang.org/">Scala</a>. The talk and the workshops where full of snappy remarks on <a href="http://www.java.com/">Java</a> programming language. I am doing Java for over ten years now. And I am confident that I am pretty good at <a href="http://www.java.com/">Java</a> and it was my favorite language the last ten years. But in the recent time I am feeling bored by <a href="http://www.java.com/">Java</a> and it&#8217;s very tight restrictions. We&#8217;ll see where the journey goes with this  <a href="http://www.scala-lang.org/">Scala</a> stuff.</p>
<p>On the other hand side there were also some talks &#8211; which we presented brilliantly &#8211; that where about stuff that I am doing for a couple of year now. One of these was the &#8220;Abstract monitoring&#8221; talk from <a href="https://www.xing.com/profile/Johannes_Mainusch">Dr. Johannes Mainusch</a> from Xing. Very nice talk, I agree 100% but I was also doing this since 2005. Good to see that other developers are cooking with water too <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>But the last week reminded me of the gap what we have at the moment and what I am supposed to close as soon as possible. But now I am armed with some new ideas &#8230;</p>
<div class="shr-publisher-96"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/05/mind-the-gap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nginxing around with WordPress</title>
		<link>http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/</link>
		<comments>http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 19:30:24 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[Webserver]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=91</guid>
		<description><![CDATA[Some of you may already have noticed, that this blog uses WordPress as blog software. Nothing special about that I guess. As I mentioned before in January/February I moved my website from my old provide to a new one making some significant changes to the blog and it&#8217;s infrastructure. I am in the web business [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Some of you may already have noticed, that this blog uses <a href="http://www.wordpress.com">WordPress</a> as blog software. Nothing special about that I guess. As I mentioned before in January/February I moved my website from my old provide to a new one making some significant changes to the blog and it&#8217;s infrastructure.</p>
<p>I am in the web business since a couple of years and I already worked with a couple of servers. Like most of the others I worked most with the <a href="http://httpd.apache.org">Apache web server</a>. Which is still the work horse of the internet. But recently the <a href="http://nginx.org/">nginx</a> web server which is a lean, mean web serving machine. To get a little more experience with this product I decided to use it for my blog.<span id="more-91"></span>The <a href="http://nginx.org/">nginx</a> web server already matured already 9 years and reached recently (12. April 2011) the version 1.0.0 (congratulations on this by the way <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ). But there are still some major differences between the <a href="http://httpd.apache.org">Apache</a> and the <a href="http://nginx.org/">nginx</a> web servers.<!--more-->For me this started when I wanted to use <a href="http://www.wordpress.com">WordPress</a> which is build upon <a href="http://www.php.net">PHP</a>. <a href="http://www.php.net">PHP</a> itself depends on the <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">common gateway interface</a> (a.k.a. <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a>) which is a <a href="http://httpd.apache.org/docs/2.0/mod/mod_cgi.html">long time component</a> of the Apache web server. Unfortunately the nginx server does not support <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> so you&#8217;ll have cover some more basics.</p>
<p>nginx itself supports CGI using the <a href="http://en.wikipedia.org/wiki/FastCGI">fast CGI</a> standard. Which does actually a little bit more the plan CGI. To serve fast CGI you may use the <a href="http://wiki.nginx.org/HttpFcgiModule">nginx fast CGI module</a>, so you still have access to all the scripting languages you like. But be aware that the nginx web server is known for it&#8217;s fabulous capabilities serving static content.</p>
<p>After installing nginx, a fast CGI wrapper app to execute the PHP scripts and configuring the fast CGI module, the setup of the WordPress blog was pretty basic. I&#8217;m using a standard <a href="http://www.mysql.com">MySQL</a> database backing the WordPress. The whole system runs on a <a href="http://www.centos.org/">CentOS</a> linux. The choice of the linux distribution was also inspired by the preferred system I use at my job for almost two years. Some times it&#8217;s good to stick to things you know <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>This was the status on which the whole system ran since February. But as a few &#8211; regarding to google analytics &#8211; of you may have noticed that the whole system was very slow. This is a direct result of my stinginess, because I don&#8217;t want to pay more money for my root server <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So today I invested some spare time to look for other optimizations and I would like to say, that I was successful. My first search lead to a WordPress plugin to cache the pre-rendered WordPress pages. I have not this much posting and commenting traffic, so pre-rendering the pages seemed to be a good idea. The plugin of my choice is <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> which provides a very easy to configure caching of WordPress pages.<br />
But I wanted to go one step further: The <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> plugin offer the possibility to bypass WordPress and PHP completely by using compressed pre-rendered pages via <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a>. I guess most of you noticed the problem: <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a> is an Apache module, which does not work with the nginx server, but nginx provides a powerful <a href="http://wiki.nginx.org/HttpRewriteModule">rewriting module</a> too. A very helpful <a href="http://ocaoimh.ie/2009/11/23/wordpress-nginx-wp-super-cache/">blog post</a> from the WP Super Cache author helped to configure the web server. And now &#8211; at least for any anonymous user &#8211; the site is fast.</p>
<p>It do no longer take about two seconds to return the the first bytes to the user and the page itself is compressed only approximately five kilobytes large. To speed up the perceived loading time of the page, I am using the <a href="http://wordpress.org/extend/plugins/use-google-libraries/">Use Google Libraries</a> plugin pass the delivery of standard Java Script libraries to google. So the libraries can participate on sharing between different pages and the long time expiry which is used by <a href="http://www.google.com">google</a>. The plugin <a href="http://wordpress.org/extend/plugins/wp-minify/">WP Minify</a> joins and compresses the JS and CSS used by the theme and other plugins I use, so the browser does download only a few minimized files instead of dozens of CSS and JS files.</p>
<p>I can say, that the experiment was quite successful and after getting familiar with some peculiarities the setup process was quite easy.</p>
<div class="shr-publisher-91"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A new home</title>
		<link>http://www.niclas-meier.de/2011/02/a-new-home/</link>
		<comments>http://www.niclas-meier.de/2011/02/a-new-home/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 21:33:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=74</guid>
		<description><![CDATA[I just wanted to say, that I am back &#8211; at least a kind of The last couple of month I was buried under a sh****** of work since I joined my new employer, but on the other hand side I a lot of fun and it is a very challenging job. The last couple [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/02/a-new-home/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I just wanted to say, that I am back &#8211; at least a kind of <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>The last couple of month I was buried under a sh****** of work since I joined my new <a href="http://www.gamigo.com">employer</a>, but on the other hand side I a lot of fun and it is a <i>very</i> challenging job.</p>
<p>The last couple of weeks I used some spare time to move my infrastructure to a new home, including this blog. I will shut down my private blog soon, I guess my live is not exciting enough or may be I am not exhibitionistic enough to write over every breath I take. But now this blog is almost completely migrated and got a shiny new theme too &#8211; I hope you like it!</p>
<p>The good news are, that I want to take up my technophile blogging activities. I learned very much in the last couple of month about writing good software and what to do to prevent it.</p>
<div class="shr-publisher-74"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/02/a-new-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contemporary Software Development: Building</title>
		<link>http://www.niclas-meier.de/2010/05/contemporary-software-development-building/</link>
		<comments>http://www.niclas-meier.de/2010/05/contemporary-software-development-building/#comments</comments>
		<pubDate>Sat, 15 May 2010 20:51:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[Buildr]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=68</guid>
		<description><![CDATA[The subject of my first post of the series &#8220;Contemporary Software Development&#8221; will be building. How to build your software project is a decision which is made quite early when you start developing. Unfortunately in a lot of projects this very important topic does not get the appreciation it deserves. On one hand side it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2010/05/contemporary-software-development-building/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>The subject of my first post of the series &#8220;Contemporary Software Development&#8221; will be building. How to build your software project is a decision which is made quite early when you start developing.</p>
<p>Unfortunately in a lot of projects this very important topic does not get the appreciation it deserves. On one hand side it&#8217;s a very sad story of suffering and endurance. On the other hand side we are talking about a lot of wasted money.<span id="more-68"></span>In my career as software engineer I experienced some different approaches to the project setup and the build process.</p>
<p>It started with something like <code>find . -name '*.java' | xargs javac</code>, which worked quite well for the first weeks of my professional career. But with a couple of software developer working on a project <em>you want something more standardized.</em></p>
<p>So we went on with <code>make</code><a href="http://www.gnu.org/software/make/">(*)</a>. I guess most of the software engineers will know this build tool which still is a standard tool in the Unix/Linux world. <code>make</code> is a very powerful tools but has its peculiarities also. The <code>make</code> grammar is very delicate when it comes to white spaces. I quess quite a few people sat over a broken <code>make</code> build when a <code>TAB</code> char wasted your build script.</p>
<p>In the Java world <a href="http://ant.apache.org/">Apache Ant</a> was the successor to <code>make</code> in my career. The problem with <code>make</code> and the Java world is, that make is not really platform independent. There are <code>make</code> ports for Microsoft Windows but (at least when I made the jump from <code>make</code> to Ant) it does not work very well. So if you have a heterogeneous environment e.g. you develop on Microsoft Windows and you deploy into a Linux based cloud, <em>you want your build to to be platform independent.</em></p>
<p>A nice story about platform independence. I did some consulting in a project for the Deutsche Bank Italy and a very large (and expensive) consulting company provided the BEA Weblogic build and setup. I am not 100% sure but I guess it was an <a href="http://ant.apache.org/">Apache Ant</a> based build. One major issue was the application server integration integration. To solve it, the complete project was placed and build in the application server which was committed in to the CVS source control management system. The delivery artifact was &#8211; of course &#8211; delivered without the application server. But this leads to another wish I have when I am using a build. <em>You want the build to credit the current  environment.</em> If you are building for your local development environment you may have different requirements concerning the built artifact as when you are creating an artifact that will be deployed on staging or productive environment.</p>
<p>Back on memory lane: <a href="http://ant.apache.org/">Apache Ant</a> worked pretty well for some years and a couple of projects. But one thing that started to annoy me. Every project was using a slightly build setup so in the daily business there were always searching for artifacts or checking library versions.</p>
<p>Some former colleagues introduced me to <a href="http://maven.apache.org/">Apache Maven</a>. I started with <a href="http://maven.apache.org/maven-1.x/index.html">Maven 1</a> which is a quite interesting mixture of <a href="http://ant.apache.org/">Ant</a> with a framework that offered the possibility to manipulate the Ant build file during the runtime. But <a href="http://maven.apache.org/">Apache Maven</a> had some features which I hat to get used to.<br />
An example is the rigid directory structure defined in a Maven build: Why do I have to follow them? I want my special directory names! But nowadays I love this structure which is equal in every project. You find your files so fast now and even in foreign project. That&#8217;s another thing that you want: <em>You want your builds to follow standards, so you can get familiar with the project in very short time.</em> If you are working in the software business a couple of years, may have already realized that you will see very much projects during a professional career and standard projects and processes will make your life much more easy.</p>
<p>Let&#8217;s talk about some goodies now which modern build system offer. I will use <a href="http://maven.apache.org/">Apache Maven</a> as example but other systems like <a href="http://rake.rubyforge.org/">rake</a> or <a hef="http://buildr.apache.org/">buildr</a> offer similar functions.</p>
<p>One thing I love/hate is dependency management. When I started with make or ant, we where committing all libraries into our CVS. Which worked quite well, in most cases you could check our the project, performed the initial build and started to work. But there where lots of minor but very nasty problems. Starting from which library version is really used to incompatibilities of the build tool version.</p>
<p>With the <a href="http://maven.apache.org/">Apache Maven</a> dependency resolution mechanism a new area begun. If you are having one independent project the mechanism is pretty easy to use. You define the libraries you want to use in your <code>pom.xml</code> and maven takes care of the rest. Okay if you want to use libraries which are not in the maven central repository it&#8217;s a little more complicated <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>If you are having a multi module/project environment things will get messy pretty easy, but: They would also if you don&#8217;t use the dependency management mechanism. You ask why? When you don&#8217;t use this mechanism you&#8217;ll normally have a huge monolithic project in your SCM system which will get even more difficult to manage or build. So you <em>want to have a transparent dependency management in your build system</em>. With <a href="http://ant.apache.org/ivy/">Ivy</a> for example you&#8217;ll have an add-on which offers the possibility to have an dependency management when you are using <a href="http://ant.apache.org/">Ant</a>.</p>
<p>Another goodie is release management. It&#8217;s very handy if you start a build to create your release artifact and your tag (or something similar) in the SCM system of your choice. <em>You want your release process embedded in your build system, so you can perform the build when you are creating your release.</em></p>
<p>Another important topic is testing. You <em>really want your build tool to support your testing facilities.</em> At least when you create your release or deployment artifact you want your build to automatically run your test suite.</p>
<p>I have only one topic left in this post, that is IDE support. Unfortunately most modern IDE like <a href="http://www.eclipse.org/">Eclipe</a>, <a href="http://netbeans.org/">Netbeans</a> or <a href="http://www.jetbrains.com/idea/">Intellij IDEA</a> offer a IDE specific build. This this very comfortable if you have a small project and what to deal only with your IDE. But you&#8217;ll grow really beyond this (my experience). But integration into other build tools is sometimes really poor. So you have to check how you can bridge the gap between your IDE and the build tool. E.g. the maven directory structure troubles some IDE<br />
standard configurations. Fortunatly more and more projects provide solutions for this.</p>
<p>So let&#8217;s have a quick resume. This is what you should want in your build system:</p>
<ul>
<li>standardized process</li>
<li>platform indipendence (if your need it)</li>
<li>credit current environment</li>
<li>standardized structures</li>
<li>dependency management</li>
<li>embeddable release process (including SCM support)</li>
<li>support of your test tools</li>
<li>IDE support</li>
</ul>
<p>I think this list is not too lang and offers some major improvements for your daily work. So if your build process is missing some items from this list, you maybe should think about your build process. And remember: Your development resources are far to valuable to be wasted in an inefficient build process <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-68"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2010/05/contemporary-software-development-building/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Announcing: Contemporary Software Development</title>
		<link>http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/</link>
		<comments>http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/#comments</comments>
		<pubDate>Tue, 11 May 2010 19:26:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Allgemein]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=66</guid>
		<description><![CDATA[It has been some time since my last blog post. But I promise to do better. I am planning a series ob blog post in which I am trying to explain how you should want to develop software nowadays &#8211; at least in my opinon. I will try to cover topics like: How to build [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It has been some time since my last blog post. But I promise to do better. I am planning a series ob blog post in which I am trying to explain how you should want to develop software nowadays &#8211; at least in my opinon.</p>
<p>I will try to cover topics like: How to build your system? How to manage you source code and you versions? Or what do do with your deployment data?</p>
<p>But I don&#8217;t want you to tell you which frameworks to use in fact I want to discuss what you should want to do not how you are going to do it.</p>
<p>I am excited, it will be a lot of work, but I am excited <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-66"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Pages with Tapestry 5</title>
		<link>http://www.niclas-meier.de/2010/03/virtual-pages-with-tapestry-5/</link>
		<comments>http://www.niclas-meier.de/2010/03/virtual-pages-with-tapestry-5/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 15:13:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tapestry]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=62</guid>
		<description><![CDATA[Some of you may know Apache Tapestry 5 already. It&#8217;s a very great framework for building web applications. In my opinion you&#8217;ll won&#8217;t find a framework this mature and production ready very easy. Tapestry 5 covers a wide variety of topics related to the creation of state-of-the-art web applications. So it&#8217;s no surprise that Howard [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2010/03/virtual-pages-with-tapestry-5/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Some of you may know <a href="http://tapestry.apache.org/tapestry5/">Apache Tapestry 5</a> already. It&#8217;s a very great framework for building web applications. In my opinion you&#8217;ll won&#8217;t find a framework this mature and production ready very easy. Tapestry 5 covers a wide variety of topics related to the creation of state-of-the-art web applications. So it&#8217;s no surprise that <a href="http://tapestryjava.blogspot.com/">Howard Lewis Ship</a> the creator/founder of the Tapestry Project joined the ranks of the <a href="http://tapestryjava.blogspot.com/2010/03/java-champion.html>&#8220;Java Champions</a>. So congratulations from here <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>But back on topic: One fundamental rule of the Tapestry 5 framework is, that each page has a corresponding class which contains all (java-) logic for this page. This mechanism works sole with convention over configuration and there is no exception to this rule. At least in standard Tapestry 5 &#8230;<span id="more-62"></span>In the company I used to work we depended on Tapestry pretty heavy. We had created a couple very good solutions using this framework but we also had some challenges to meet. I guess they are pretty common to web based companies.</p>
<ul>
<li>We had to use a CMS system (<a href="http://www.magnolia-cms.com/home.html">Magnolia CMS</a> in this case) to enable the marketing and non-techical guys to maintain all the content they are creating.</li>
<li>We had to maintain a couple of so called landing pages. I guess most of the web guys know and hate them <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  These pages are just an empty shell containing nothing more than some sightly different logos and graphics of partner companies. The also provide a nice URL in most cases like: <code>http://www.mycomany.com/tv</code>, <code>/mobile</code> or <code>/unameit</code>. Unfortunately some of these landing pages hade some minor dynamical stuff on it. </li>
<li>Most of this landing pages require that you are storing some (voucher) code into your application to modifier your check-out process a little bit.</li>
</ul>
<p>So, now you have a couple of pages, of which you don&#8217;t know when they appear &#8211; and you really don&#8217;t want to know, because coordinating the timing with the marketing guys is always a mess <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  -, with very similar structure and functionality. As a matter of fact this case should be a text book example for component reuse. but this is a case where Tapestry 5 and the convention-over-configuration thing works against us.</p>
<p>So what do you have to do in classic Tapestry 5? Jepp you allready guessed it, you have to create a page class for each of this landing pages. Okay thanks to inheritance this class will be de-facto empty. But it is annoying to create this class. You&#8217;ll have to create a version of your web application, do a QA cycle (if you want to play it right), make a deployment. So you have a lots of communication with a bunch of other departments. In a world with perfect processes you might to accept this, but I guess most of the guys out there know the situation where a junior business consultant guy stands right at your desk telling you of the nation wide TV campaign that launches tomorrow and that needs this new landing page. Maybe some of you already tried to say the &#8216;n*&#8217; word <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>A early solution was to introduce some Meta templates in out CMS. They were some simple HTML comments which where evaluated by a service in our web application and re-assembled via simple Tapestry pages and components. This worked quite well but brought us a bunch of issues &#8211; like template caching, dynamic contents in templates, etc. &#8211;  which are already solved in Tapestry. The solution was also pretty limited in when dynamical and statical parts should be joined together. So I took some time to evaluate a different approach:</p>
<p><i>My first question was:</i> Is it possible to make tapestry work with pages that do not have a class as backup?</p>
<p>I never tried this, because I figured out, that I actually didn&#8217;t want to do this, and as a matter of fact, it makes the whole exercise a lot easier. What I did was to make Tapestry use a default class for pages tapestry does not know. I call this pages <i>virtual</i> pages. I&#8217;ll guess you always have some minor data shared between all virtual pages, so you create on page class that Tapestry may use to serve <i>virtual</i> pages.</p>
<p>So how you serve <i>virtual</i> pages with Tapestry 5.1? I was surprised who simple it was (after some month of the wrong track). So this is, how <i>virtual</i> pages may work:</p>
<ol>
<li><b>Check if the page exists</b><br />A good place to do this is the <code>ComponentClassResolver</code> with its <code>isPageName(..)</code> method. I created a <a href="http://github.com/niclasmeier/tapestry-virtual-pages/blob/master/src/main/java/net/nicl/virtualpages/services/DecoratedComponentClassResolver.java">special implementation</a> of the  <code>ComponentClassResolver</code> which decorates the Tapestry original.</li>
<li><b>Mark the request</b><br />Mark the request as request to a virtual page. I used a <a href="http://github.com/niclasmeier/tapestry-virtual-pages/blob/master/src/main/java/net/nicl/virtualpages/services/VirtualPageData.java">dedicated service</a> with thread scope for this. You also may compute and store some data in this service.</li>
<li><b>Alter page class loading</b><br />Adapt the loading of the component classes to load (and attach) the default class to the page. <a href="http://github.com/niclasmeier/tapestry-virtual-pages/blob/master/src/main/java/net/nicl/virtualpages/services/DecoratedComponentInstantiatorSource.java">Another decorated service</a> does the work here too.</li>
</ol>
<p>And voila you can deliver content for pages with no backing class, astonishing isn&#8217;t it? You may look at the <a href="http://github.com/niclasmeier/tapestry-virtual-pages">small prototype/example project at github</a> and you&#8217;ll realize how simple the solution is. The prototype is a slightly modified Tapestry 5 archetype project which will serve the URL <code>http://localhost:8080/About</code> as virtual page.</p>
<p>So far, so good! But now some last words if this is a good solution at all. First I want to mention that we had an integration ready for the architecture we used, but it went &#8211; for several reasons, most non-technical &#8211; never productive.</p>
<p>Let&#8217;s talk about some oddities first:</p>
<ul>
<li>The URLs to address the pages do not fully comply the Tapestry behaviour. In Tapstry it does not matter if you request <code>/About</code> or <code>/about</code>, but the prototype only supports a simple template resolution.</li>
<li>Some Tapestry components/mechanisms won&#8217;t work properly. Tapestry uses classes to compute links to pages. Always when this mechanism is used, you&#8217;ll may get problems. Components like <code>&lt;t:pagelink ...&gt;</code> may not work properly because you do not have a class. Keep this in mind.</li>
<li>Unexpected Runtime and memory behaviour. Tapestry is a very stable and production ready framework. But we are misusing it a little bit. Keep a close eye on memory consumption because every HTML page will now be a tapestry template and will be cached in the memory of your virtual machine. Some of some infrastructure components are also optimized for a (relatively) small amount of page instances.</li>
</ul>
<p><i>Why do I want to use Tapstry this way?</i> The first advantage is the simple creation of new pages. You&#8217;ll create the <code>.tml</code> file and you are done. We used it with a CMS in the background and with some specialized CMS templates the marketing guys where able to create a bunch of landing pages without troubling an IT guy. In addition to the standard page we used some components which contained the major functions of the pages. So we were able to create instance of this virtual pages which behaved sightly different because we passed some parameters using the <code>TML</code> of the virtual page.</p>
<p><i>Why does not offer Tapestry this mechanism?</i> First: It&#8217;s a prototype! If you take a closer look you will se how limited it is. This topic as hole comes across the tapestry mailing list regularly and there are lots of pro&#8217;s and con&#8217;s. I don&#8217;t want to discuss any of them in this blog post. But I agree with the Tapestry guys not to introduce it into the core framework.</p>
<p>At the time I was evaluating this prototype I had some very good reasons to do so and only a few are mentioned here. But if you have a big amount of content it is seldom a good idea to generate templates which are interpreted by a dynamic framework. No matter if you use JSP, Tapestry or even PHP.</p>
<p>I hope you&#8217;ll enjoyed reading this blog post. I learned much about Tapestry 5 preparing it and evaluating my idea. If you have questions of any kind feel free to contact me <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-62"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2010/03/virtual-pages-with-tapestry-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a domain specific  language with XML-Schema and JAX-B</title>
		<link>http://www.niclas-meier.de/2010/01/creating-a-domain-specific-language-with-xml-schema-and-jax-b/</link>
		<comments>http://www.niclas-meier.de/2010/01/creating-a-domain-specific-language-with-xml-schema-and-jax-b/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 11:32:30 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Domain Specific Languages]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JAX-B]]></category>
		<category><![CDATA[Magnolia CMS]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=56</guid>
		<description><![CDATA[Here at scoyo we use the Magnolia CMS to manage our website content. It&#8217;s a quite nice tool based on the Content Repository API for Java (JCR) (JSR-170). In this blog post I want to tell you a little more about a small domain specific language, which I created to manage the migration of content [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2010/01/creating-a-domain-specific-language-with-xml-schema-and-jax-b/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Here at <a href="http://www.scoyo.de">scoyo</a> we use the <a href="http://www.magnolia-cms.com">Magnolia CMS</a> to manage our website content. It&#8217;s a quite nice tool based on the <a href="http://en.wikipedia.org/wiki/Content_repository_API_for_Java">Content Repository API for Java (JCR)</a> (<a href="http://jcp.org/en/jsr/detail?id=170">JSR-170</a>). In this blog post I want to tell you a little more about a small domain specific language, which I created to manage the migration of content and configuration of our <a href="http://www.magnolia-cms.com">Magnolia CMS</a> installation, using XML-Schema, JAX-B and the facilities of the CMS.</p>
<p><span id="more-56"></span>To introduce you a little more into the domain. When using a CMS with some other software components you&#8217;ll have a situation very similar like having a database. You have content which other (non-tech type) people manage and if you change your application sometimes you&#8217;ll have to change the content &#8211; or worse the structure of the content &#8211; too. In the database world there is a <a href="http://www.amazon.com/Refactoring-Databases-Evolutionary-Database-Design/dp/0321293533/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1262857005&amp;sr=8-1">very nice book regarding the refactoring of databases</a>.</p>
<p>As a solution to this issue the magnolia CMS offer some API related to the <code> info.magnolia.module.ModuleVersionHandler</code>. This API&#8217;s offers the possibility to define <code>info.magnolia.module.delta.Task</code>s which may be related to specific module version. So the CMS may discover on startup time which <code>Task</code>s to execute when migrating e.g. from module version 1.4.2 to 1.4.6. This is very nice because you can load partial XML content dumps or move some content (or configuration) nodes around.</p>
<p>Unfortunately you&#8217;ll have to do this while program the update procedure in Java in your <code>ModuleVersionHandler</code>. To close this gap we introduced an own domain specific language using XML. I refer to this as DSL because it evolved to be much more like a simple XML config file, I&#8217;ll hope you&#8217;ll get the point later on. The inspiration gave a <a href="http://www.menzel.com/">freelance contractor</a> with very deep <a href="http://www.magnolia-cms.com">magnolia</a> know-how. So here is how I did it:</p>
<p>First of all the <code>ModuleVersionHandler</code> has to deliver all the information defined in the XML file, so you&#8217;ll have to override it. So we subclassed the <code>info.magnolia.module.DefaultModuleVersionHandler</code> to override methods like <code>getExtraInstallTasks(...)</code>. This new version handler is responsible for reading the XML file, and converting it into the objects that magnolia handles.</p>
<p>Next step was to define a XML format. It should be an expressive format, nice to read and easy to understand. So waived of standard formats or facilities like the <a href="http://www.springframework.com/">Springframework</a> which also offers facilities to assemble object graphs from XML files. The format we choose looks like:</p>
<pre class="brush:xml">&lt;updates&gt;
	&lt;version number="1.5.0"&gt;
		&lt;description&gt;Changed implementation of header selection&lt;/description&gt;
		&lt;updates&gt;
			&lt;load file="config.modules.scoyo.dialogs.pageProperties.xml"/&gt;
			&lt;if-exists repository="WEBSITE" node="/en"&gt;&lt;then&gt;
				&lt;set-property node="/de" repository="WEBSITE" property="reportSuiteIdLive"&gt;&lt;value&gt;test_en&lt;/value&gt;&lt;/set-property&gt;&lt;/then&gt;
			&lt;/if-exists&gt;

 		&lt;/updates&gt;
	&lt;/version&gt;
&lt;/updates&gt;</pre>
<p>which is quite nice to read and you&#8217;ll have your documentation in the right place. In order to automatically process it using JAX-B you&#8217;ll have to define a <a href="http://www.w3.org/XML/Schema">XML-Schema</a> which will be used to generate your Java bindings. Besides this it&#8217;s always good to have a XML-Schema, I&#8217;ll give you some further examples later <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Our schema looks like this (at least in eclipe)<br />
<img src="http://euve11383.vserver.de/wp-content/uploads/2010/01/Eclipse.png" border="0" alt="Eclipse.png" width="588" height="575" /></p>
<p>We defined some elements (as seen on the left hand side). Each of this elements contains some attributes (or inner elements) which are passed to the magnolia <code>Task</code>s. The clou of this XML-Schema is the <code>Task</code> type and the <code>&lt;task /&gt;</code> element. The <code>&lt;task /&gt;</code> element is an element, which all elements defining a specific task (e.g. <code>&lt;load /&gt;</code>) must have as substitution group. Doing this allows on every place where a <code>&lt;task /&gt;</code> may be placed in XML another element of this substitution group may be placed too. In fact you&#8217;ll never use <code>&lt;task /&gt;</code> but always use a specific element like <code>&lt;load /&gt;</code>. The <code>Task</code> XML type covers the XML type part of the <code>&lt;task /&gt;</code> element, when generating the XML bindings the <code>Task</code> XML type will be translated into an abstract super class for all specific types like the <code>Load</code> XML type, which defines the structure of the <code>&lt;load /&gt;</code> element.</p>
<p>To generate the XML binding classes from the XML-Schema we use the <a href="http://maven.apache.org/">Apache Maven 2</a> plugin from <a href="http://mojo.codehaus.org/">the Codehaus mojos</a>. You may configure it like this:</p>
<pre class="brush:xml">&lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.2&lt;/version&gt;
    &lt;executions&gt;
        &lt;execution&gt;
        	&lt;id&gt;bootstrap&lt;/id&gt;
        	&lt;phase&gt;generate-sources&lt;/phase&gt;
            &lt;configuration&gt;
            	&lt;schemaFiles&gt;bootstrap_1_2.xsd&lt;/schemaFiles&gt;
                &lt;packageName&gt;...&lt;/packageName&gt;
            &lt;/configuration&gt;
            &lt;goals&gt;
                &lt;goal&gt;xjc&lt;/goal&gt;
            &lt;/goals&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
    &lt;configuration&gt;
    	&lt;verbose&gt;true&lt;/verbose&gt;
        &lt;outputDirectory&gt;${project.build.directory}/generated-sources/java&lt;/outputDirectory&gt;
        &lt;clearOutputDir&gt;false&lt;/clearOutputDir&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;</pre>
<p>The JAX-B bindings will produce nice annotated java beans which you can use in the further work. Another nice side effect of using JAX-B is, that it&#8217;s blazing fast compared to use DOM or XPath processing of your XML files. Another nice effect of having an XML-Schema.</p>
<p>So, after defining the XML-Schema and generating the JAX-B binding the next thing to do is to unmarshal the data from the XML file (or <code>InputStream</code>) which is not more than 20 lines of standard java code. Then you have an object graph representing the XML and the only thing left is to create the objects you (or the Magnolia CMS) need from this object graph. This should be an accomplishable task for a serious developer <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I choose to create a generic mapper interface like</p>
<pre class="brush:java">interface TaskHandler {
	info.magnolia.module.delta.Task create(T xmlTask);
}</pre>
<p>and use a <code>java.util.Map</code> to determine the right <code>TaskHandler</code> instance for a XML task bean instance and voila I had all the <code>info.magnolia.module.delta.Task</code> instances which where defined in XML. Some glue code which does some sorting and other stuff completed my <code>ModuleVersionHandler</code>. A <code>TaskHandler</code> implementation could look like this:</p>
<pre class="brush:java">dictionary.put(Load.class, new TaskHandler(Load.class) {
    @Override
    public Task create(Load xmlTask) {
        String name = name(xmlTask, String.format("Load file '%s'.", xmlTask.getFile()));
        String description = description(xmlTask, String.format("Load file '%s' for XML import.", xmlTask.getFile()));
        String resource = String.format("/mgnl-bootstrap/%1$s/%2$s", moduleName, xmlTask.getFile());
        return new BootstrapSingleResource(name, description, resource,
                javax.jcr.ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
    }
});</pre>
<p>I used an anonymous inner class an add the instance directly to the dictionary mapping all JAX-B types to the <code>TaskHandler</code>. The task handler itself uses the getter from the XML bean to create a new instance of the <code>BootstrapSingleResource</code> task. You will mention that the name of the element (<code>&lt;load /&gt;</code>) is more readable. One of the benefits using a specialized domain specific XML file.</p>
<p>I promised to give some more advantages of having an XML-Schema. Another Advantage is that you may validate the XML (quite boring) and when you deploy the XML to a public location (e.g. a web server) you will get auto completion in Eclipse. Which is very nice!</p>
<p>So my resume: Sometimes it&#8217;s more than only nice to have a solution specific to the problem domain. With very little effort you are able to create this solution using XML-Schema and JAX-B technology stack. The result in this case was a well documented XML format which can handle various content migration scenarios. With some further levels of indirections (which were very simple) I was able to introduce programming language constructs like conditions (e.g. the <code>&lt;if-exists repository="WEBSITE" node="/en" /&gt;</code> element). I guess it&#8217;s okay to call it a language now, isn&#8217;t it?</p>
<p>There are many situation where standard soultions like the <a href="http://www.springframework.com/">Springframework</a> (or the <a href="http://en.wikipedia.org/wiki/SOAP">SOAP</a> message XML format) are the best choice to quickly assemble an object graph, but when the XML (or the content in general) is object to changes made by humans it&#8217;s always worth to consider a more human readable variant.</p>
<div class="shr-publisher-56"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2010/01/creating-a-domain-specific-language-with-xml-schema-and-jax-b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

