<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Unmaintainable &#187; java</title>
	<atom:link href="http://unmaintainable.wordpress.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://unmaintainable.wordpress.com</link>
	<description>Scripting, Software Engineering and Stuff in Between</description>
	<lastBuildDate>Sun, 22 Nov 2009 09:05:47 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='unmaintainable.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/6f90ae5619dfc90140df401ac60575d2?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Unmaintainable &#187; java</title>
		<link>http://unmaintainable.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://unmaintainable.wordpress.com/osd.xml" title="Unmaintainable" />
		<item>
		<title>New Project: JSysTest</title>
		<link>http://unmaintainable.wordpress.com/2009/05/23/jsystest/</link>
		<comments>http://unmaintainable.wordpress.com/2009/05/23/jsystest/#comments</comments>
		<pubDate>Sat, 23 May 2009 10:39:57 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=271</guid>
		<description><![CDATA[I love unit tests and use them whenever possible. But in the end, there&#8217;s no substitute for a full scale system test. Only after system testing, you can be sure that everything works as intended. When I was looking for a way to test a REST-style JSON web service, I decided to create a small [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=271&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I love unit tests and use them whenever possible. But in the end, there&#8217;s no substitute for a full scale system test. Only after system testing, you can be sure that everything works as intended. When I was looking for a way to test a REST-style JSON web service, I decided to create a small testing framework to simplify the task.</p>
<p><span id="more-271"></span></p>
<p>The result is the <a href="http://code.google.com/p/jsystest">JSysTest</a> framework written in Java. Using JSysTest, you can create functional web service tests based on JUnit 4 and its Hamcrest-based assertion DSL. With the help of some custom matchers, a test can look as concise as this:</p>
<pre>
  assertThat(get("/some-resource"), has(status(404)));
</pre>
<p>Have a look at the <a href="http://code.google.com/p/jsystest/">Documentation</a> for a few more examples.</p>
<p>The framework is still in its early stages of development and is likely to change. I still don&#8217;t know how to make HTTP POST and PUT methods as elegant as the GET case, but I&#8217;m sure a pattern will emerge at some point.</p>
<p>I think the most important lesson to take away from this little experiment is that you can simplify your tests significantly if you invest a bit of time for building a highly specialized DSL.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=271&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/05/23/jsystest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Collections Reaching 1.0</title>
		<link>http://unmaintainable.wordpress.com/2009/04/13/google-collections-reaching-10/</link>
		<comments>http://unmaintainable.wordpress.com/2009/04/13/google-collections-reaching-10/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 20:53:04 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[libraries]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=228</guid>
		<description><![CDATA[Exciting news for Java developers: The first 1.0 release candidate of Google Collections has been released. For almost a year I&#8217;ve been waiting for this, and now it seems the waiting will soon be over.

Basically, Google Collections is a better, more consistent version of commons-collections with generics and a few cool things that let you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=228&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Exciting news for Java developers: The first 1.0 release candidate of <a href="http://code.google.com/p/google-collections/">Google Collections</a> has been released. For almost a year I&#8217;ve been waiting for this, and now it seems the waiting will soon be over.</p>
<p><span id="more-228"></span></p>
<p>Basically, Google Collections is a better, more consistent version of <a href="http://commons.apache.org/collections/">commons-collections</a> with generics and a few cool things that let you almost use a functional style in Java (at least as far as this is possible). I think this library will quickly become a standard dependency in my Java projects.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/228/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=228&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/04/13/google-collections-reaching-10/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Simplifying Server Deployment</title>
		<link>http://unmaintainable.wordpress.com/2009/04/12/simplifying-server-deployment/</link>
		<comments>http://unmaintainable.wordpress.com/2009/04/12/simplifying-server-deployment/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 08:43:20 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=194</guid>
		<description><![CDATA[Configuring servers is tedious work if you operate a cluster of more than a few machines (if you&#8217;re a regular reader, you&#8217;ve heard about it). I&#8217;ve created a simple deployment framework that helps with building deployment packages based on central configuration templates. It is ant-based, so people from the Java world should have no problem [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=194&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Configuring servers is tedious work if you operate a cluster of more than a few machines (if you&#8217;re a regular reader, you&#8217;ve <a href="/2008/09/07/webapp-deployment/">heard about it</a>). I&#8217;ve created <a href="http://users.musicbrainz.org/~matt/misc/sdf-0.1.tar.gz">a simple deployment framework</a> that helps with building deployment packages based on central configuration templates. It is ant-based, so people from the Java world should have no problem to adjust it to their needs. Read on to find out how it works.</p>
<p><span id="more-194"></span></p>
<h4>The Server Deployment Framework (SDF)</h4>
<p>Based on a server template, a bit of configuration and your application, this little framework creates a self-contained deployment package ready for installation. The package contains both the server itself and the application, so you always start from a clean slate. There&#8217;s no cruft left between installations.</p>
<p>With SDF, there&#8217;s a separation of responsibilities between developers and admins. Developers provide the application in a <cite>.war</cite> file. The <cite>.war</cite> file has no environment-specific configuration. Admins are responsible for configuring the application for the target environment. The general ideas is that the same application artifact that is handed to the QA department is also installed on the production systems.</p>
<p>This is how it works:</p>
<ol>
<li>Create a server template in the <cite>src</cite> directory. Replace important configuration values with wildcards. Rename all files containing wildcards to filename.in (think autoconf).</li>
<li>Place your web applications in the base directory&#8217;s <cite>webapps</cite> directory.</li>
<li>Create/edit the environment configuration in the <cite>conf</cite> directory, ie. <cite>ENV-NAME.properties</cite>.</li>
<li>Run <cite>ant package -Dapp.environment=ENV-NAME</cite>.</li>
<li>You&#8217;ll find your pre-configured deployment package in the target directory.</li>
</ol>
<p>Repeat steps 2-5 any time you want to make a new release.</p>
<h4>The Bundled Tomcat</h4>
<p>A few words on the bundled Tomcat instance: It is for illustration only and hasn&#8217;t been configured for production use. There are a couple of interesting ideas though.</p>
<p>All ports settings have a &#64;PORT_PREFIX&#64; wildcard. That way you can run multiple Tomcat instances on one host by changing the prefix parameter. This is useful for rollouts: You can start up and check the new revision while the old one is still running. Using loadbalancer settings, you can switch over to the new application and later shut down the old revision.</p>
<p>In <cite>conf/context.xml</cite>, an example context parameter has been set. This is a simple way of passing environment-specific parameters to your application without having to change anything inside the <cite>.war</cite> file.</p>
<p>As a general rule, it&#8217;s a good idea to run just one web application per Tomcat instance. This way, it&#8217;s easier to figure out which application is misbehaving. In large operations with high performance requirements, this is the normal case anyway. When you follow the single application rule, you can as well turn off hot deployment.</p>
<p>Since applications tend to crash sometimes (OutOfMemory exceptions happen to the best of us), it makes sense to restart the server automatically without admin intervention. One easy solution to do this is to run Tomcat inside a JavaServiceWrapper that makes sure your JVM is in a healthy state. Remote restarts and easy JMX access are helpful additional features.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=194&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/04/12/simplifying-server-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>The State of Java Build Systems</title>
		<link>http://unmaintainable.wordpress.com/2008/08/02/java-build-systems/</link>
		<comments>http://unmaintainable.wordpress.com/2008/08/02/java-build-systems/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 09:29:43 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[build systems]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[opinion]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=76</guid>
		<description><![CDATA[Most people eventually get it that building release artifacts using their IDEs is not the way to nirvana. Builds have to stay stable and reproducible between IDE revisions, and being able to execute them in a command line environment or especially continuous integration servers is key to agile development.
Fortunately, there are open source build tools [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=76&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Most people eventually get it that building release artifacts using their IDEs is <strong>not</strong> the way to nirvana. Builds have to stay stable and reproducible between IDE revisions, and being able to execute them in a command line environment or especially continuous integration servers is key to agile development.</p>
<p>Fortunately, there are open source build tools for Java. Less fortunately, they&#8217;re not quite perfect. Let&#8217;s see what we&#8217;ve got.</p>
<p><span id="more-76"></span></p>
<h4>The Sorry State of Affairs</h4>
<p>There&#8217;s <a href="http://ant.apache.org/">Ant</a>, the undying classic, but pretty much in maintenance mode, I understand. Ant-based build systems usually start small and innocent but quickly turn into a tangled mess. Every Ant script is a unique piece of modern art that has to be deciphered on its own. They are the cockroaches of Java development, and I guess we&#8217;ll have to deal with them again in 30 years when we&#8217;ll be porting ancient Java applications to the next big platform.</p>
<p><a href="http://maven.apache.org/">Maven 2</a> promises relief and introduces convention over configuration, dependency management, lifecycle support and a few other things that aren&#8217;t strictly relevant for a build system. Great concepts, but the actual implementation makes you want to cry. The state of documentation is poor, the XML syntax is unnecessarily bulky, and trivial one-off tasks aren&#8217;t possible without a proper plugin (go and write one if you&#8217;re feeling brave). Not to mention that stunts like multi-module projects are necessary to build a simple EAR file. And no, Eclipse doesn&#8217;t like them either.</p>
<p>Despite all its shortcomings, a lot of people including me tried hard to love Maven, but it&#8217;s not easy.</p>
<h4>The Winds of Change</h4>
<p>Where does that leave us?</p>
<p>I don&#8217;t have much hope for Ant. It is what it is and lacks too many things a build system needs, most importantly built-in conventions and higher level abstractions. Granted, there&#8217;s <a href="http://ant.apache.org/ivy/">Ivy</a>, a pretty nice dependency manager that adds a couple of interesting features, but that&#8217;s about it (Ivy looks heavily inspired by Maven, but it&#8217;s funny how they changed all the terminology).</p>
<p>Maven 2&#8217;s future looks a little bit brighter since it seems the project is opening up to common sense, which maybe be a direct effect of recent discussions and probably Don Brown&#8217;s patches. For example, the XML syntax in 2.1.0 will be much more concise and there are fixed default plugin versions in 2.0.9 so that it&#8217;s easier to have reproducible builds. Unfortunately, the public repository is a swamp of misplaced software and crappy metadata, so there may be no alternative to setting up a local repository.</p>
<p>At the moment, I&#8217;m taking a closer look at <a href="http://incubator.apache.org/buildr/">Buildr</a>, a ruby-based build system for Java that&#8217;s currently under incubation at the <a href="http://apache.org">ASF</a>. Apparently they&#8217;re creating a better Maven, taking the proven concepts but none of its implementation. The jury&#8217;s still out on whether the average coder will be able to create effective, maintainable build scripts, but we&#8217;ll see. Having to learn Ruby may be a problem to some and an incentive to others.</p>
<h4>So?</h4>
<p>Poor build systems and development environments in general are a barrier for new project members and a frequent cause for frustration. I&#8217;ve worked on projects where all you had to do was to check something out from Subversion, type &quot;mvn package&quot; and you were ready to go. For other projects (both commercial and open source!) you needed a specialist&#8217;s support, a couple of days time and a lot of hand-holding to actually build the product and run it locally.</p>
<p>Unfortunately, only few development shops realize that a decent development environment is an asset and invest in their build infrastructure. A good project setup takes time, and if there&#8217;s no time or budget available, your build tool of choice won&#8217;t do any wonders on its own.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/76/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/76/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=76&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2008/08/02/java-build-systems/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Generating DDL Scripts from JPA Annotations with Maven</title>
		<link>http://unmaintainable.wordpress.com/2008/04/12/hibernate3-schema-creation/</link>
		<comments>http://unmaintainable.wordpress.com/2008/04/12/hibernate3-schema-creation/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 09:48:43 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[build systems]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=51</guid>
		<description><![CDATA[A while ago I posted an article that showed how to generate a database schema from JPA annotations. Since I didn&#8217;t get the hibernate3 maven plugin working back then I used the antrun plugin as a workaround. Thanks to the help of a reader the plugin works now, so an update is in order.

[Update 2009-06-01: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=51&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A while ago I <a href="http://unmaintainable.wordpress.com/2007/06/30/generating-ddl-scripts-with-maven/">posted an article</a> that showed how to generate a database schema from JPA annotations. Since I didn&#8217;t get the <a href="http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/">hibernate3 maven plugin</a> working back then I used the <a href="http://maven.apache.org/plugins/maven-antrun-plugin/">antrun plugin</a> as a workaround. Thanks to the help of a reader the plugin works now, so an update is in order.</p>
<p><span id="more-51"></span></p>
<p>[<strong>Update 2009-06-01:</strong> The plugin is now available in version 2.2 from the central maven repository, so I removed the plugin repository configuration. I also switched from annotationconfiguration to jpaconfiguration.]</p>
<p>Since the last article the scenario hasn&#8217;t changed: I want to generate DDL scripts for creating a database schema from JPA annotations. The created schema can then be tweaked as necessary and used in the production environment. Like the old antrun solution, the maven plugin uses the ant task from <a href="http://www.hibernate.org/255.html">Hibernate Tools</a>, so the resulting schema is the same.</p>
<p>This is how it works. Edit your <code>pom.xml</code> and add the plugin configuration:</p>
<pre>
&lt;build&gt;
  &lt;plugins&gt;
    &lt;!-- other plugins ... --&gt;
    &lt;plugin&gt;
      &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate3-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.2&lt;/version&gt;
      &lt;executions&gt;
        &lt;execution&gt;
          &lt;phase&gt;process-classes&lt;/phase&gt;
          &lt;goals&gt;
            &lt;goal&gt;hbm2ddl&lt;/goal&gt;
          &lt;/goals&gt;
        &lt;/execution&gt;
      &lt;/executions&gt;
      &lt;configuration&gt;
        &lt;components&gt;
          &lt;component&gt;
            &lt;name&gt;hbm2ddl&lt;/name&gt;
            &lt;implementation&gt;jpaconfiguration&lt;/implementation&gt;
          &lt;/component&gt;
        &lt;/components&gt;
        &lt;componentProperties&gt;
          &lt;persistenceunit&gt;Default&lt;/persistenceunit&gt;
          &lt;outputfilename&gt;schema.ddl&lt;/outputfilename&gt;
          &lt;drop&gt;false&lt;/drop&gt;
          &lt;create&gt;true&lt;/create&gt;
          &lt;export&gt;false&lt;/export&gt;
          &lt;format&gt;true&lt;/format&gt;
        &lt;/componentProperties&gt;
      &lt;/configuration&gt;
    &lt;/plugin&gt;
  &lt;plugins&gt;
&lt;/build&gt;
</pre>
<p>Don&#8217;t forget to set the persistence unit to whatever you declared in <code>persistence.xml</code>.</p>
<p>Schema creation is executed in the <code>process-classes</code> phase, so you&#8217;ll find the schema in <code>target/hibernate3/sql/schema.ddl</code> after running <code>mvn package</code> (or any later phase). An alternative is to remove the <code>&lt;executions&gt;</code> element and to run the hbm2ddl goal from the command line:</p>
<pre>
  mvn hibernate3:hbm2ddl
</pre>
<p>The plugin offers a lot more than just schema creation. See the <a href="http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/">plugin documentation</a> for more information.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=51&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2008/04/12/hibernate3-schema-creation/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Using GridGain&#8217;s Topology SPI</title>
		<link>http://unmaintainable.wordpress.com/2008/01/26/gridgain-topology-spi/</link>
		<comments>http://unmaintainable.wordpress.com/2008/01/26/gridgain-topology-spi/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 09:01:06 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[libraries]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=41</guid>
		<description><![CDATA[On a GridGain cluster, you sometimes want to execute your jobs on only a subset of the nodes available: those nodes meeting a given condition. Let&#8217;s say some nodes run an expensive piece of thirdparty software that is (fortunately) only needed for a couple of tasks. At another time, the jobs should be executed on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=41&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>On a <a href="http://www.gridgain.com">GridGain</a> cluster, you sometimes want to execute your jobs on only a subset of the nodes available: those nodes meeting a given condition. Let&#8217;s say some nodes run an expensive piece of thirdparty software that is (fortunately) only needed for a couple of tasks. At another time, the jobs should be executed on a different subset, or maybe on all nodes of the cluster. </p>
<p><span id="more-41"></span></p>
<p>There are several ways to do this: Filtering out nodes in your <a href="http://gridgain.com/javadoc/org/gridgain/grid/GridTask.html#map(java.util.List,%20T)">map()</a> method would work, but you usually don&#8217;t want that if you&#8217;re using <a href="http://gridgain.com/javadoc/org/gridgain/grid/GridTaskSplitAdapter.html#split(int,%20T)">split()</a> already. Or you could put the nodes on different multicast groups, thus filtering via <a href="http://gridgain.com/javadoc/org/gridgain/grid/spi/discovery/GridDiscoverySpi.html">DiscoverySpi</a>. In that case it&#8217;s more difficult to run a task&#8217;s job on all nodes: You can no longer use the default discovery service provider; you&#8217;d have to pick a different one or even implement your own.</p>
<p>Luckily, there&#8217;s the <a href="http://gridgain.com/javadoc/org/gridgain/grid/spi/topology/GridTopologySpi.html">TopologySpi</a>. It is used by the framework to filter the set of nodes returned by discovery. Any strategy for filtering can be implemented, providing a perfect hook for a criteria based filter. For example, the service provider shipped with GridGain, <a href="http://gridgain.com/javadoc/org/gridgain/grid/spi/topology/basic/GridBasicTopologySpi.html">GridBasicTopologySpi</a>, makes it possible to execute jobs only on the local node or only on remote nodes.</p>
<p>To solve the problem described above, I developed a simple group concept based on user attributes that can be assigned to each grid node in its configuration. A node may be part of one or more groups. This is added to the configuration file of the worker grid nodes like this:</p>
<pre>
  &lt;property name="userAttributes"&gt;
    &lt;map&gt;
      &lt;entry key="grid.groups"&gt;
        &lt;set&gt;
          &lt;value&gt;foo&lt;/value&gt;
          &lt;value&gt;bar&lt;/value&gt;
        &lt;/set&gt;
      &lt;/entry&gt;
    &lt;/map&gt;
  &lt;/property&gt;
</pre>
<p>A custom topology provider is used on the node where my tasks are deployed. It&#8217;s derived from <a href="http://gridgain.com/javadoc/org/gridgain/grid/spi/topology/basic/GridBasicTopologySpi.html">GridBasicTopologySpi</a>, but you can also specify which groups a node has to be part of to qualify for the task. The provider is called <code>GroupTopologySpi</code> (the &#8220;i&#8221; is used consistently in GridGain, although it&#8217;s counter-intuitive) and is activated in the master&#8217;s configuration:</p>
<pre>
  &lt;property name="topologySpi"&gt;
    &lt;bean class="de.mafr.grid.GroupTopologySpi"&gt;
      &lt;property name="localNode" value="true"/&gt;
      &lt;property name="remoteNodes" value="true"/&gt;
      &lt;property name="requiredGroups"&gt;
        &lt;set&gt;
          &lt;value&gt;foo&lt;/value&gt;
        &lt;/set&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  &lt;/property&gt;
</pre>
<p>If the <code>requiredGroups</code> property isn&#8217;t given or if it contains the empty set, the service provider works exactly the same as <a href="http://gridgain.com/javadoc/org/gridgain/grid/spi/topology/basic/GridBasicTopologySpi.html">GridBasicTopologySpi</a>, so it can be used as a drop-in replacement. In the example only grid nodes in the group <code>foo</code> will take part in the task.</p>
<p>The implementation is simple and consists of one short class and an interface: The actual topology provider, <a href="http://users.musicbrainz.org/~matt/code/gridgain/GroupTopologySpi.java">GroupTopologySpi</a>, and the <a href="http://users.musicbrainz.org/~matt/code/gridgain/GroupTopologySpiMBean">MBean interface</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=41&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2008/01/26/gridgain-topology-spi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>A Quick Look at GridGain</title>
		<link>http://unmaintainable.wordpress.com/2007/11/18/a-quick-look-at-gridgain/</link>
		<comments>http://unmaintainable.wordpress.com/2007/11/18/a-quick-look-at-gridgain/#comments</comments>
		<pubDate>Sun, 18 Nov 2007 19:07:38 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[opinion]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/2007/11/18/a-quick-look-at-gridgain/</guid>
		<description><![CDATA[This weekend I finally had the time to take a look at GridGain, a computational grid package written in and for Java. GridGain is a an open source product licensed under LGPL-2.1 (the same as JBoss) with minor portions under the Apache 2.0 license, so use in commercial products is possible. Since we&#8217;re doing medium-sized [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=36&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This weekend I finally had the time to take a look at <a href="http://www.gridgain.com">GridGain</a>, a computational grid package written in and for Java. GridGain is a an open source product licensed under LGPL-2.1 (the same as JBoss) with minor portions under the Apache 2.0 license, so use in commercial products is possible. Since we&#8217;re doing medium-sized number crunching at work, I definitely wanted to give it a try. The following article is no in-depth evaluation but rather a first impression after a few days of reading and experimenting with version 1.6.1.</p>
<p><span id="more-36"></span></p>
<p>Like I said, GridGain is a computational grid, which means it focuses on the computational part. Getting meta data (job input parameters etc.) to your workers is easily possible, of course, but transfer of large amounts of input data is entirely up the user. GridGain is no data grid, but it provides optional integration with <a href="http://www.oracle.com/technology/products/coherence/index.html">Oracle Coherence</a>, a commercial, closed source data grid and caching package.</p>
<p>The programming paradigm behind GridGain is <a href="http://labs.google.com/papers/mapreduce.html">Map/Reduce</a>, a divide and conquer approach which has been made popular by Google. The underlying idea is a simple one: Split your problem into smaller parts and execute them in parallel on network nodes (the <em>map</em> part). When the nodes are done, aggregate the individual results to obtain the final result (<em>reduce</em>). If you&#8217;re able to express your problem in terms of map and reduce operations, you can scale out to many nodes and solve large problems.</p>
<p>GridGain is a pretty young product, so there isn&#8217;t much to be found about it on the web. That leaves the <a href="http://216.93.179.140:8080/wiki/display/GG15UG/">official documentation</a> (and the source code) as the only sources of information. Fortunately, the documentation (<a href="http://gridgain.com/javadoc/index.html">Javadoc</a> and the <a href="http://216.93.179.140:8080/wiki/display/GG15UG/">read-only wiki</a>) is in a good state already and gets you up to speed quickly.</p>
<p>In retrospect, I spent too much time reading the wiki documentation though. It&#8217;s excellent to get a basic grasp of GridGain&#8217;s concepts and features, but there&#8217;s no substitute for actually writing a simple application yourself. As soon as I did that, a lot of things suddenly cleared up and and I gained much more confidence. I quickly implemented a <code>GridTask</code> (containing the <code>map</code> and <code>reduce</code> functionality) and a <code>GridJob</code> (containing the actual processing logic) and distributed it to nodes on the local network. I even added an MBean for monitoring the entire task just because it was so simple to do. The comprehensive API documentation helped a lot in the process.</p>
<p>To make things easier for new users, I think it would help to restructure the tutorials a bit. In my opinion, the @Gridify annotation (a way to <em>grid-enable</em> a method) is a bit too magic for a beginner in his or her first two hours with GridGain, as it stands in the way of understanding the basics: The simple and elegant GridTask and GridJob abstractions. I&#8217;d also move the anonymous GridJob implementations out of the GridTask in the examples. That would make the code easier to read and understand.</p>
<p>From what I&#8217;ve seen, GridGain&#8217;s source code is clean and well-written. The authors obviously have a great deal of design experience which results in a modular, flexible system. Like many applications using the <a href="http://springframework.org/">Spring Framework</a>, GridGain is made up of several services implementing service provider interfaces (<em>SPIs</em>). For example, finding grid nodes on a network is done using a discovery service, which implements the <em>DiscoverySpi</em> interface. The default is a multicast-based discovery (with lots of other implementations available), but users could create their own service easily. It is possible to configure many aspects of the provided services or use your own services to change policies. For the start, I didn&#8217;t have to do that, however, since things generally worked out of the box.</p>
<p>Over the next few months it will be quite interesting to see if GridGain is able to build a community around their software. A great step towards this is the <a href="http://www.gridgainsystems.com/jiveforums/index.jspa">public online forum</a>. Employees from GridGain Systems (the company behind GridGain) answer questions in a polite and helpful manner. The forum has a good search function, which proved to be very useful when I had questions.</p>
<p>Personally, I&#8217;m also interested in a public maven proxy &#8211; something many users would benefit from &#8211; and also a public source code repository. I know that companies are often hesitant to go this far, but it has proven to be a great asset to open source projects, since it allows advanced users to track the project&#8217;s progress in detail. I&#8217;d also appreciate build instructions (from what I&#8217;ve seen, the build system isn&#8217;t shipped in version 1.6.1), in case I&#8217;d have to do emergency bug fixes to GridGain. Experience shows that things like that are necessary in any software product from time to time.</p>
<p>To sum things up, my overall impression is a very positive one: The package is really a lot of fun to work with, as the website promised. I think everybody who considers doing serious number crunching on the Java platform should take the time to evaluate GridGain.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/36/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/36/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=36&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2007/11/18/a-quick-look-at-gridgain/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Easing Configuration with Spring Beans</title>
		<link>http://unmaintainable.wordpress.com/2007/11/01/configuration-with-spring-beans/</link>
		<comments>http://unmaintainable.wordpress.com/2007/11/01/configuration-with-spring-beans/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 16:06:14 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[libraries]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/2007/11/01/configuration-with-spring-beans/</guid>
		<description><![CDATA[Handling configuration data in Java isn&#8217;t as convenient as it could be. The old and popular Properties mechanism has an awkward syntax and you have to take care of type safety yourself. The new Preferences mechanism supports XML but still isn&#8217;t everything I&#8217;d like it to be.
Recently, I discovered an alternative while playing with GridGain: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=33&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Handling configuration data in Java isn&#8217;t as convenient as it could be. The old and popular <a href="http://java.sun.com/javase/6/docs/api/java/util/Properties.html">Properties</a> mechanism has an <a href="http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)">awkward syntax</a> and you have to take care of type safety yourself. The new <a href="http://java.sun.com/javase/6/docs/api/java/util/prefs/Preferences.html">Preferences</a> mechanism supports XML but still isn&#8217;t everything I&#8217;d like it to be.</p>
<p>Recently, I discovered an alternative while playing with <a href="http://gridgain.com">GridGain</a>: <a href="http://www.springframework.org/">Spring</a> Beans. Despite all the hype over the last years I&#8217;ve never worked with Spring before, so I had some catch-up to do. Spring provides &#8211; among many other things &#8211; an Inversion of Control (IoC) container, similar in style to packages like <a href="http://www.picocontainer.org/">PicoContainer</a>/<a href="http://www.nanocontainer.org/">NanoContainer</a> or <a href="http://hivemind.apache.org/">Hivemind</a>. The main service of these containers is Dependency Injection, a non-intrusive way of obtaining dependencies for objects (data sources are a popular example). In this article, I&#8217;m focusing on Spring and the configuration aspect.</p>
<p><span id="more-33"></span></p>
<p>Spring provides a simple XML format that we can use for configuration files:</p>
<pre>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt;

  &lt;bean id="config" class="de.mafr.demo.Config"&gt;
    &lt;property name="hostname" value="mafr.de"/&gt;
    &lt;property name="port" value="8080"/&gt;
  &lt;/bean&gt;

&lt;/beans&gt;
</pre>
<p>In the example, we declare a Java Bean (<code>de.mafr.demo.Config</code>) and assign values to its properties. The <code>Config</code> bean is a POJO that follows the Java Bean conventions and isn&#8217;t tied to Spring in any way. Here it is:</p>
<pre>
package de.mafr.demo;

public class Config {
	private String hostname;
	private short port;

	public String getHostname() {
		return hostname;
	}

	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	public short getPort() {
		return port;
	}

	public void setPort(short port) {
		this.port = port;
	}
}
</pre>
<p>Note that type conversion is done by the container: The <code>port</code> value is converted to int automatically. This works for all base types and for a few other classes like URL.</p>
<p>Now let&#8217;s actually read the configuration file and obtain a ready to use <code>Config</code> object:</p>
<pre>
package de.mafr.demo;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class Main {
    public static void main(String[] args) {
    	BeanFactory factory = new XmlBeanFactory(
    			new FileSystemResource("config.xml"));

    	Config config = (Config) factory.getBean("config", Config.class);

        // use config
    }
}
</pre>
<p>If there&#8217;s an error, you are notified immediately by an exception from the constructor. The configuration file can be read from disk directly like in the example above (using <code>FileSystemResource</code>), from the classpath (<code>ClassPathResource</code>), a servlet context (<code>ServletContextResource)</code>, from a URL (<code>UrlResource</code>), or other sources.</p>
<p>To get the example up and running, a subset of Spring and a few dependencies are required. If you&#8217;re using <a href="http://maven.apache.org">Maven</a>, all you have to do is to add the following dependency to your <code>pom.xml</code>:</p>
<pre>
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
      &lt;version&gt;2.0.7&lt;/version&gt;
    &lt;/dependency&gt;
</pre>
<p>A lot more is possible with Spring Beans. See <a href="http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-lifecycle">the official reference manual</a> for all the details.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=33&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2007/11/01/configuration-with-spring-beans/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Minimal Enterprise Application with Maven</title>
		<link>http://unmaintainable.wordpress.com/2007/07/29/minimal-enterprise-app-maven/</link>
		<comments>http://unmaintainable.wordpress.com/2007/07/29/minimal-enterprise-app-maven/#comments</comments>
		<pubDate>Sun, 29 Jul 2007 07:39:07 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[build systems]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/2007/07/29/minimal-enterprise-app-maven/</guid>
		<description><![CDATA[Setting up a Java EE application is no trivial task. Dependency management, building, and deployment can get pretty complex and require a thorough understanding of deployment descriptors, jars, ears and other artifacts.
In this article, I&#8217;m going to present a truly minimal maven-based setup for the JBoss Application Server (tested with jboss-4.0.5.GA), providing a solid base [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=22&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Setting up a Java EE application is no trivial task. Dependency management, building, and deployment can get pretty complex and require a thorough understanding of deployment descriptors, jars, ears and other artifacts.</p>
<p>In this article, I&#8217;m going to present a truly minimal maven-based setup for the JBoss Application Server (tested with jboss-4.0.5.GA), providing a solid base for further work. The project is an EJB3 demo application which uses JPA to access a database and makes the data available via a remote session bean interface. The application will be deployed in an <code>ear</code> file which contains the required dependencies (unless they are already provided by JBoss).</p>
<p><span id="more-22"></span></p>
<p>First of all, <a href="http://musicbrainz.org/~matt/misc/EnterpriseApp-simple-0.2.tar.gz">download the application</a> and extract it. In the root directory, there&#8217;s a <code>pom.xml</code> file (the POM) which defines the top-level project. Each of the subdirectories (<code>ear</code>, <code>ejb</code>, and <code>client</code>) is a maven project itself with a <code>pom.xml</code> on its own. Apart from some basic values, the top-level POM specifies its <em>sub-modules</em> and gives a list of dependencies for the project. The dependency list is just a declaration, its purpose is to let the other POMs reference dependencies without having to specify the version number.</p>
<p>The <code>ejb</code> module is the heart of the application. It contains the server side source code, which is the data source layer  (DAOs), JPA Entities, and a remote facade (in this case: a stateless session bean). The <code>ejb</code> module creates two jar files: One containing all the code, and the other one with all the interfaces and data transfer objects relevant for remote clients (the <em>client-jar</em>).</p>
<p>The <code>ear</code> module contains no source code, its purpose is to configure the deployment descriptor (<code>application.xml</code>) and to package the <code>ejb</code> module&#8217;s jar file and all the dependencies into a single <code>ear</code> file, ready for deployment into the jboss application server. You&#8217;ll find the created file in <code>ear/target</code>.</p>
<p>The <code>client</code> module implements a simple client application which accesses the server via its remote facade. It can be run from the command line or from within eclipse.</p>
<p>To build the project, run <code>mvn install</code> from the command line. If you want to import the project into eclipse, execute <code>mvn eclipse:eclipse</code> to generate the required <code>.project</code> and <code>.classpath</code> files. From within the IDE, choose <em>File/Import</em>, <em>General/Existing Projects into Workspace</em>, browse to the project&#8217;s base directory and hit <em>Finish</em>.</p>
<p><strong>Update</strong>: I updated the demo application to version 0.2. The new version removes an unused import script that caused confusion and the documentation notes where the JBoss dependencies are coming from.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=22&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2007/07/29/minimal-enterprise-app-maven/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Using the Maven Source Plugin</title>
		<link>http://unmaintainable.wordpress.com/2007/07/01/using-the-maven-source-plugin/</link>
		<comments>http://unmaintainable.wordpress.com/2007/07/01/using-the-maven-source-plugin/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 07:57:22 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[build systems]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/2007/07/01/using-the-maven-source-plugin/</guid>
		<description><![CDATA[When using an ordinary jar library, IDEs like Eclipse&#8217;s JDE don&#8217;t have enough information to display inline javadocs for referenced classes. You have to manually direct Eclipse to the library&#8217;s source code to take advantage of inline documentation. Maven&#8217;s source plugin provides a convenient solution to this problem. When building the library, the plugin creates [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=25&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When using an ordinary jar library, IDEs like Eclipse&#8217;s JDE don&#8217;t have enough information to display inline javadocs for referenced classes. You have to manually direct Eclipse to the library&#8217;s source code to take advantage of inline documentation. Maven&#8217;s <a href="http://maven.apache.org/plugins/maven-source-plugin/">source plugin</a> provides a convenient solution to this problem. When building the library, the plugin creates a source jar containing the package&#8217;s source code. This source package can be installed or deployed into your repository. Maven&#8217;s <a href="http://maven.apache.org/plugins/maven-eclipse-plugin/">eclipse plugin</a> then adds the source package to the generated <code>.classpath</code> file.</p>
<p><span id="more-25"></span></p>
<p>This is how it works. Before installing or deploying your library, run the source plugin:</p>
<pre>
  mvn source:jar
</pre>
<p>Your next <code>install</code> or <code>deploy</code> call will take care of the rest. In the dependent project (the one using your library), run the eclipse plugin:</p>
<pre>
  mvn eclipse:eclipse
</pre>
<p>After refreshing the project in eclipse, you should now have access to inline documentation.</p>
<p>If you don&#8217;t want to run <code>source:jar</code> each time, you can attach the call to the build lifecycle&#8217;s <code>package</code> phase:</p>
<pre>
  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;phase&gt;package&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;jar&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
</pre>
<p>After running <code>mvn package</code>, there should be a source package in your <code>target</code> directory.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/unmaintainable.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/unmaintainable.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=25&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2007/07/01/using-the-maven-source-plugin/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
	</channel>
</rss>