<?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://nicl.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://nicl.net</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 20:51:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Contemporary Software Development: Building</title>
		<link>http://nicl.net/2010/05/contemporary-software-development-building/</link>
		<comments>http://nicl.net/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 "Contemporary Software Development" 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's a [...]]]></description>
			<content:encoded><![CDATA[<p>The subject of my first post of the series "Contemporary Software Development" 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'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 - of course - 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'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'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's a little more complicated <img src='http://nicl.net/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't use the dependency management mechanism. You ask why? When you don't use this mechanism you'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'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'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'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'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://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2010/05/contemporary-software-development-building/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Announcing: Contemporary Software Development</title>
		<link>http://nicl.net/2010/05/announcing-contemporary-software-development/</link>
		<comments>http://nicl.net/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 - at least in my opinon.
I will try to cover topics like: How to build your [...]]]></description>
			<content:encoded><![CDATA[<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 - 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'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://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/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://nicl.net/2010/03/virtual-pages-with-tapestry-5/</link>
		<comments>http://nicl.net/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's a very great framework for building web applications. In my opinion you'll won'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's no surprise that Howard [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you may know <a href="http://tapestry.apache.org/tapestry5/">Apache Tapestry 5</a> already. It's a very great framework for building web applications. In my opinion you'll won'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'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>"Java Champions</a>. So congratulations from here <img src='http://nicl.net/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 ...<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://nicl.net/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't know when they appear - and you really don't want to know, because coordinating the timing with the marketing guys is always a mess <img src='http://nicl.net/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'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 'n*' word <img src='http://nicl.net/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 - like template caching, dynamic contents in templates, etc. -  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'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'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'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'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 - for several reasons, most non-technical - never productive.</p>
<p>Let'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't work properly. Tapestry uses classes to compute links to pages. Always when this mechanism is used, you'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'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'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's and con's. I don'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'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://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/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://nicl.net/2010/01/creating-a-domain-specific-language-with-xml-schema-and-jax-b/</link>
		<comments>http://nicl.net/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</dc:creator>
				<category><![CDATA[Domain Specific Languages]]></category>
		<category><![CDATA[JAX-B]]></category>
		<category><![CDATA[Java]]></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'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[<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'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'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'll have to change the content - or worse the structure of the content - 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&#038;s=books&#038;qid=1262857005&#038;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'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'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'll hope you'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'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>
&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'll have your documentation in the right place. In order to automatically process it using JAX-B you'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's always good to have a XML-Schema, I'll give you some further examples later <img src='http://nicl.net/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://nicl.net/wp-content/uploads/2010/01/Eclipse.png" alt="Eclipse.png" border="0" 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'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>
&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'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://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I choose to create a generic mapper interface like</p>
<pre>
interface TaskHandler<t extends com...xml.Task> {
	info.magnolia.module.delta.Task create(T xmlTask);
}
</t></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>
dictionary.put(Load.class, new TaskHandler<load>(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);
    }
});
</load></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'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's okay to call it a language now, isn'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's always worth to consider a more human readable variant.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2010/01/creating-a-domain-specific-language-with-xml-schema-and-jax-b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Temporal coincidence or news on maven builds</title>
		<link>http://nicl.net/2009/11/temporal-coincidence-or-news-on-maven-builds/</link>
		<comments>http://nicl.net/2009/11/temporal-coincidence-or-news-on-maven-builds/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:31:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=51</guid>
		<description><![CDATA[A few weeks ago I wrote a blog entry about building applications with Apache Maven and where I see the most demanding problems with Maven builds.
Coincidentally Jason van Zyl a mastermind behind the Apache Maven Project wrote a series of articles on the  blog at Sonartype, which are describing the future road map of [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a <a href="/2009/11/some-thoughts-about-building/">blog entry</a> about building applications with <a href="http://maven.apache.org">Apache Maven</a> and where I see the most demanding problems with Maven builds.</p>
<p>Coincidentally <a href="http://twitter.com/jvanzyl">Jason van Zyl</a> a mastermind behind the <a href="http://maven.apache.org">Apache Maven</a> Project wrote a series of articles on the  <a href="http://www.sonatype.com/people/author/jason/">blog</a> at <a href="http://www.sonatype.com">Sonartype</a>, which are describing the future road map of Maven 3.0.</p>
<p><span id="more-51"></span>It was quite funny: On the friday after I wrote my article I had a discussion on the lunch break with a <a href="https://www.xing.com/profile/Bjorn_Stachmann">colleague</a> just about this topic. On sunday evening I stumbled accidentally across the first article from <a href="http://twitter.com/jvanzyl">Jason van Zyl</a> with the title <a href="http://www.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-one-2/">"Maven 3.x: Paving the desire lines — Part One"</a>. In this article Jason describes how the Maven development team tried to figure which way to go with Maven 3.0. Besides the fascinating informations the article is also fun to read, very nice. A few days later the <a href="http://www.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-two/">second part</a> was published. Which was great, too.</p>
<p>After reading these articles I was some kind of reconciled and excited about the future of Maven. But I had also a lot of work to do to prepare the new Release of <a href="http://www.scoyo.de">scoyo</a>. So the only thing I could to was to add the Sonartype blog to my RSS reader.</p>
<p>So it happens that I didn't miss the <a href="http://www.sonatype.com/people/2009/11/maven-30-alpha-3-released/">announcement of the first public alpha version</a> of Maven 3.0. I had not enough time so far to check it out, but I will follow the events eagerly.</p>
<p>So sometimes things happen parallel and my complaints about building and Maven came along with the start of the 3.0 series of the <a href="http://maven.apache.org">Apache Maven</a> project.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/11/temporal-coincidence-or-news-on-maven-builds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some thoughts  about building</title>
		<link>http://nicl.net/2009/11/some-thoughts-about-building/</link>
		<comments>http://nicl.net/2009/11/some-thoughts-about-building/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 13:31:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[Flex-mojo]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=49</guid>
		<description><![CDATA[Over the last few days I had some thoughts about building your project. I am using Apache Maven for quite a while now. At my current employer we use Maven for all our components even our learn portal which is build entirely in Adobe Flex, using the Flexmojos.
The bottom line is that we have approximately [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few days I had some thoughts about building your project. I am using <a href="http://maven.apache.org">Apache Maven</a> for quite a while now. At my <a href="http://www.scoyo.de">current employer</a> we use Maven for all our components even our learn portal which is build entirely in <a href="http://www.adobe.com/products/flex/">Adobe Flex</a>, using the <a href="http://flexmojos.sonatype.org/">Flexmojos</a>.</p>
<p>The bottom line is that we have approximately 100 projects build with maven to build our entire platform. You don't need much imagination that we have a couple of challenges to meet.<span id="more-49"></span>I started with <a href="http://maven.apache.org/maven-1.x/index.html">Maven 1</a> which was a astonishing mixture of <a href="http://ant.apache.org/">Apache Ant</a> and <a href="http://ant.apache.org/">Jelly</a>. But I never really liked the idea of executable XML. In my opinion XML is not a good programming language at all but this would be a blog posting of its own <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Back to to the builds. A couple of days ago a read some <a href="https://twitter.com/hlship/status/5408252622">tweets</a> from the <a href="https://twitter.com/hlship">the man behind tapestry</a> to remind me about <a href="http://buildr.apache.org/">Apache Buildr</a>. This lead to rethink some experiences I made with <a href="http://maven.apache.org">Maven2</a> in the last couple of month...</p>
<p>This lead to certain discoveries what I started to really dislike on Maven2:</p>
<ol>
<li><i>The XML</i> - The <code>pom.xml</code> which defines the central project object model os getting really cluttered. When you have a small project there is almost no problem but if you have an enterprise scale project (almost evereything after an example project) the <code>pom.xml</code> is getting huge and you don't find the things you need.
<p>Okay, there are "helpers" to maintain the <code>pom.xml</code>, but e.g. if you use <a href="http://www.eclipse.org">Eclipse</a> with a POM file the XML editor starts to parse it. If the file is no very small - even a small open source project like <a href="http://jaev.googlecode.com">jaev</a> has an approx. 140 lines <code>pom.xml</code> - it'll make Eclipse somewhat slow. If you use the <a href="http://m2eclipse.sonatype.org/">m2eclipse</a> plugin it will get even worse. The <a href="http://m2eclipse.sonatype.org/">m2eclipse</a> offers some very nice tools for POM handling and it got really good compared to the early versions. But I know a couple of guys who refuse to use it because of the negative impact on your development environment.
</li>
<li><i>Reuse by inheritance</i> - The only way (so far I know <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) to reuse settings in Maven2 is POM inheritance. This works like prototypic inheritance (like in Javascript). You may define prototypic plugin settings in the parent POM and all POMs which inherit from this parent POM will use this settings as a default.
<p>So far so good, but in most object oriented programming languages inheritance to reuse code is considered to be a bad design pattern. In Maven2 you may stumble across the same bad issues as e.g. in Java when you use the POM inheritance. As a matter of fact you may only inherit from one parent POM, so your inheritance tree will get cluttered with settings and overrides.
</li>
<li><i>Insufficient version and dependency management</i> - The dependency management is one of Maven2 strongpoints, no doubt about it. But if you really start to use it you'll get to it's limits very fast.
<p>I guess Maven2 did some awesome pioneer work to version handling. Due to the fact that every artifact has a version number. Unfortunately the version numbers in Maven do not have an ordinal structure and admits special indicators like <code>SNAPSHOT</code>, <code>alpha</code> or <code>LATEST</code> which are adding a whole new level of complexity. So maven can't tell if a version is greater than another version, e.g. is <code>1.4-SNAPSHOT</code> greater than <code>1.4</code>?. This is very problematic when use version ranges and transitive dependencies. When you'll get a dependency from different sources (e.g. the commmons-lang library) there is always some magic involved which version you'll get. This leads to next next issue:
</li>
<li><i>The build does not break early enough.</i> - Maven2 tries to be very clever in some situations like the dependency resolution. If a problem occurs maybe a log message will be provided but the build will continue even if you have contradictory dependency declarations. So the only "hint" you'll get, if the dependency tree is faulty, are compile errors if you're lucky. If you have runtime dependencies you'll get some funny effects in your application
</li>
<li><i>No separation of concerns.</i> - The POM includes all concerns of a build like:
<ul>
<li>Dependency management</li>
<li>Compiling</li>
<li>Tesing</li>
<li>Packaging</li>
<li>Reporting</li>
<li>Deployment</li>
</ul>
<p>You'll have different sections in the <code>pom.xml</code> like <code>&lt;build/&gt;</code>,  <code>&lt;dependencies/&gt;</code>, <code>&lt;profiles/&gt;</code> or  <code>&lt;reporting/&gt;</code> which group the declarations a little bit. But if you take a closer look at the <code>&lt;build/&gt;</code> section you'll soon realize that it works quite different that e.g. the <code>&lt;dependencies/&gt;</code> section. In the <code>&lt;build/&gt;</code> you are more on a programming level to specify the compile and packaging issues of your build. The <code>&lt;dependencies/&gt;</code> is only declarative.</li>
<li><i>Only one file</i> - To make the lack of separation more painful you are not able to break the different concerns into separate files. There are some Maven plugins which use other files like the assembly plugin, but this an exception. It would be really nice if out could include files into your <code>pom.xml</code>. This really could have positive effects on the inheritance issue too.
</li>
</ol>
<p>Okay to straighten this a little bit. I guess the Apache Maven did some of the most innovative work on the build sector in the last few years. And I don't  consider to switch to <code>make</code> or <a href="http://ant.apache.org/">Apache Ant</a>. It makes many things a lot easier and most of my critique may be corrected in further versions <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I already had a peek into the Maven3 source code and I'll guess the Maven/<a href="http://www.sonatype.com/">Sonartype</a> guys will level some of this issues. I 'am very curious about Maven3 and I hope it will ease some of my pain related to the Version 2 of Maven.</p>
<p>So, it was great to get some thoughts clear about what is important when you build a project and what are the different facets when you use a build tool. I had a first look on <a href="http://buildr.apache.org/">Apache Buildr</a> maybe I get enough stuff together to create a blog entry about it ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/11/some-thoughts-about-building/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git-ing around</title>
		<link>http://nicl.net/2009/10/git-ing-around/</link>
		<comments>http://nicl.net/2009/10/git-ing-around/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 09:24:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=47</guid>
		<description><![CDATA[The last weeks I had some spare time to play around with the Git source control management system. My interest was aroused by a vote on the Apache Tapestry mailing list to migrate the Tapestry Subversion repository into a Git repository.
After a little more than a glimpse into the capabilities of Git I am quite [...]]]></description>
			<content:encoded><![CDATA[<p>The last weeks I had some spare time to play around with the <a href="http://www.git-scm.com">Git</a> source control management system. My interest was aroused by a vote on the <a href="http://tapestry.apache.org">Apache Tapestry</a> mailing list to migrate the <a href="http://tapestry.apache.org">Tapestry</a> <a href="http://subversion.tigris.org/">Subversion</a> repository into a <a href="http://www.git-scm.com">Git</a> repository.</p>
<p>After a little more than a glimpse into the capabilities of <a href="http://www.git-scm.com">Git</a> I am quite impressed!<span id="more-47"></span>I think I have a quite common background in source code management systems (SCM). I started with CVS at <a href="http://www.fh-wedel.de">university</a> and I really hated it. On my <a href="http://www.sinnerschrader.de">first job</a> I continued with CVS and started to value a good source code management system. </p>
<p>When you are working with a bunch of guys on a large Java/HTML project you can't work without a SCM system. CVS was a good system with some quite nice GUI clients like the <a href="http://www.eclipse.org">Eclipse</a> CVS plugin or <a href="http://www.wincvs.org">WinCVS</a>. </p>
<p>I am not quite aware when, but it was 2004-2005 I initiated a project to update the SCM infrastructure to <a href="http://subversion.tigris.org/">Subversion</a> to address some problems with CVS. If you ever created a major release tag on CVS you'll know what I mean <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
In my opinion <a href="http://subversion.tigris.org/">Subversion</a> is more than a worthy successor to CVS but it has it's own weaknesses.</p>
<p>The greatest weakness is the lack of branches and tags as an additional dimension in the SCM model. This makes at least branching with <a href="http://subversion.tigris.org/">SVN</a> not a very nice task. Tracking the changes of files through branches or tags is not that easy, because <a href="http://subversion.tigris.org/">SVN</a> simulates a branch/tag in the file structure.<br />
On my <a href="http://www.scoyo.de">current job</a> we came across some special <a href="http://subversion.tigris.org/">SVN</a> related problem. <a href="http://subversion.tigris.org/">SVN</a> uses the HTTP protocol for communication between <a href="http://subversion.tigris.org/">SVN</a> client and server. This solves al lot of network related issues, because HTTP is a well known and wide spread protocol. But creates a some new ones. So the synchronization of the working copy can some time, especially for for large binary assets and/or large projects. </p>
<p>But let me emphasize that <a href="http://subversion.tigris.org/">SVN</a> is a great SCM system with very well tool support (<a href="http://www.eclipse.org">Eclipse</a>, <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a>, etc.) and a large community. So let's stop <a href="http://subversion.tigris.org/">SVN</a> "bashing" and start with the real topic.</p>
<p><a href="http://www.git-scm.com">Git</a> is a relatively new SCM system. It was started in April 2005 by <a href="http://torvalds-family.blogspot.com">Linus Torvalds</a>. It was created due to the change in license of <a href="http://www.bitkeeper.com">Bit Keeper</a>, so that the linux kernel developers have no longer access to the SCM system.</p>
<p>The main difference between Git and SVN is, that SVN (like CVS) has a centralized model and Git has a decentralized model. What does this mean? In the SVN world you have one (central) repository which keeps track of all versions. In the Git world you have a local repository which can pull or push versioning data with other (remote) repositories. This has some fancy effects on the Git SCM system:</p>
<p>One thing that puzzled me most during my switch form CVS to SVN was the change in the version number. CVS provides for each file a version number (e.g. <code>1.1</code>, <code>1.3.4</code>, etc.) but SVN uses a version number for the whole repository (e.g. <code>47382</code>). This works only because the is one leading instance (repository). Git does not have this central instance so the Version number is a SHA1 id (e.g. <code>f4d267c9374da99c95222a95e203dab6c15a499</code>). I guess you noticed the difference too <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  But this is necessary because you cannot tell which version (number) this other guy half the way around the world created a moment ago. The version is also provided for a defined set of changes when committed. The version tracks the parent version and so you can build a version tree. This this is quite different the the linear model of SVN, where the version number is an integer.</p>
<p>Another effect of the design is, that there is more emphasis on branching and merging. So the Git provides a lost more support for this tasks. Like <code>git stash</code> which pushes the changes on the working copy into a local branch and restores the <code>HEAD</code>. This is quite nice, if you want to store your work to e.g. fix an urgent problem. Of course you can easily create a new named branch of your stashed changes. Needless to say that merging is quite easy in the Git world. Git also provides a good visualization of the different branches and commits. This makes cherry picking quite easy.</p>
<p>Since I am playing around with Git, I realized how SVN is conceptually weak in branching and merging. A <a href="http://software.thomasjacob.de">former colleague</a> mentioned this already in 2004 when the migration at my <a href="http://www.sinnerschrader.de">former employer</a> started. I think I understand him now <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Another nice feature of Git is that you can fetch versioning informations of SVN. So if you have a central SVN repository, you can push and pull version to this repository and keep track of you local work/changes in Git.</p>
<p>Last topic for this blog entry (yeah, all good things must come to an end <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) is the Git tool support. Git is a quite nice command line tool. But sometimes I am quite lazy so I want a GUI tool as well. <a href="http://www.eclipse.org">Eclipse</a> is mandatory for any competitor in the SCM game. Let me mention some real surprise: The <a href="http://www.eclipse.org/egit/">EGit</a> Eclipse plugin is the first SCM eclipse plugin (I came across) which could move and rename files and keep track of the version history!<br />
Of course there are various tools for all kind of platforms (e.g. <a href="http://gitx.frim.nl/">GitX</a>, <a href="http://code.google.com/p/tortoisegit/">TortoiseGit</a> or <a href="http://sourceforge.net/projects/qgit">qgit</a>).</p>
<p>I guess, I will keep an eye on Git  ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/10/git-ing-around/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating dynamic PDF, or another reason to like Apache Tapestry</title>
		<link>http://nicl.net/2009/08/creating-dynamic-pdf-or-another-reason-to-like-apache-tapestry/</link>
		<comments>http://nicl.net/2009/08/creating-dynamic-pdf-or-another-reason-to-like-apache-tapestry/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 20:40:29 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Tapestry]]></category>
		<category><![CDATA[The Flying Saucer Project]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=45</guid>
		<description><![CDATA[I am using Apache Tapestry 5 on my job since February of this year. Today was another of these days when I am pretty sure why it is a good idea to use this framework.
Last week we started the new sprint for the scoyo feature release which will be release on end of September. A [...]]]></description>
			<content:encoded><![CDATA[<p>I am using <a href="http://tapestry.apache.org/">Apache Tapestry 5</a> on my job since February of this year. Today was another of these days when I am pretty sure why it is a good idea to use this framework.<br />
<span id="more-45"></span>Last week we started the new sprint for the <a href="http://www-de.scoyo.com">scoyo</a> feature release which will be release on end of September. A website feature may require the dynamic creation of PDF files so I evaluated the possibilities of the <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer Project"</a>, a XML/XHTML/CSS 2.1 rendering engine.</p>
<p>I already made some experiences with the <a href="https://xhtmlrenderer.dev.java.net/">Flying Saucer</a> on another job and it is still a very nice framework for PDF creation. For me, a major advantage of <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer"</a> over other PDF creation frameworks, like XSLT and <a href="http://xmlgraphics.apache.org/fop/">FOP</a>, in the Web world is the homogenous technology mix.</p>
<p><a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer Project"</a> create PDF from XML/XHTML pages using CSS style sheets. All technologies known to the web designer that gives your web site this pretty look. I guess it's okay when you say, that XSLT and <a href="http://xmlgraphics.apache.org/fop/">FOP</a> is the more powerful technology mix, but styling pages on this technology mix is not a simple task to do.</p>
<p>So back to the initial topic: A basic ingredient which is needed to create PDFs with the <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer Project"</a> is some XHTML. In our project at <a href="http://www-de.scoyo.com">scoyo</a> we wanted to use <a href="http://tapestry.apache.org/">Apache Tapestry</a> to create this XHTML.</p>
<p>After taking a closer look to the <a href="http://tapestry.apache.org/">Apache Tapestry</a> rendering pipeline I found out, that the <code>PageResponseRenderer</code> is the perfect place to hook up the PDF creation into the rendering process. On the one hand the <code>PageResponseRenderer</code> uses a <code>MarkupWriter</code> to create the (X)HTML content from the current <code>Page</code> instance. On the other hand the <code>PageResponseRenderer</code> is responsible for writing the generated content into the server response.</p>
<p>Using the <a href="http://tapestry.apache.org/">Apache Tapestry</a> own IoC mechanism it's quite an easy task to decorate the <a href="http://tapestry.apache.org/">Tapestry</a>  <code>PageResponseRenderer</code> implementation. It's a beautiful mechanism when you understood how it works. Okay I guess using the 5.1 version of tapestry it would be better to advice the <code>renderPageResponse(...)</code> method, but I had not enough time to get familiar with it yet.</p>
<p>One real big plus on <a href="http://tapestry.apache.org/">Apache Tapestry</a> is the implementation. Every function is well encapsulated into separate services. And the service implementing classes are very short and almost always on consistent level of abstraction. So you easily understand how a service works and you are able to copy and extend the service functions. So I extended <code>PageResponseRenderer</code> to determine if a page creates XHTML output which should be transformed to PDF. If no PDF should be created my <code>PageResponseRenderer</code> simply delegates to the original Tapestry instance.</p>
<p>When the page wants to create PDF my <code>PageResponseRenderer</code> buffers the created content and redirects it into the <code>ITextRenderer</code> of the a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer". Okay this sounds more nice, than it actually is. The content is stored into a <code>ByteArrayOutputStream</code> and re-parsed by the standard JDK XML parser for further processing by the <code>ITextRenderer</code>. But I guess the we will live with the performance impact until it gets a real issue.</p>
<p>So long explanation short story. The whole thing worked out great! It took me like two to three hours to implement a first prototype. In out web application. This also includes the embedding of custom fonts into the PDF and a nice discovery of pages to render into PDF, via custom annotations using the component model meta-data facilities and a <code>ClassTransformationWorker</code>.</p>
<p>Web development can be so easy when you are using <a href="http://tapestry.apache.org/">Apache Tapestry</a>. On an earlier project we used a similar architacture with JSP and the <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer"</a>. I guess it took us ten times the effort to establish an equal infrastructure using JSF and the Java Servlet API ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/08/creating-dynamic-pdf-or-another-reason-to-like-apache-tapestry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogging in private  too &#8230;</title>
		<link>http://nicl.net/2009/08/blogging-in-private-too/</link>
		<comments>http://nicl.net/2009/08/blogging-in-private-too/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 19:23:36 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Allgemein]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=43</guid>
		<description><![CDATA[On the last weekend I had some time to migrate my private website to another blog. So this blog will be used more exclusively for technical topics. 
If you want to read more of my private thoughts, which will be written in my native tongue - german -, has to visit http://www.niclas-meier.de. See you there [...]]]></description>
			<content:encoded><![CDATA[<p>On the last weekend I had some time to migrate my private website to another blog. So this blog will be used more exclusively for technical topics. </p>
<p>If you want to read more of my private thoughts, which will be written in my native tongue - german -, has to visit <a href="http://www.niclas-meier.de">http://www.niclas-meier.de</a>. See you there <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/08/blogging-in-private-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New jaev Release</title>
		<link>http://nicl.net/2009/07/new-jaev-release/</link>
		<comments>http://nicl.net/2009/07/new-jaev-release/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 18:42:16 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tapestry]]></category>
		<category><![CDATA[google wave]]></category>
		<category><![CDATA[jaev]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=41</guid>
		<description><![CDATA[Today I made a new release of the jaev Framework for "advanced" e-mail validation. After being in productive use for quite some month now it was about time to offer a bugfix release. Some issues with domains containing no MX but an A DNS record where resolved. E-mail belonging to this kind of domains will [...]]]></description>
			<content:encoded><![CDATA[<p>Today I made a new release of the <a href="http://jaev.googlecode.com">jaev Framework</a> for "advanced" e-mail validation. After being in productive use for quite some month now it was about time to offer a bugfix release. Some issues with domains containing no MX but an A DNS record where resolved. E-mail belonging to this kind of domains will now be accepted. An issue with a file handle leak due to unclosed UDP connections during the DNS lookup was also fixed.</p>
<p>Due to the generosity of Google I got a nice <a href="http://wave.google.com/">Google wave</a> test account. Now I am looking desperately to some spare time to evaluate the integration of <a href="http://jaev.googlecode.com">jaev</a> to the <a href="http://wave.google.com/">wave</a>. One idea is to expand the validation to wave addresses via the <a href="http://www.waveprotocol.org/">wave protocol</a>. Maybe an online validation as wave bot is another exciting idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/07/new-jaev-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
