<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Jayway Team Blog » Tools</title>
	
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<pubDate>Wed, 18 Mar 2009 10:13:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/jayway/posts/tools" /><feedburner:info uri="jayway/posts/tools" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Executable .jar, with onejar-maven-plugin</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/A8US80mAFeQ/</link>
		<comments>http://blog.jayway.com/2009/03/14/executable-jar-with-onejar-maven-plugin/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 16:25:10 +0000</pubDate>
		<dc:creator>Hugo Josefson</dc:creator>
		
		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[assembly]]></category>

		<category><![CDATA[executable]]></category>

		<category><![CDATA[jar]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[maven]]></category>

		<category><![CDATA[onejar]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=972</guid>
		<description><![CDATA[<a href="http://onejar-maven-plugin.googlecode.com/">Onejar-maven-plugin</a> collects your application including dependencies, into one executable jar. It's both easy and works well!

It lets all your dependency jars stay jars, and your code is in its own jar. All of those jars are put in a bigger jar, which is made executable.

<h4>Configuration</h4>
It may sound weird, but it's quite elegant! Just put this in your <code>pom.xml</code>'s <code>&#60;plugins&#62;</code> tag to make it work:...]]></description>
			<content:encoded><![CDATA[<p><a href="http://onejar-maven-plugin.googlecode.com/">Onejar-maven-plugin</a> collects your application including dependencies, into one executable jar. It's both easy and works well!</p>
<h3>Problem</h3>
<p>If you have ever tried doing this before with Maven, you have probably used <a href="http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies">maven-assembly-plugin</a>, which would leave the door open for classpath problems!</p>
<p>It would extract all your dependency jars in one directory together with all your class files and all other classpath resources. The problem is that everything ended up in a big mix, with classpath resources possibly overwriting each other. For example, if two dependencies each had a <code>log4j.properties</code> file in their jar, one <code>log4j.properties</code> would overwrite the other.</p>
<p>No more of that mess!</p>
<h3>Solution</h3>
<p>Enter maven-onejar-plugin. It lets all your dependency jars stay jars, and your code is in its own jar. All of those jars are put in a bigger jar, which is made executable.</p>
<h4>Configuration</h4>
<p>It may sound weird, but it's quite elegant! Just put this in your <code>pom.xml</code>'s <code>&lt;plugins&gt;</code> tag to make it work:</p>
<pre>&lt;plugin&gt;
  &lt;groupId&gt;org.dstovall&lt;/groupId&gt;
  &lt;artifactId&gt;onejar-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;1.2.3&lt;/version&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;configuration&gt;
        &lt;mainClass&gt;your.package.YourMainClass&lt;/mainClass&gt;
      &lt;/configuration&gt;
      &lt;goals&gt;
        &lt;goal&gt;one-jar&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;</pre>
<p>You also need to add this to the pom:</p>
<pre>&lt;pluginRepositories&gt;
  &lt;pluginRepository&gt;
    &lt;id&gt;onejar-maven-plugin.googlecode.com&lt;/id&gt;
    &lt;url&gt;http://onejar-maven-plugin.googlecode.com/svn/mavenrepo&lt;/url&gt;
  &lt;/pluginRepository&gt;
&lt;/pluginRepositories&gt;</pre>
<p><em>Please note the new Maven repository URL. Me and onejar-maven-plugin founder Drew Stovall just recently moved the project to Google Code to make it more open and easier for others (like me!) to pitch in. Yesterday, I released version 1.2.3 of onejar-maven-plugin to our new Maven repo at Google Code. Make sure you get the <code>&lt;pluginRepository&gt;</code> URL right so that the latest version will be available to you!</em></p>
<h4>Use</h4>
<p>Then do this to build everything:</p>
<pre>mvn install</pre>
<p>That will build both your normal jar, as well as another jar. You will get these:</p>
<div id="attachment_1152" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.jayway.com/wp-content/uploads/2009/03/onejar-maven-plugin-screenshot.png"><img src="http://blog.jayway.com/wp-content/uploads/2009/03/onejar-maven-plugin-screenshot-300x150.png" alt="Standalone one-jar.jar file, along with the original .jar file." title="onejar-maven-plugin-screenshot" width="300" height="150" class="size-medium wp-image-1152" /></a><p class="wp-caption-text">Standalone one-jar.jar file, along with the original .jar file.</p></div>
<p><code>myApp.one-jar.jar</code> is the big executable that includes both <code>myApp.jar</code>, and all dependency jars.</p>
<p>You can run it standalone without any extra files, like this:</p>
<pre>java -jar target/myApp.one-jar.jar</pre>
<p><em>If you found this interesting, you might find <a href="/2008/11/28/executable-war-with-winstone-maven-plugin/">my post about winstone-maven-plugin</a> enlightning as well. It shows you how to make an executable .war file.</em></p>
<h4>Credits</h4>
<p>Thank you <a href="http://dstovall.com/">Drew Stovall</a> for creating this Maven plugin in the first place, and thank you to the <a href="http://onejar-maven-plugin.googlecode.com/svn/mavensite/history.html">other contributors</a> who have also submitted patches.</p>
<p>Project homepage: <a href="http://onejar-maven-plugin.googlecode.com/">http://onejar-maven-plugin.googlecode.com</a></p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/A8US80mAFeQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/03/14/executable-jar-with-onejar-maven-plugin/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2009/03/14/executable-jar-with-onejar-maven-plugin/</feedburner:origLink></item>
		<item>
		<title>Mavenizing the Liferay Plugin SDK</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/e0p8BaaCxUQ/</link>
		<comments>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 08:58:00 +0000</pubDate>
		<dc:creator>Henrik Bernström</dc:creator>
		
		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Usability]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[archetype]]></category>

		<category><![CDATA[artifact]]></category>

		<category><![CDATA[liferay]]></category>

		<category><![CDATA[maven2]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[portlet]]></category>

		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1094</guid>
		<description><![CDATA[Liferay is the leading Open Source enterprise portal platform in the Java market. It's certainly an impressive piece of software. I've been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability.
One area that, in my opinion, could still be improved is [...]]]></description>
			<content:encoded><![CDATA[<p>Liferay is the leading Open Source enterprise portal platform in the Java market. It's certainly an impressive piece of software. I've been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability.</p>
<p>One area that, in my opinion, could still be improved is the development environment. It may be a heck of a good build system <a href="http://www.liferay.com">Liferay</a> has come up with, but at the bottom line it takes time to learn it and to just start studying it you easily become a bit uncertain. It consists of homegrown ant scripts. To have a flatter learning curve for newcomers <a href="http://maven.apache.org/">Maven 2</a> might be suitable.</p>
<p>Anyway, I sat down one evening some time ago and looked into how Maven 2 could be used for creating Jsp Portlets for Liferay. Some hours later the work had resulted in a new archetype for creating Liferay Jsp Portlets. </p>
<p><a href="http://svn.liferay.com/browse/plugins/trunk/tools/portlet_tmpl">The structure and content of the standard Liferay Jsp Portlet can be viewed here.</a></p>
<h3>So, what did I do?</h3>
<p>1. I followed these instructions to manipulate the Jsp Portlet part of Liferay's plugin SDK into a maven archetype:</p>
<p><a href="http://maven.apache.org/guides/mini/guide-creating-archetypes.html">http://maven.apache.org/guides/mini/guide-creating-archetypes.html</a></p>
<p>This involved editing these property and xml files:</p>
<pre>liferay-plugin-package.properties
name=${artifactId}
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=MIT
</pre>
<pre class="xml">portlet.xml
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-app</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>jspPortlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>${groupId}.JSPPortlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;init-param<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>view-jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>/view.jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/init-param<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;expiration-cache<span style="font-weight: bold; color: black;">&gt;</span></span></span>0<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/expiration-cache<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;supports<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mime-type<span style="font-weight: bold; color: black;">&gt;</span></span></span>text/html<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mime-type<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/supports<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-info<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;title<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/title<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;short-title<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/short-title<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;keywords<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/keywords<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-info<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>administrator<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>guest<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>power-user<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>user<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-app<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>to insert ${artifactId} and ${groupId} for the portlet name and package structure. These files are part of the file list finally being wrapped up within the archetype and used to generate the resulting portlet from Maven 2.</p>
<p>2. I ran '<strong>mvn install</strong>' on that particular archetype to have it installed in my local repository.</p>
<p>3. I used the archetype to create a new Liferay Jsp Portlet artifact:</p>
<pre>
mvn archetype:create -DarchetypeGroupId=com.liferay.maven.archetypes.portlet.jsp
  -DarchetypeArtifactId=liferay-jsp-portlet
  -DarchetypeVersion=1.0-SNAPSHOT
  -DgroupId=[my.package]
  -DartifactId=[MyFirstLiferayJspPortlet]
</pre>
<p>4. I stepped into the artifact and ran '<strong>mvn install</strong>' on it which generated my MyFirstLiferayJspPortlet-1.0-SNAPSHOT.war.</p>
<p>5. I then uploaded the war file to my portal instance via the Liferay admin GUI Plugin Installer.</p>
<p>6. Et voila. It worked, showing up in the portal.</p>
<p>And of course, worth mentioning, to have a development environment up and running in eclipse in seconds this is all you have to do:</p>
<pre>
1. mvn eclipse:add-maven-repo -Declipse.workspace=[full-path-to-workspace]

2. mvn eclipse:eclipse
</pre>
<p>To have the archetype play with the existing build situation of Liferay it would probably need to be generated from some ant target and be based on the portlet template in subversion located at "plugins/tools/portlet_tmpl/" to have it follow updates of Liferay.</p>
<p><a href="https://blog.jayway.com/wp-content/uploads/2009/03/jspportlet-archetype.zip">Here you can download the final result, as a zipped archetype.</a></p>
<p>If a generated archetype like this was to be uploaded to a public maven repository, working from above point #3 and down is what would be necessary for a developer to have a project and all the necessary property and xml files (correctly edited with package structures and all) in place for a Liferay Jsp Portlet development environment. It could at least become a complement to the Plugins SDK. And yes, it could for sure still be enhanced. For example, there is no JSPPortletTest class generated for the JSPPortlet class.</p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/e0p8BaaCxUQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/</feedburner:origLink></item>
		<item>
		<title>Encrypting Properties With Jasypt</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/u655G0iw4pU/</link>
		<comments>http://blog.jayway.com/2008/12/09/encrypting-properties-with-jasypt/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:08:40 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Spring]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[properties]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=539</guid>
		<description><![CDATA[Properties are used in many Java applications as a simple way of separating parts that are likely to change, from the parts that are not that likely to change. Consider for example this typical bean definition in a Spring configuration file:
&#160;
&#60;bean id=&#34;traditionalPersonDao&#34;
      class=&#34;org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl&#34;&#62;
&#60;property name=&#34;url&#34; value=&#34;ldap://localhost:3901&#34; /&#62;
&#60;property name=&#34;base&#34; value=&#34;dc=jayway,dc=se&#34; /&#62;
&#60;property name=&#34;userDn&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Properties are used in many Java applications as a simple way of separating parts that are likely to change, from the parts that are not that likely to change. Consider for example this typical bean definition in a Spring configuration file:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;traditionalPersonDao&quot;</span>
      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;ldap://localhost:3901&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;base&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;dc=jayway,dc=se&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userDn&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;uid=admin,ou=system&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;secret&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>In order to simplify deployment and maintenance, it's quite common to extract properties related to server names, ports, and user credentials from the Spring configuration file into a separate property file, like in this <code>ldap.properties</code>:</p>
<pre>
url=ldap://localhost:3901
userDn=uid=admin,ou=system
password=secret
</pre>
<p>In the configuration file, the previously hard-coded values are replaced with "property placeholders", ie variables enclosed with <code>${}</code>:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;traditionalPersonDao&quot;</span>
      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${url}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;base&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;dc=jayway,dc=se&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userDn&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${userDn}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${password}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>In order to perform the property value substitution in a transparent way, a <code>PropertyPlaceholderConfigurer</code> is configured:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;location&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;classpath:/config/ldap.properties&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>Spring will <a href="http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-extension-factory-postprocessors">pick up</a> that one has been configured and run it before any beans are instantiated. It will read the property file and replace the placeholders with the actual values. Quite handy and very simple.</p>
<p>But what if your organization dislikes having sensitive information like passwords lying around in property files, in clear text? Let's say that your boss demands that all such passwords must be encrypted. Wouldn't it be great if the password then somehow could be automatically decrypted before being used? This can quite easily be achieved using the <a href="http://jasypt.org/">Jasypt</a> library.</p>
<p>It's a two-step process. First we need to encrypt the password. Then we configure a different <code>PropertyPlaceholderConfigurer</code> that is capable of decrypting the property after it has been read.</p>
<h4>Encrypting the password</h4>
<p>The available encryption algorithms are currently limited to Password Based Encryptors (PBE). There are scripts for encrypting and decrypting in the Jasypt distribution. This is the procedure for encrypting a text (assuming the Jasypt library has been unpacked in JASYPT_HOME):</p>
<pre>
% cd $JASYPT_HOME/bin
% chmod +x *.sh
% ./encrypt.sh input="This is my message to be encrypted" password=MYPAS_WORD verbose=false
p3ZVFhK+aqQCyvSk9uWk7p/eisyPbXp3zt3sqnEZsn1Z5plr4CHNC/HHqlgRQ7I3
</pre>
<p>Let's verify that it can actually be decrypted:</p>
<pre>
% ./decrypt.sh input="p3ZVFhK+aqQCyvSk9uWk7p/eisyPbXp3zt3sqnEZsn1Z5plr4CHNC/HHqlgRQ7I3"
    password=MYPAS_WORD verbose=false
This is my message to be encrypted
</pre>
<p>Good. Note that the encryption is "salted", so you'll never get the same result twice. You'll always be able to decrypt it, though. Want to see? OK, one more time then:</p>
<pre>
% ./encrypt.sh input="This is my message to be encrypted" password=MYPAS_WORD verbose=false
Zi68CfrcLndtKg0npE9OScr+7qNJmWrcO8XI7ZGyucjFiqT9h1FnAIxyezbqNjQq

% ./decrypt.sh input="Zi68CfrcLndtKg0npE9OScr+7qNJmWrcO8XI7ZGyucjFiqT9h1FnAIxyezbqNjQq"
    password=MYPAS_WORD verbose=false
This is my message to be encrypted
</pre>
<p>Now, let's encrypt our password:</p>
<pre>
% ./encrypt.sh input="secret" password=MYPAS_WORD verbose=false
6mbJVZ6jozGYF1pjjqDQOQ==
</pre>
<p>We'll replace the password value in the properties file with the string above, surrounded by <code>ENC()</code>:</p>
<pre>
url=ldap://localhost:3901
userDn=uid=admin,ou=system
password=ENC(6mbJVZ6jozGYF1pjjqDQOQ==)
</pre>
<h4>Configure A Decrypting PropertyPlaceholderConfigurer</h4>
<p>We'll simply replace our existing <code>PropertyPlaceholderConfigurer</code> with the Jasypt <code>EncryptablePropertyPlaceholderConfigurer</code>:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor-arg</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;configurationEncryptor&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;location&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;classpath:/config/ldap.properties&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>It delegates the actual decryption to a <code>StringEncryptor</code> implementation:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;configurationEncryptor&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jasypt.encryption.pbe.StandardPBEStringEncryptor&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;config&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;environmentVariablesConfiguration&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>The encryptor in turn needs a configuration that provides information such as the algorithm to use and the encryption password. It delegates that responsibility to a <code>PBEConfig</code> implementation that expects the password to be available in an environment variable or a system property:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;environmentVariablesConfiguration&quot;</span>
      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;algorithm&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;PBEWithMD5AndDES&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;passwordEnvName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;APP_ENCRYPTION_PASSWORD&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>Providing the encryption password as a system property is actually a good thing. A system property can be cleared just when the application has started, thereby minimizing considerably the time that the password is exposed. </p>
<h4>Running The Application</h4>
<p>It won't work with a Maven property:</p>
<pre>
% mvn test -DAPP_ENCRYPTION_PASSWORD=MYPAS_WORD
...
Tests run: 8, Failures: 0, Errors: 8, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to target/surefire-reports for the individual test results
</pre>
<p>We check the Surefire reports and find the cause of the error:</p>
<pre>
org.jasypt.exceptions.EncryptionInitializationException:
  Password not set for Password Based Encryptor
</pre>
<p>It <em>does</em> however work with an environment variable:</p>
<pre>
% export APP_ENCRYPTION_PASSWORD=MYPAS_WORD
% mvn test
...
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...
% unset APP_ENCRYPTION_PASSWORD
</pre>
<h3>Issues With Java5</h3>
<p>If we're on Java5 (or lower), we'll need <a href="http://icu-project.org/">ICU4J</a>. Otherwise, we'll run into this:</p>
<pre>
org.jasypt.exceptions.EncryptionInitializationException:
  java.lang.NoClassDefFoundError: com/ibm/icu/text/Normalizer
</pre>
<p>There are two places where we'll need ICU4J: the command line tools and our Maven project.</p>
<h4>ICU4J With The Command Line Tools</h4>
<p>Reviewing the Jasypt scripts, we find that it's possible to customize the classpath:</p>
<pre>
export JASYPT_CLASSPATH=~/Downloads/icu4j-4_0.jar
</pre>
<h4>ICU4J With Maven</h4>
<p>Add this profile to the Maven <code>pom.xml</code> to get ICU4J in the classpath:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;profiles<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;profile<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id<span style="font-weight: bold; color: black;">&gt;</span></span></span>jdk15<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/id<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;activation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;jdk<span style="font-weight: bold; color: black;">&gt;</span></span></span>1.5<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/jdk<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/activation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependencies<span style="font-weight: bold; color: black;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>com.ibm.icu<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>icu4j<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>3.8<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependencies<span style="font-weight: bold; color: black;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/profile<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/profiles<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>Currently, the 4.0 version is not available in the central Maven repo, but 3.8 seems to work just fine.</p>
<h3>Summary</h3>
<p>Using Jasypt, it's actually quite easy to use encrypted values in your property files. In a Spring-based application, it's simply a question of replacing the existing <code>PropertyPlaceholderConfigurer</code> with the Jasypt encrypting equivalent, plus two more beans providing encryption and configuration. Choose how to provide the encryption password, and you're set to go.</p>
<p>If running on Java5 or lower, you'll also need to add ICU4J to your classpath, for the encryption scripts as well as your build and deployment environment.</p>
<h3>References</h3>
<ul>
<li><a href="http://jasypt.org">http://jasypt.org</a></li>
<li><a href="http://www.springframework.org">http://www.springframework.org</a></li>
<li><a href="http://icu-project.org/">http://icu-project.org/</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/u655G0iw4pU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/12/09/encrypting-properties-with-jasypt/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2008/12/09/encrypting-properties-with-jasypt/</feedburner:origLink></item>
		<item>
		<title>Neo4j matches my mental model of information</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/7tAGY99XxBw/</link>
		<comments>http://blog.jayway.com/2008/10/06/neo4j-matches-my-mental-model-of-information/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 10:27:55 +0000</pubDate>
		<dc:creator>Mattias Ask</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[graph database]]></category>

		<category><![CDATA[neo4j]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=335</guid>
		<description><![CDATA[I’m a visual person which means that I see pictures in my head when I think about abstract things like structure, code and information. My guess is that most people do, but anyway...
When I first started looking at Neo4j I was blown away by how precise the graph database structure matched my mental model of [...]]]></description>
			<content:encoded><![CDATA[<p>I’m a visual person which means that I see pictures in my head when I think about abstract things like structure, code and information. My guess is that most people do, but anyway...</p>
<p>When I first started looking at <a href="http://neo4j.org/">Neo4j</a> I was blown away by how precise the graph database structure matched my mental model of information. You have blobs of informations (nodes with preferences) that relates to other blobs of information. Perfect! </p>
<p>When I started playing around with the API I couldn’t do what I wanted, namely extend NodeImpl and make the objects I want to persist Nodes. Now, Neo4j has a very nice API which is hard to abuse (if you don’t place your classes in the same namespace as they use), and understandably they don’t want you to extend NodeImpl. The <a href="http://wiki.neo4j.org/content/Design_Guide">design guide</a> gives this example of use:</p>
<pre class="java">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomerImpl <span style="color: #000000; font-weight: bold;">implements</span> Customer<span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Node underlyingNode;
&nbsp;
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> KEY_FIRST_NAME = <span style="color: #ff0000;">&quot;firstName&quot;</span>;
&nbsp;
        CustomerImpl<span style="color: #66cc66;">&#40;</span> Node underlyingNode <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">underlyingNode</span> = underlyingNode;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setFirstName<span style="color: #66cc66;">&#40;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> firstName <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                underlyingNode.<span style="color: #006600;">setProperty</span><span style="color: #66cc66;">&#40;</span> KEY_FIRST_NAME, firstName <span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getFirstName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> <span style="color: #66cc66;">&#41;</span> underlyingNode.<span style="color: #006600;">getProperty</span><span style="color: #66cc66;">&#40;</span> KEY_FIRST_NAME <span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// ...</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>That’s great, but it doesn’t match what I see in my head... In order to make things match I made a subtle change. </p>
<pre class="java">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> NodeDelegate <span style="color: #000000; font-weight: bold;">implements</span> Node <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">private</span> Node delegate;
&nbsp;
        <span style="color: #000000; font-weight: bold;">protected</span> NodeDelegate<span style="color: #66cc66;">&#40;</span>Node node<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                delegate = node;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// Delegate all methods of the Node interface to the</span>
        <span style="color: #808080; font-style: italic;">// Node received in the constructor...</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomerNode <span style="color: #000000; font-weight: bold;">extends</span> NodeDelegate <span style="color: #000000; font-weight: bold;">implements</span> Customer <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> KEY_FIRST_NAME = <span style="color: #ff0000;">&quot;firstName&quot;</span>;
&nbsp;
        CustomerNode<span style="color: #66cc66;">&#40;</span>Node node<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">super</span><span style="color: #66cc66;">&#40;</span>node<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setFirstName<span style="color: #66cc66;">&#40;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> firstName <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                setProperty<span style="color: #66cc66;">&#40;</span> KEY_FIRST_NAME, firstName <span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getFirstName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> <span style="color: #66cc66;">&#41;</span> getProperty<span style="color: #66cc66;">&#40;</span> KEY_FIRST_NAME <span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>By doing this I can work with my domain objects as Nodes. I don’t know if it is "correct" but with this small change I can say that "A Customer IS a Node" and this is what I see in my head. Good? Bad? You be the judge, but it fits me <img src='http://blog.jayway.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/7tAGY99XxBw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/10/06/neo4j-matches-my-mental-model-of-information/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2008/10/06/neo4j-matches-my-mental-model-of-information/</feedburner:origLink></item>
		<item>
		<title>Squid, the caching proxy</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/P_hk7AIWYNE/</link>
		<comments>http://blog.jayway.com/2008/06/06/squid-the-caching-proxy/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 17:37:34 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[performance]]></category>

		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=85</guid>
		<description><![CDATA[I just checked out the old Squid again, the worlds most famous caching proxy. If you direct all your web access through the Squid proxy server, it will cache stuff after the first access. This would simplify for example for labs where fifty people simultaneously begin retrieving stuff from a Maven repo somewhere or downloading [...]]]></description>
			<content:encoded><![CDATA[<p>I just checked out the old <a href="http://www.squid-cache.org/">Squid</a> again, the worlds most famous caching proxy. If you direct all your web access through the Squid proxy server, it will cache stuff after the first access. This would simplify for example for labs where fifty people simultaneously begin retrieving stuff from a Maven repo somewhere or downloading required libraries, and we have a very limited bandwidth.</p>
<p>On the Mac it was easy to get running (if you have <a href="http://www.macports.org/">MacPorts</a>):</p>
<pre>% sudo port install squid
% sudo squid -z (initialize stuff if you never ran Squid before)
% sudo squid -N -d 1 (no daemon, debug level 1)</pre>
<p>Then it was running on the console, and you could test it like this:</p>
<pre>% squidclient http://google.com
...
X-Cache: MISS from myhostname
Via: 1.0 myhostname:3128 (squid/2.7.STABLE2)</pre>
<p>And again, this time fetching from the cache:</p>
<pre>% squidclient http://google.com
...
X-Cache: HIT from myhostname
Via: 1.0 myhostname:3128 (squid/2.7.STABLE2)</pre>
<p>You configure your browser by simply setting proxy server to <code>localhost:3128</code>, if you are running your Squid locally, that is.</p>
<p>Maven is probably best configured in <code>~/.m2/settings.xml</code>:</p>
<pre>&lt;settings xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/xmlSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/xsd/settings-1.0.0.xsd"&gt;
  &lt;proxies&gt;
    &lt;proxy&gt;
      &lt;active&gt;true&lt;/active&gt;
      &lt;protocol&gt;http&lt;/protocol&gt;
      &lt;host&gt;localhost&lt;/host&gt;
      &lt;port&gt;3128&lt;/port&gt;
    &lt;/proxy&gt;
  &lt;/proxies&gt;
&lt;/settings&gt;</pre>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/P_hk7AIWYNE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/06/06/squid-the-caching-proxy/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2008/06/06/squid-the-caching-proxy/</feedburner:origLink></item>
		<item>
		<title>My First Weekend With iPhone SDK</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/nsgahdHbe6s/</link>
		<comments>http://blog.jayway.com/2008/03/09/my-first-weekend-with-iphone-sdk/#comments</comments>
		<pubDate>Sun, 09 Mar 2008 07:47:18 +0000</pubDate>
		<dc:creator>Fredrik Olsson</dc:creator>
		
		<category><![CDATA[Embedded]]></category>

		<category><![CDATA[Frameworks]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[mobile]]></category>

		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=265</guid>
		<description><![CDATA[My first reaction is that it is polished. Very polished. I have used the unofficial SDK for iPhone OS 1.x software, and nearly everything from iPhone OS 1.x has been redesigned. Small changes from renaming, to removal of changes, and addition of complete frameworks.
Not only the provided Frameworks are polished even in beta, so are [...]]]></description>
			<content:encoded><![CDATA[<p>My first reaction is that it is polished. Very polished. I have used the unofficial SDK for iPhone OS 1.x software, and nearly everything from iPhone OS 1.x has been redesigned. Small changes from renaming, to removal of changes, and addition of complete frameworks.</p>
<p>Not only the provided Frameworks are polished even in beta, so are the tools. Mac OS X 10.5 Leopard, and Xcode 3.1 is required! If you can live with that works perfectly, with zero setup; double click install package and you are done. Several project templates provided as starting points. Only drawback I find is that the Simulator is not an emulator of the actual hardware, eg. it is running 32-bit x86 not ARM, which makes an Java JIT-compiler undebuggable on the Simulator. Good news is that there is transparent on-device debugging, bad news again; it requires the 2.0 beta software on the phone.</p>
<p>My second reaction is that it is complete. The SDK, as well as the underlying system. It truly is the same system as on desktop Macs running on the device. The same kernel, the same Frameworks. Just a bit more restrictive memory, and screen size.</p>
<p>The documentation is impressive, ranging from conceptual books and a wide range of subjects such as as Human Interface Guidelines, Memory Management, introduction to Objective-C for beginners, writing games using Open GL | ES, security, and much more.</p>
<p>It is obvious by looking at the documentation provided that special care has been taken to cater for the needs of developers without previous experience of Cocoa, or Mac OS X development. Two thirds of the documentation is very basic for anyone with more then a few months experience with Cocoa. And the last third is in depths iPhone OS specific. Most of the documentation is also shared between iPhone OS and desktop Mac OS X, my gut feeling is that Apple want to use iPhone as a lure for developers to embrace Cocoa on Mac OS X as well.</p>
<p>Apart from documentation there is also over 4 hours of video tutorials, ranging from basic overview to optimizing OpenGL | ES games. As well as over 40 example projects, including complete applications. Bot the "show a feature" type that Android have in bounty, and "show a solution" that gives a better feel for how an application should be organized.</p>
<p>And organizing an application is important. Just as with Cocoa for Mac OS X, Cocoa Touch for iPhone OS gives the developer allot for free, provided you follow a few guidelines, and best practices. These are however few, and clear, so anyone can get the hang of it in a matter of hours. Cocoa's inherent talkative API:s with descriptive class, method and constant names, encourages developers to both use and follow "good style". A method named applicationDidLaunch is very hard to misinterpret (It is however misspelled as ApplicationDidLaunch in the iPhone OS Development Introduction ).</p>
<p>And my last reaction; it is beta! Interface Integration is not yet included. That means that you will have to create your UI in code, not using the drag-n-drop as shown on the Keynote last thursday. I miss it dearly, but try to tell myself it is a good thing to first learn how it works under the hood . That and a short list of known bugs, is really the only things I can see standing in the way of a 1.0 release.</p>
<p>I have as a tutorial for myself rewritten the URLyBird assignment for my Java Developer certification with the iPhone OS SDK. Minus the remote server it is up and running beautifully in less than 8 hours of coding.</p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/nsgahdHbe6s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/03/09/my-first-weekend-with-iphone-sdk/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2008/03/09/my-first-weekend-with-iphone-sdk/</feedburner:origLink></item>
		<item>
		<title>Using Amazon S3 for backup</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/-XSZdcPDaBk/</link>
		<comments>http://blog.jayway.com/2007/09/02/using-amazon-s3-for-backup/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 21:50:20 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[amazon]]></category>

		<category><![CDATA[backup]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[s3]]></category>

		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=162</guid>
		<description><![CDATA[Amazon Simple Storage Service (S3) is cheap on-line storage with a Web Service interface. You just log in with your Amazon id, sign up for S3, designate a credit card, and that's it. You now have access to pretty much unlimited storage space, managed by Amazon. The price is $0.15 per GB-Month of storage used [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/s3">Amazon Simple Storage Service (S3)</a> is cheap on-line storage with a Web Service interface. You just log in with your Amazon id, sign up for S3, designate a credit card, and that's it. You now have access to pretty much unlimited storage space, managed by Amazon. The price is $0.15 per GB-Month of storage used (plus transfer costs). It was too tempting; I simply had to test it.</p>
<p>I used the <a href="http://jungledisk.com/">Jungle Disk</a> software to provide the mapping from the S3 web service interface to a network drive. You give Jungle Disk your S3 account information, and it provides a network disk which you can use as the backup device. I first tried my existing backup software (<a href="http://www.qdea.com/pages/pages-sprox/sprox1.html">Synchronize! Pro X</a>) and it happily began creating directories and copying files. I then tried the backup feature built into Jungle Disk, and it works fine too. It's not fast compared to a local FireWire disk. It's limited to your upload bandwidth, which often is substantially smaller than the download bandwidth.</p>
<p>Anyway, it has been tugging along today storing 5 GB of by digital photos. It feels pretty good to know that my photos are now stored encrypted and with 99.99% availability somewhere far far away, costing me only 75 cents per month after the initial $2 for the transfer.</p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/-XSZdcPDaBk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2007/09/02/using-amazon-s3-for-backup/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2007/09/02/using-amazon-s3-for-backup/</feedburner:origLink></item>
		<item>
		<title>Sharing a Mac Internet Connection Through Airport</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/_Elgkf4JOBk/</link>
		<comments>http://blog.jayway.com/2007/01/20/sharing-a-mac-internet-connection-through-airport/#comments</comments>
		<pubDate>Sat, 20 Jan 2007 21:02:03 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=183</guid>
		<description><![CDATA[I just solved a networking problem on my Macs after hours of trying. For the benefit of others, I'll describe here the problem and the solution.
Setup
Cable modem from ISP, network cable to a firewall, the private end of the firewall via network cable on to a switch. Pretty basic, I guess. No wireless base stations [...]]]></description>
			<content:encoded><![CDATA[<p>I just solved a networking problem on my Macs after hours of trying. For the benefit of others, I'll describe here the problem and the solution.</p>
<h3>Setup</h3>
<p>Cable modem from ISP, network cable to a firewall, the private end of the firewall via network cable on to a switch. Pretty basic, I guess. No wireless base stations or anything. Just an iMac connected via network cable to the switch.</p>
<h3>Problem</h3>
<p>Share the iMac's network cable connection through its Airport wireless capability. The client is a MacBook Pro. Basically, I just want to get Internet access on my laptop via the iMac. Sounds simple, but hey, it took me half a day and plenty of research to figure out.</p>
<h4>Useful pieces of information gathered during this adventure</h4>
<ol>
<li>Turning on Internet Connection Sharing (ICS) will start a DHCP server.</li>
<li>Turning on ICS will create a full Airport network (not a computer-to-computer network).</li>
<li>Turning on ICS will create a new network configuration for 10.0.2.1, which I understand is the same address as the Airport base stations use.</li>
</ol>
<h3>Solution</h3>
<ol>
<li>On the iMac, set the Airport network to "Use DHCP with manual address" and set the IP to 10.0.2.1. Set the DNS servers to the ones recommended by your ISP. Apply.</li>
<li>On the iMac, go to Sharing|Internet and choose AirPort Options. Enable WEP encryption (I chose 40-bit with a 5 character password). The default network name is your computer name. I added a postfix to the network name ("-ics") so I can distinguish it from the computer-to-computer network. Apply.</li>
<li>Now start sharing your Built-in Ethernet connection to computers using Airport. As I mentioned previously, this will create the new network and also start a DHCP server.</li>
<li>On the MacBook, set the Airport network to "Use DHCP". Leave all fields blank.</li>
<li>On the MacBook, connect to the newly created network, which should be named "hostname-ics" if you followed my naming advice earlier. Watch the network configuration. Eventually it shows the IP 10.0.2.2.</li>
</ol>
<p>That's it. You should now have access to your other machines on your private network, but also to Internet.</p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/_Elgkf4JOBk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2007/01/20/sharing-a-mac-internet-connection-through-airport/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2007/01/20/sharing-a-mac-internet-connection-through-airport/</feedburner:origLink></item>
		<item>
		<title>Solving 403 problems with Sourceforge Subversion</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/pJpzDbjomyA/</link>
		<comments>http://blog.jayway.com/2007/01/13/solving-403-problems-with-sourceforge-subversion/#comments</comments>
		<pubDate>Sat, 13 Jan 2007 15:54:42 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[dns]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[sourceforge]]></category>

		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=177</guid>
		<description><![CDATA[After having had severe problems when committing to the Sourceforge Subversion repos, I stumbled upon what appears to be the solution. The problem was that in the middle of a commit, one file or directory would fail with a 403 (permission denied). In desperation, I would chop up the change set and commit little pieces [...]]]></description>
			<content:encoded><![CDATA[<p>After having had severe problems when committing to the Sourceforge Subversion repos, I stumbled upon what appears to be the solution. The problem was that in the middle of a commit, one file or directory would fail with a 403 (permission denied). In desperation, I would chop up the change set and commit little pieces at the time, until only the ones with problems remained. I would then perform desperate unnamed actions with these until they eventually were committed. Pretty nerve-wrecking, time-consuming, and unproductive stuff. The worst part is that if you split the change set, you could end up splitting a move operation, which is basically a copy and a delete. Say that you commit the delete operation successfully first. Then you try to commit the copy, which will fail with a 404 (not found), since the stuff it tries to copy has been deleted. There are ways around it, but I won't describe them here. Horrible stuff.</p>
<p>I had seen somewhere that you could get the 403 error if you were using SSL (which I was) and the Sourceforge server <tt>svn.sourceforge.net</tt>. The correct server is the <tt>PROJECTNAME.svn.sourceforge.net</tt>, where <tt>PROJECTNAME</tt> in my case was <tt>springframework</tt>. So <b>the correct URL to use is <tt>https://springframework.svn.sourceforge.net/svnroot/springframework/</tt>.</b> This meant changing the checkout URL, which Subversion can do on an already checked-out working copy, using the <tt>switch</tt> command. Cool. When I tried this, it failed because it couldn't find the new server. The problem was that the DNS servers I was using at some point didn't find this server, and probably cached this negative hit. Eventually I found a DNS that could locate this server and performed the switch. Things have been working much better since.</p>
<p>Using the incorrect server, which most likely is a proxy server of some sort, could possibly have resulted in different physical servers being used for different requests during the Subversion transaction. It's not allowed to perform a <tt>svn copy</tt> operation between repositories. You'll get a 403 if you try it. Perhaps that rule applied to my situation as well.</p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/pJpzDbjomyA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2007/01/13/solving-403-problems-with-sourceforge-subversion/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2007/01/13/solving-403-problems-with-sourceforge-subversion/</feedburner:origLink></item>
		<item>
		<title>A cool GMail feature</title>
		<link>http://feedproxy.google.com/~r/jayway/posts/tools/~3/DjUsNkoO3Cs/</link>
		<comments>http://blog.jayway.com/2007/01/03/a-cool-gmail-feature/#comments</comments>
		<pubDate>Wed, 03 Jan 2007 15:34:37 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[mail]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=172</guid>
		<description><![CDATA[Google Mail will deliver a mail even though the recipient address ends with '+' and some more text, like john.doe+msn@gmail.com for example. This feature can be used to create an unlimited number of mail addresses that can be used for registration purposes. For example, say that the MSN web site requires your email address for [...]]]></description>
			<content:encoded><![CDATA[<p>Google Mail will deliver a mail even though the recipient address ends with '+' and some more text, like <tt>john.doe+msn@gmail.com</tt> for example. This feature can be used to create an unlimited number of mail addresses that can be used for registration purposes. For example, say that the MSN web site requires your email address for you to download some stuff you need. You don't want to give up your real email, since you're afraid you'll be spammed. Yet you need to give a valid email since they might send registration information to it, like the password. The solution is to use <tt>john.doe+msn@gmail.com</tt> and the mails will still be delivered to the <tt>john.doe</tt> mailbox. However, you can now quickly identify if the address you gave when you registered at MSN has been used for spam, and create a filter to handle them. GMail filters allow you to perform any or all of the following actions: archive, delete, label, forward, mark with a star.</p>
<p>Note that although this follows the Internet standard for email addresses (<a href="http://www.ietf.org/rfc/rfc0822.txt">RFC 822</a>), some sites simply ignore this and incorrectly disallows addresses with plus signs.</p>
<p>Read more <a href="http://21st.blogspot.com/2006/09/use-gmail-generate-unlimited-e-mail.html">here</a>. More cool mail tips can be found <a href="http://www.howtohut.com/tag/email">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/jayway/posts/tools/~4/DjUsNkoO3Cs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2007/01/03/a-cool-gmail-feature/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.jayway.com/2007/01/03/a-cool-gmail-feature/</feedburner:origLink></item>
	</channel>
</rss>
