<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Path to Zen &#187; java</title>
	<atom:link href="http://www.digizenstudio.com/blog/categories/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digizenstudio.com/blog</link>
	<description>Jing Xue's Weblog</description>
	<lastBuildDate>Tue, 01 Jun 2010 01:40:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>When does Ivy:deliver not replace dynamic revisions?</title>
		<link>http://www.digizenstudio.com/blog/2009/03/28/when-does-ivy-deliver-not-replace-dynamic-revisions/</link>
		<comments>http://www.digizenstudio.com/blog/2009/03/28/when-does-ivy-deliver-not-replace-dynamic-revisions/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 04:27:09 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[ivy]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/?p=234</guid>
		<description><![CDATA[When publishing a module, Ivy:deliver (and in turn, publish) has the ability to replace dynamic dependency revisions (e.g. ranges like &#8220;2.5+&#8221;) with the specific revisions resolved. One thing that is not very obvious is that, since the task relies on the latest resolve results to figure out what exactly those dynamic revisions are resolved to, [...]]]></description>
			<content:encoded><![CDATA[<p>When publishing a module, Ivy:deliver (and in turn, publish) has the ability to replace dynamic dependency revisions (e.g. ranges like &#8220;2.5+&#8221;) with the specific revisions resolved. One thing that is not very obvious is that, since the task relies on the latest resolve results to figure out what exactly those dynamic revisions are resolved to, if the latest resolve is a partial one &#8211; meaning only some of the confs are resolved, ivy:deliver may not be able to see all the resolved revisions.</p>
<p>I discovered this when I changed my build script to only resolve &#8216;master&#8217; before publishing a snapshot to a local repo, because I wanted local publishes to be extremely fast. I guess it&#8217;s ok for local snapshots to carry dynamic revisions, but it&#8217;s probably a good idea to always do a full resolve before publishing a release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2009/03/28/when-does-ivy-deliver-not-replace-dynamic-revisions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Ant Task to Maintain Eclipse Classpaths with Ivy Resolve Results</title>
		<link>http://www.digizenstudio.com/blog/2009/02/13/ivy-ant-task-to-maintain-eclipse-classpaths/</link>
		<comments>http://www.digizenstudio.com/blog/2009/02/13/ivy-ant-task-to-maintain-eclipse-classpaths/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 05:21:00 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ivy]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/?p=223</guid>
		<description><![CDATA[I put together an Ant task(download) that can use the result of the ivy:resolve task to maintain Eclipse's .classpath file. If your ivy:resolve also generates references to the source jars, this task will also attach them to the corresponding classpath entries in the .classpath file.
To use the class, drop the class on you Ant classpath, [...]]]></description>
			<content:encoded><![CDATA[<p>I put together an Ant task(<a href='http://www.digizenstudio.com/blog/wp-content/uploads/2009/02/EclipseClasspath.java'>download</a>) that can use the result of the <code>ivy:resolve</code> task to maintain Eclipse's .classpath file. If your ivy:resolve also generates references to the source jars, this task will also attach them to the corresponding classpath entries in the .classpath file.<span id="more-223"></span></p>
<p>To use the class, drop the class on you Ant classpath, then declare the task like so:</p>
<div class="igBar"><span id="lxml-5"><a href="#" onclick="javascript:showPlainTxt('xml-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-5">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"ivyeclipse"</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">"org.apache.ivy.ant.EclipseClasspath"</span><span style="font-weight: bold; color: black;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
It's a standard <a href="http://ant.apache.org/ivy/history/latest-release/use/postresolvetask.html" rel="_blank">Ivy post-resolve task</a>. What that means is a) it takes the same common attribute set as any other post-resolve tasks would, and b) it must be run after an ivy:resolve call.  For example, every time the following line</p>
<div class="igBar"><span id="lxml-6"><a href="#" onclick="javascript:showPlainTxt('xml-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-6">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ivyeclipse</span> <span style="color: #000066;">conf</span>=<span style="color: #ff0000;">"provided,testtime"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
executes, the entries in .classpath that were generated from the previous run are removed, and new entries added according to the latest ivy:resolve result on ivy conf "provided" and "testtime".  The entries generated by this task are marked with an attribute, <code>ivygen="true"</code>, so any entries you manually added are not impacted.  <strong>Note:</strong> if you have added classpath entries manually for the dependencies in ivy.xml, before running this task for the first time ever, it's a good idea to remove all of them, otherwise you'll end up with duplicated entries.</p>
<p>To invoke the source jar attachment support, just add to the ivy.xml references to the source jars. For example:</p>
<div class="igBar"><span id="lxml-7"><a href="#" onclick="javascript:showPlainTxt('xml-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-7">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency</span> <span style="color: #000066;">org</span>=<span style="color: #ff0000;">"org.hibernate"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"hibernate-core"</span> <span style="color: #000066;">rev</span>=<span style="color: #ff0000;">"3.3.1.GA"</span> <span style="color: #000066;">conf</span>=<span style="color: #ff0000;">"compile;references"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifact</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"hibernate-core"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"sources"</span> <span style="color: #000066;">ext</span>=<span style="color: #ff0000;">"jar"</span> m:<span style="color: #000066;">classifier</span>=<span style="color: #ff0000;">"sources"</span> <span style="color: #000066;">conf</span>=<span style="color: #ff0000;">"references"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
would add hibernate-core's source jar to ivy conf named "references". Then make sure to include conf "references" in the ivy:resolve call, such as:</p>
<div class="igBar"><span id="lxml-8"><a href="#" onclick="javascript:showPlainTxt('xml-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-8">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ivyeclipse</span> <span style="color: #000066;">conf</span>=<span style="color: #ff0000;">"provided,testtime,references"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
The classpath entries updated will then also have the corresponding source jars (if available) attached.</p>
<p><a href='http://www.digizenstudio.com/blog/wp-content/uploads/2009/02/EclipseClasspath.java'><strong>Here's the source code for the task.</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2009/02/13/ivy-ant-task-to-maintain-eclipse-classpaths/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fix broken maven-metadata.xml through Nexus</title>
		<link>http://www.digizenstudio.com/blog/2009/01/17/fix-broken-maven-metadataxml-through-nexus/</link>
		<comments>http://www.digizenstudio.com/blog/2009/01/17/fix-broken-maven-metadataxml-through-nexus/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 02:41:23 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[ivy]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[nexus]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/?p=210</guid>
		<description><![CDATA[The log4j maven-metadata.xml hosted at ibiblio is missing the latest two versions, 1.1.14 and 1.1.15.  It becomes a problem for me as an Ivy user, too, since Ivy 2.0 adds the ability to use maven metadata to list available versions.
Fortunately I have a Nexus repository as the aggregator/proxy to all the external repositories.  [...]]]></description>
			<content:encoded><![CDATA[<p>The log4j maven-metadata.xml hosted at <a href="http://repo2.maven.org/maven2/log4j/log4j/maven-metadata.xml" rel="_blank">ibiblio</a> is missing the latest two versions, 1.1.14 and 1.1.15.  It becomes a problem for me as an Ivy user, too, since Ivy 2.0 adds the ability to <a href="http://www.digizenstudio.com/blog/2008/03/18/ivy-2-maven-metadata-support/" rel="_blank">use maven metadata to list available versions</a>.</p>
<p>Fortunately I have a Nexus repository as the aggregator/proxy to all the external repositories.  Brian from the Nexus IRC room pointed me to this solution/workaround: add the fixed maven-metadata.xml to a repo hosted by Nexus - e.g., the "3rd Party" repo coming out of box in Nexus. Then create a group to aggregate the 3rd Party and the public Ibiblio repos.  The "virtual" group repo will automatically create a merged maven-metadata.xml on the fly whenever it is requested.</p>
<p>And it works like a charm. Thanks, Brian!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2009/01/17/fix-broken-maven-metadataxml-through-nexus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hibernate more picky on character type discriminators</title>
		<link>http://www.digizenstudio.com/blog/2008/11/20/hibernate-more-picky-on-character-type-discriminators/</link>
		<comments>http://www.digizenstudio.com/blog/2008/11/20/hibernate-more-picky-on-character-type-discriminators/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 03:15:02 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[hibernate]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/?p=194</guid>
		<description><![CDATA[On a project I'm working on, I've got one abstract base class and two subclasses, which are mapped to one same table, with a single character column as the discriminator. I got this error when Hibernate initializes:

org.hibernate.MappingException: multiple or zero characters found parsing string

Turns out if the discriminator type is "character", the base class must [...]]]></description>
			<content:encoded><![CDATA[<p>On a project I'm working on, I've got one abstract base class and two subclasses, which are mapped to one same table, with a single character column as the discriminator. I got this error when Hibernate initializes:</p>
<blockquote><p>
<code>org.hibernate.MappingException: multiple or zero characters found parsing string</code>
</p></blockquote>
<p>Turns out if the discriminator type is "character", the base class must have a discriminator-value attribute declared, even though obviously due to the abstractness there will never be any row carrying that discriminator value.  And apparently for "string" type discriminators, there isn't such a limitation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2008/11/20/hibernate-more-picky-on-character-type-discriminators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Upgrade The Freemarker Jar Bundled In JBoss Freemarker IDE</title>
		<link>http://www.digizenstudio.com/blog/2008/08/30/how-to-upgrade-the-freemarker-jar-bundled-in-jboss-freemarker-ide/</link>
		<comments>http://www.digizenstudio.com/blog/2008/08/30/how-to-upgrade-the-freemarker-jar-bundled-in-jboss-freemarker-ide/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 23:28:48 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[freemarker]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[osgi]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/?p=167</guid>
		<description><![CDATA[The current version (1.0.0.GA) of Freemarker IDE from JBoss Tools comes with freemarker-2.3.8.jar bundled. To update to freemarker 2.3.13:

Copy freemarker-2.3.13.jar into $ECLIPSE_INSTALLATION/plugins/org.jboss.ide.eclipse.freemarker_1.0.0.GA, and remove the freemarker-2.3.8.jar in there.
Edit META-INF/MANIFEST.MF to replace the reference to "freemarker-2.3.8.jar" with "freemarker-2.3.13.jar".
Restart Eclipse with the "-clean" command line option. This is important because otherwise the Eclipse OSGI engine will keep [...]]]></description>
			<content:encoded><![CDATA[<p>The current version (1.0.0.GA) of Freemarker IDE from <a href="http://www.jboss.org/tools/">JBoss Tools</a> comes with freemarker-2.3.8.jar bundled. To update to freemarker 2.3.13:</p>
<ol>
<li>Copy freemarker-2.3.13.jar into <code>$ECLIPSE_INSTALLATION/plugins/org.jboss.ide.eclipse.freemarker_1.0.0.GA</code>, and remove the freemarker-2.3.8.jar in there.</li>
<li>Edit <code>META-INF/MANIFEST.MF</code> to replace the reference to "freemarker-2.3.8.jar" with "freemarker-2.3.13.jar".</li>
<li>Restart Eclipse with the "-clean" command line option. This is important because otherwise the Eclipse OSGI engine will keep using cached bundle data which is stale now.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2008/08/30/how-to-upgrade-the-freemarker-jar-bundled-in-jboss-freemarker-ide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The UnknownHostException and A Not-so-obvious Cause</title>
		<link>http://www.digizenstudio.com/blog/2008/06/09/the-unknownhostexception-and-a-not-so-obvious-cause/</link>
		<comments>http://www.digizenstudio.com/blog/2008/06/09/the-unknownhostexception-and-a-not-so-obvious-cause/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 01:12:15 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/?p=160</guid>
		<description><![CDATA[The past week has turned out to be the week of "all sorts of weird problems" for me.  One of the issues I ran into was that, in a new Ubuntu installation, maven fails to download artifacts from the repository server.  After some arm-twisting with maven (people really should start logging the actually [...]]]></description>
			<content:encoded><![CDATA[<p>The past week has turned out to be the week of "all sorts of weird problems" for me.  One of the issues I ran into was that, in a new Ubuntu installation, maven fails to download artifacts from the repository server.  After some arm-twisting with maven (people really should start logging the actually exception instead of just printing "unable to download artifact..."), I was able to pinpoint the underlying problem to be an UnknownHostException from trying to resolve the repository server.  The strangeness of the situation is, I can access the repo and download the same artifact with firefox, wget, or anything non-java.  I can also resolve the repo server name just fine with nslookup.<span id="more-160"></span></p>
<p>And here comes the second layer of strangeness - I also have an ubuntu virtualbox machine running in the same box, with the same JDK version, same setup, and the same source tree.  And it works just fine in there.</p>
<p>So fast-forward through a few hours of hair pulling, the two workarounds I eventually figured out are:</p>
<ul>
<li>The <code>/etc/nsswitch.conf</code> file out-of-box has a line looking like this:<br />
<code>hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4</code><br />
Apparently the name resolution code in JVM (e.g. <code>InetAddress.getByName()</code> and friends) doesn't like the multicasting DNS (represented by 'mdns4_minimal').<br />
Move 'dns' up so it looks like:<br />
<code>hosts:          files <strong>dns</strong> mdns4_minimal [NOTFOUND=return] mdns4</code><br />
solves the problem.  On the other hand, I haven't observed any negative effect of this change on any of the non-Java applications.
</li>
<li>If you are not comfortable with or don't have control over changing a box-wide config file, another workaround is to set the system property <code>java.net.preferIPv4Stack</code> to <code>true</code> when starting a Java application (maven in my case) which needs to do name resolution.</li>
</ul>
<p>So how come the default works fine in the virtual machine?  My theory is that when running in there, the virtualbox NAT code running in the guest OS is called for name resolution during 'files'-based resolution, and is able to handle it by delegating to the host OS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2008/06/09/the-unknownhostexception-and-a-not-so-obvious-cause/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ivy 2 beta 2 Adds Maven Metadata Support</title>
		<link>http://www.digizenstudio.com/blog/2008/03/18/ivy-2-maven-metadata-support/</link>
		<comments>http://www.digizenstudio.com/blog/2008/03/18/ivy-2-maven-metadata-support/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 23:33:41 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[ivy]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2008/03/18/ivy-2-maven-metadata-support/</guid>
		<description><![CDATA[Ivy 2.0 beta 2 adds an interesting useMavenMetaData switch to its ibiblio resolver. When it's on (the default actually), Ivy will try and use the maven-metadata.xml for listing the versions available, and for dynamic dependency resolution. This is interesting to me because it makes it a lot easier to run our builds against a proxy [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ant.apache.org/ivy/history/2.0.0-beta2/index.html" rel="_blank">Ivy 2.0 beta 2</a> adds an interesting <code>useMavenMetaData</code> switch to its ibiblio resolver. When it's on (the default actually), Ivy will try and use the maven-metadata.xml for listing the versions available, and for dynamic dependency resolution. This is interesting to me because it makes it a lot easier to run our builds against a proxy repository server like <a href="http://www.google.com/url?sa=t&#038;ct=res&#038;cd=1&#038;url=http%3A%2F%2Fmaven-proxy.codehaus.org%2F&#038;ei=QfXdR-u-E6KMiwHP3MDhBQ&#038;usg=AFQjCNGi21bVGx7PO0TIVDMhr8DJe72KmA&#038;sig2=kI1pyOBn6kM6vzHApMP6oA" rel="_blank">Maven Proxy</a> or <a href="http://www.google.com/url?sa=t&#038;ct=res&#038;cd=1&#038;url=http%3A%2F%2Fmaven.apache.org%2Farchiva%2F&#038;ei=Z_XdR-_vMozqiAHptJHDBQ&#038;usg=AFQjCNHsRevKxvYtOfiEaDk2-2r0yLkhDw&#038;sig2=EKaF7VMZ-uytuguDdcKqPA" rel="_blank">Archiva</a>. </p>
<p>Until beta 2, Ivy finds out about the available versions of a module by parsing the directory listing HTML from Ibiblio's Apache server. That doesn't work when there is a proxy server sitting in between, because a) the proxy server doesn't usually proxy directory listing requests, and/or b) the proxy server renders the directory listing in different HTML. Switching to using the structured maven meta data completely eliminated this mess.</p>
<p>Of course, using the maven-metadata.xml files from the official ibiblio repository will subject us to some new hazard - some modules   have out-of-date maven-metadata.xml. For instance, by its maven-metadata.xml, the latest version of Hibernate would still be 3.2.0.cr1.</p>
<p>One of those maven proxy servers turns out to be a perfect solution to this problem - we can use them now, remember? <img src='http://www.digizenstudio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   In my case, I run an Archiva server proxying the official maven 2 repository. Whenever I run into a bad metadata file, I simply request the missing version through Archiva, and it will fetch it <em>and</em> update the metadata file.  For example, in the hibernate case, I would just open up Firefox and try to download <code>http://archiva-server/repository/internal/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar</code>.  That only needs to be done once, and afterwards Archiva would have updated its local version of the maven-metadata.xml properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2008/03/18/ivy-2-maven-metadata-support/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Could Java 7 Please Add A Subpackage Access Modifier?</title>
		<link>http://www.digizenstudio.com/blog/2008/01/06/could-java-7-please-add-a-subpackage-access-modifier/</link>
		<comments>http://www.digizenstudio.com/blog/2008/01/06/could-java-7-please-add-a-subpackage-access-modifier/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 03:34:41 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2008/01/06/could-java-7-please-add-a-subpackage-access-modifier/</guid>
		<description><![CDATA[As we all know, the package hierarchy in Java is a rather superficial one. Package com.foo.pack.sub means nothing special to package com.foo.pack - no more special than com.bar.whatever. It's something that's seemingly trivial, but really has been discouraging proper organization of classes and more careful design practices.
As an example, say I would like to organize [...]]]></description>
			<content:encoded><![CDATA[<p>As we all know, the package hierarchy in Java is a rather superficial one. Package <code>com.foo.pack.sub</code> means nothing special to package <code>com.foo.pack</code> - no more special than <code>com.bar.whatever</code>. It's something that's seemingly trivial, but really has been discouraging proper organization of classes and more careful design practices.<span id="more-154"></span></p>
<p>As an example, say I would like to organize the interfaces/classes that constitute an order handling API into a com.foo.order package, such as:</p>
<ul>
<li><code>Order</code> - the aggregation root of the domain.</li>
<li><code>LineItem</code> - the entity class that represents each line item on an order. Each order has a list of line items.</li>
<li><code>OrderService</code> - an interface for an order handling service.</li>
<li><code>OrderRepostiory</code> - a repository interface for access the order objects.</li>
</ul>
<p>And I'd like the implementation classes kept in a <code>com.foo.order.impl</code> sub-package, which would have, of course, <code>OrderServiceImpl</code> and <code>OrderRepositoryImpl</code>.</p>
<p>Now the problem comes. On the <code>Order</code> class, as part of the domain API, I have public methods controlling access to the line items by index, e.g., <code>getLineItem(int i)</code>. In the meantime, I would like to provide a method <code>setLineItems(List items)</code> so that the repository implementation can efficiently set the list of line items read from the database. Obviously that method should not be public, as it defeats the purpose of any other controlled accessors. On the other hand, there is no way other than making the method public for it to be accessible to the repository implementation, due to it being in a different package.</p>
<p>It seems to be quite a natural thing to me for Java to support an extra level of access - the sub-package level. It would be between public and the default access - only classes in the same package or the sub-packages can access members declared at this level.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2008/01/06/could-java-7-please-add-a-subpackage-access-modifier/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spring 2.5&#8217;s Unintrusive Annotation-based Configuration</title>
		<link>http://www.digizenstudio.com/blog/2007/11/14/spring-25s-unintrusive-annotation-based-configuration/</link>
		<comments>http://www.digizenstudio.com/blog/2007/11/14/spring-25s-unintrusive-annotation-based-configuration/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 03:00:33 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/11/14/spring-25s-unintrusive-annotation-based-configuration/</guid>
		<description><![CDATA[Annotation-based configuration isn't new, but Spring 2.5 adds an interesting twist to it by making it possible to use annotations for wiring, yet without being explicitly tied to any Spring classes.
Say we have two classes:
PLAIN TEXT
JAVA:




import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.beans.factory.annotation.Component;


@Component


public class Psychic &#123;


&#160; &#160; private CrystalBall daBall;


&#160; &#160; public String tellFate&#40;&#41; &#123;


&#160; &#160; &#160; &#160; return daBall.getPrediction&#40;&#41;;


&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Annotation-based configuration isn't new, but Spring 2.5 adds an interesting twist to it by making it possible to use annotations for wiring, yet without being explicitly tied to any Spring classes.<span id="more-153"></span></p>
<p>Say we have two classes:</p>
<div class="igBar"><span id="ljava-12"><a href="#" onclick="javascript:showPlainTxt('java-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-12">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Autowired;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Component;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.google.com/search?q=allinurl%3AComponent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Component</span></a></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Psychic <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> CrystalBall daBall;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> tellFate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> daBall.<span style="color: #006600;">getPrediction</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> CrystalBall getDaBall<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> daBall;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Autowired</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setDaBall<span style="color: #66cc66;">&#40;</span>CrystalBall daBall<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">daBall</span> = daBall;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> CrystalBall <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> prediction;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getPrediction<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> prediction;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setPrediction<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> prediction<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">prediction</span> = prediction;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In the context file, a simpe one-liner</p>
<div class="igBar"><span id="lxml-13"><a href="#" onclick="javascript:showPlainTxt('xml-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-13">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;context</span> :annotation-config<span style="font-weight: bold; color: black;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>gets the above two beans wired together (or any number of other beans as long as they are properly annotated with the two markers).</p>
<p>Easy, right? Well, the only problem is that those two imports make our otherwise nice domain class depending on some Spring infrastructure. Fortunately, with a little extra config, we can remove this dependency.</p>
<p>First we create our own annotation classes. In this case I simply copied the two Spring ones into my package structure, with the code itself remaining the same. So I won't bother to post it here. Bottom line is now we have our own <code>sandbox.spring.annotation.Component</code> and <code>sandbox.spring.annotation.Autowired</code>.</p>
<p>So now we replace the Spring annotation classes in those imports with our own versions, and change that one-liner above to:</p>
<div class="igBar"><span id="lxml-14"><a href="#" onclick="javascript:showPlainTxt('xml-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-14">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"autowiredAnnotationBeanPostProcessor"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; p:<span style="color: #000066;">autowiredAnnotationType</span>=<span style="color: #ff0000;">"sandbox.spring.annotation.Autowired"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;context</span> :component-scan <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">"sandbox.spring.annotation"</span> <span style="color: #000066;">annotation-config</span>=<span style="color: #ff0000;">"false"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;context</span> :include-filter <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"annotation"</span> <span style="color: #000066;">expression</span>=<span style="color: #ff0000;">"sandbox.spring.annotation.Component"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;context</span> :exclude-filter <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"annotation"</span> <span style="color: #000066;">expression</span>=<span style="color: #ff0000;">"org.springframework.stereotype.Component"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/context<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Basically the <code>autowiredAnnotationBeanPostProcessor</code> bean definition defines a customized BeanPostProcessor that looks for our own <code>Autowired</code> annotation instead of the default one.  And then the <code>&lt;context:component-scan&gt;</code> element overrides the default <code>Component</code> annotation with our version.</p>
<p>Note that it's important to have the <code>annotation-config="false"</code> above, for it turns off the default BeanPostProcessors.</p>
<p>Also worth noting is that the extra config is applied to all other annotated beans, so despite it might look overly complicated in this case, it's really trivial in any serious context where hundreds of beans could benefit from this same piece of config.</p>
<p>Similar to the two annotations discussed above, pretty much all others (such as <code>@Required</code>) can be substituted with customized versions via similar configuration.</p>
<p>I have never been a big fan of annotation-based configuration. One of my biggest concerns - and perhaps the only practical one - is the compile-time coupling it introduces. With this unintrusive way being introduced in Spring 2.5, I find annotation-based configuration a strategy more valid than ever.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/11/14/spring-25s-unintrusive-annotation-based-configuration/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Log4j 1.2.15: What&#8217;s With All These Dependencies?</title>
		<link>http://www.digizenstudio.com/blog/2007/09/19/log4j-1215-whats-with-all-these-dependencies/</link>
		<comments>http://www.digizenstudio.com/blog/2007/09/19/log4j-1215-whats-with-all-these-dependencies/#comments</comments>
		<pubDate>Wed, 19 Sep 2007 21:55:58 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/09/19/log4j-1215-whats-with-all-these-dependencies/</guid>
		<description><![CDATA[I may not necessarily agree with Weiqi Gao's opinion that Log4j Must Die, but I have to admit that I really think the new mandatory dependencies added by log4j 1.2.15 are going over the board. To add insult to injury, some of those dependencies - namely com.sun.jdmk.jmxtools and com.sun.jmx.jmxri - aren't actually available in any [...]]]></description>
			<content:encoded><![CDATA[<p>I may not necessarily agree with Weiqi Gao's opinion that <a href="http://www.weiqigao.com/blog/2007/08/29/log4j_must_die.html" rel="_blank">Log4j Must Die</a>, but I have to admit that I really think the new <a href="http://repo1.maven.org/maven2/log4j/log4j/1.2.15/log4j-1.2.15.pom" rel="_blank"><em>mandatory</em> dependencies</a> added by log4j 1.2.15 are going over the board. To add insult to injury, some of those dependencies - namely <code>com.sun.jdmk.jmxtools</code> and <code>com.sun.jmx.jmxri</code> - aren't actually available in any public repository due to license reasons.<span id="more-150"></span><br />
Ironically I just commented on Weiqi's aforementioned post that the major driving force for us to stay with log4j is its flexible configuration and powerful ability to interact with various message sinks. I mean those are all great things to have, but in the meanwhile could the good folks at log4j please change those dependencies to 'optional' or even 'provided', unless it's really, really dependded on by the core log4j?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/09/19/log4j-1215-whats-with-all-these-dependencies/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Checked Exceptions and Alternate Business Flows</title>
		<link>http://www.digizenstudio.com/blog/2007/07/17/checked-exceptions-and-alternate-business-flows/</link>
		<comments>http://www.digizenstudio.com/blog/2007/07/17/checked-exceptions-and-alternate-business-flows/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 17:57:28 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/07/17/checked-exceptions-and-alternate-business-flows/</guid>
		<description><![CDATA[As I have always had problems with Java's checked exceptions, I had a little debate with Debasish in the comments section of his recent blog post regarding exceptions in DDD.  Over there, I concluded my case with:

I also realize that you feel stronger urge to enforce exception handling in contracts than I do, because [...]]]></description>
			<content:encoded><![CDATA[<p>As I have always had <a href="http://www.digizenstudio.com/blog/2006/08/08/my-2-cents-on-checked-exceptions/" rel="_blank">problems with Java's checked exceptions</a>, I had a little debate with Debasish in the comments section of <a href="http://debasishg.blogspot.com/2007/06/domain-driven-design-whats-in-exception.html" rel="_blank">his recent blog post</a> regarding exceptions in DDD.  Over there, I concluded my case with:<span id="more-144"></span></p>
<blockquote><p>
I also realize that you feel stronger urge to enforce exception handling in contracts than I do, because of another philosophical difference - I think things like "insufficient balance" aren't really exceptions, and should be expressed as the status of an account or a transaction in a first-class domain object.</p>
<p>But I guess that's an even finer line to draw, so, another debate for another day... <img src='http://www.digizenstudio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
</p></blockquote>
<p>Well, I guess that "other day" <a href="http://debasishg.blogspot.com/2007/07/domain-driven-design-handling-alternate_3757.html" rel="_blank">has come</a>.:-)</p>
<p>Basically Debasish is promoting the approach to handle alternate business flows with checked exceptions, like so (sample code quoted from his post):</p>
<div class="igBar"><span id="ljava-17"><a href="#" onclick="javascript:showPlainTxt('java-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-17">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3APosition+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Position</span></a> updatePosition<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//.. normal flow</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; current = getPosition<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; current.<span style="color: #006600;">doUpdate</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> current;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>ShortPositionException spex<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//.. short position handling</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>DelinquentPositionException dpex<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//.. delinquent position handling</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now, to me, that begs for the question: <strong>how is that, in essence, different from doing:</strong></p>
<div class="igBar"><span id="ljava-18"><a href="#" onclick="javascript:showPlainTxt('java-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-18">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> PositionStatus <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ShortPositionStatus implementing PositionStatus <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DelinquentPostitionStatus implementing PositionStatus <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ItsAllCoolPositionStatus implementing PositionStatus <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// ... and then</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3APosition+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Position</span></a> updatePosition<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; current = getPosition<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; PositionStatus status = current.<span style="color: #006600;">doUpdate</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>status <span style="color: #000000; font-weight: bold;">instanceof</span> ItsAllCoolPositionStatus<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> current;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>status <span style="color: #000000; font-weight: bold;">instanceof</span> ShortPositionStatus<span style="color: #66cc66;">&#41;</span>&nbsp; <span style="color: #808080; font-style: italic;">// short position handling.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>status <span style="color: #000000; font-weight: bold;">instanceof</span> DelinquentPosition<span style="color: #66cc66;">&#41;</span>&nbsp; <span style="color: #808080; font-style: italic;">// delinquent position handling.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I believe doing unnecessary type-based branching like that is generally considered very un-OO.  I probably wouldn't hire myself if I wrote code like that in an interview.  Why, then, should it be considered a legitimate pattern simply after being dressed up in a try-catch block?</p>
<p>Of course, I hear the argument that "the compiler then enforces the handling for you". And that would bring it back to my original debate with Debash, in which my main point was that the way checked exceptions are designed in Java to "help" enforcing contracts is highly intrusive - quoting my own comments from Debasish's blog:</p>
<blockquote><p>
"I would like to force the caller of my api..." that's the philosophy I'm against really <img src='http://www.digizenstudio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  - checked exception is just the expression of that philosophy on the surface.</p>
<p>And the reason is very simple - I can't find any software engineering doctrine that says the callee mandating the caller's logical flow is a good thing. Imagine a language where an API can explicitly define rules for its callers like "you must have an alternate flow to deal with my return value if it's 0,1,or 2." That would sound crazy, but it's essentially the same as checked exceptions in Java.</p>
<p>Other languages learned from Java's mistake - C# exceptions are all unchecked, for instance.<br />
...<br />
I absolutely agree with you that exceptions are part of the contract. However, IMHO, an API contract should _not_ dictate implementation - either way for that matter. That an exception is part of the contract only goes as far as saying "be _prepared_ to handle this exception," but not "you _must_ handle this exception right here right now."</p>
<p>Again let's use the return value analogy - it's perfectly fine for a contract to say "I might return null so don't be surprised when you see one," but it's rather excessive to say "you must have an if testing my return value and do something differently if it's null."
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/07/17/checked-exceptions-and-alternate-business-flows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet Another Maze Solver: guess I have too much time on hands</title>
		<link>http://www.digizenstudio.com/blog/2007/06/18/yet-another-maze-solver-guess-i-have-too-much-time-on-hands/</link>
		<comments>http://www.digizenstudio.com/blog/2007/06/18/yet-another-maze-solver-guess-i-have-too-much-time-on-hands/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 14:05:27 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/06/18/yet-another-maze-solver-guess-i-have-too-much-time-on-hands/</guid>
		<description><![CDATA[Here goes my version of the maze solver program to the Excellent Interview Question Shane Bell wrote about.  My solution follows the classic "always keep your left hand on a wall" idea. It doesn't guarantee to find the best route, but then it being non-recursive doesn't blow up the stack with a large maze, [...]]]></description>
			<content:encoded><![CDATA[<p>Here goes <a href='http://www.digizenstudio.com/blog/wp-content/uploads/2007/06/mazesolver.java' title='MazeSolver.java'>my version of the maze solver program</a> to the <a href="http://blog.onlysimpler.com/entries/excellent_interview_question.html">Excellent Interview Question</a> Shane Bell wrote about.  My solution follows the classic "always keep your left hand on a wall" idea. It doesn't guarantee to find the best route, but then it being non-recursive doesn't blow up the stack with a large maze, and it at least eliminates all the loops. <img src='http://www.digizenstudio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/06/18/yet-another-maze-solver-guess-i-have-too-much-time-on-hands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The self-calling limitation in Spring-AOP and one unintrusive solution</title>
		<link>http://www.digizenstudio.com/blog/2007/05/29/the-self-calling-limitation-in-spring-aop-and-one-unintrusive-solution/</link>
		<comments>http://www.digizenstudio.com/blog/2007/05/29/the-self-calling-limitation-in-spring-aop-and-one-unintrusive-solution/#comments</comments>
		<pubDate>Wed, 30 May 2007 00:45:52 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[aop]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/05/29/the-self-calling-limitation-in-spring-aop-and-one-unintrusive-solution/</guid>
		<description><![CDATA[Spring-AOP is implemented by creating proxies decorating the target bean. One typical gotcha from using these proxies, for instance, in declarative transaction management, is the proxy can't intercept a call made from one method to another on the same target object (typically a service bean), even though both methods are supposed to be wrapped by [...]]]></description>
			<content:encoded><![CDATA[<p>Spring-AOP is implemented by creating proxies decorating the target bean. One typical gotcha from using these proxies, for instance, in declarative transaction management, is the proxy can't intercept a call made from one method to another on the same target object (typically a service bean), even though both methods are supposed to be wrapped by the proxy.<span id="more-135"></span></p>
<p>One obvious solution to the problem is to always explicitly get the bean reference from the Spring context and then call the method on it, instead of calling the method on 'this'. For example, instead of <code>this.anotherServiceMethod()</code>, do:</p>
<div class="igBar"><span id="ljava-21"><a href="#" onclick="javascript:showPlainTxt('java-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-21">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// get hold of the application context either through</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// a singleton locator or through a private reference, then</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">context.<span style="color: #006600;">getBean</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"aServiceBean"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">anotherServiceMethod</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It's an easy solution, but one that doesn't come without a few nuisances. For instance, it adds to your service bean some compile-time dependencies on Spring classes that wouldn't have been necessary otherwise.</p>
<p>One less intrusive solution I've come up with is a <a href='http://www.digizenstudio.com/blog/wp-content/uploads/2007/05/adviceskippinginjector.java' title='AdviceSkippingInjector.java'><code>AdviceSkippingInjector.java</code></a> that injects the reference to any proxied Spring bean into a property on the "raw" bean, i.e., the object prior to being wrapped in the proxy.</p>
<p>To use it, add a <code>proxiedSelf</code> property to the service bean (it doesn't have to be on any public interface), add this to your context file:</p>
<div class="igBar"><span id="lxml-22"><a href="#" onclick="javascript:showPlainTxt('xml-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-22">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"aService"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"your.proxied.service.Bean"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"ProxySkippingInjector"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.digizen.commons.spring.AdviceSkippingInjector"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"beanProperties"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;map<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"aService"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"proxiedSelf"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/map<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In the map <code>beanProperties</code>, each key is a bean name defined in the context, and the corresponding value a property name on the bean. At run-time, if the <code>AdviceSkippingInjector</code> sees a bean name in its map, it will drill into the proxies, find the reference to the original bean, and inject the reference to the proxy into the original bean's <code>proxiedSelf</code> property.</p>
<p>This solution is unintrusive because the service bean remains unaware of any of the plumbing work. All the wiring is done in the application context. In fact, the service bean isn't even necessarily aware that <code>proxiedSelf</code>, despite the name, points to its "proxied self".</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/05/29/the-self-calling-limitation-in-spring-aop-and-one-unintrusive-solution/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ivy has lots of potential</title>
		<link>http://www.digizenstudio.com/blog/2007/04/09/ivy-has-lots-of-potential/</link>
		<comments>http://www.digizenstudio.com/blog/2007/04/09/ivy-has-lots-of-potential/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 02:14:30 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/04/09/ivy-has-lots-of-potential/</guid>
		<description><![CDATA[Having recently been severely frustrated by that other ambitious Apache project that aims at "making the build process easy", and "providing guidelines for best practices development", etc. - OK, who am I kidding? Yes, I'm referring to maven 2.   - I turned my eyes to Ivy, and, after a couple of week of [...]]]></description>
			<content:encoded><![CDATA[<p>Having recently been severely frustrated by that other ambitious Apache project that aims at "making the build process easy", and "providing guidelines for best practices development", etc. - OK, who am I kidding? Yes, I'm referring to maven 2. <img src='http://www.digizenstudio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  - I turned my eyes to <a href="http://incubator.apache.org/ivy/" rel="_blank">Ivy</a>, and, after a couple of week of using it, found myself comfortable enough to write this to recommend Ivy as an indispensable part in any serious Ant-based build tools arsenal.<span id="more-133"></span></p>
<p>What do I like about Ivy? Well, let me start with the fact that it doesn't try to reinvent Ant, but rather serves as an extension to Ant (and can also run stand-alone outside any Ant context). It is essentially a dependency management engine - it focuses on being a good one at that, and once dependencies are resolved and retrieved, it stays out of the way for the rest of the build process.</p>
<p>Ivy offers a powerful expression language for specifying a variety of version patterns. There can be patterns like "1.4.+", which can be satisfied by any version later than 1.4, "[1.4,)", which means any version of 1.4 or after, or "[1.4,1.9], which selects any version between 1.4 and 1.9, including both.</p>
<p>The concept of "configuration" in Ivy also comes in very handy when you need to categorize the dependencies, and influence how classpaths ought to be assembled according to the different contexts they'll be used in - e.g., I was able to define configurations called "build", "test", "coverage" to deal with dependencies required at build-time, test-time, and test-with-emma-the-coverage-tool-time.</p>
<p>Another strong selling point of Ivy is that it has built-in support to leverage the existing ibiblio maven repositories. Ivy's ibiblio resolver works with maven 1 repository by default, but can be set in "m2compatible" mode with one attribute flip. The more universal URL resolver in Ivy can work with pretty much any repository structure whose paths are defined in patterns. Although for most practical projects, the out-of-box ibiblio support, combined with the cache resolver that tries to resolve artifacts in the local cache first, would suffice very well.</p>
<p>The one caveat I found out, though, is that at the moment the ibilbio resolver doesn't handle the directory listing of some existing maven repository proxy tools, such as maven-proxy and proximity. So the dynamic version resolving (such as range or wildcarded version numbers) feature, relying on the resolver parsing directory listing to discover available versions, won't work when there is a ibiblio resolver points to a proxy server. According to the developers, this issue is definitely on the radar and hopefully will be addressed by the time the next major version (2.0) comes out. Possible workarounds I'm contemplating on include setting up a reverse proxy with an internal apache server, or adding an extra Ivy resolver pointing to the internal repository. I'll try those and report back.</p>
<p>As Ivy has recently been taken under the Apache wings, and become an <a href="http://incubator.apache.org/projects/ivy.html" rel="_blank">Apache Incubator project</a>, I hold high hope on its codebase maturing rapidly and eventually graduates to be yet another great Apache tool. I believe as far as build management is concerned, Ivy offers a great opportunity to leverage and combine the two valuable assets the Java community has built over the years - the mature Ant toolset and the sophisticated ibiblio maven repositories. As Colin Sampaleanu pointed out, <a href="http://blog.exis.com/colin/archives/2005/04/29/decision-to-use-ivy-is-a-no-brainer/" rel="_blank">the decision to use Ivy is a no-brainer</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/04/09/ivy-has-lots-of-potential/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A few thoughts on Yahoo&#8217;s free YUI hosting offer</title>
		<link>http://www.digizenstudio.com/blog/2007/02/28/a-few-thoughts-on-yahoos-free-yui-hosting-offer/</link>
		<comments>http://www.digizenstudio.com/blog/2007/02/28/a-few-thoughts-on-yahoos-free-yui-hosting-offer/#comments</comments>
		<pubDate>Wed, 28 Feb 2007 15:20:31 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[web-design]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/02/28/a-few-thoughts-on-yahoos-free-yui-hosting-offer/</guid>
		<description><![CDATA[YUI has been my favorite AJAX library for two reasons: its unintrusiveness to the server side, and the excellent documentation. It is interesting and encouraging to see Yahoo offer free hosting for YUI. While there are obviously valid reasons for some sites not to use this service (external dependency etc.), the power of yahoo's server [...]]]></description>
			<content:encoded><![CDATA[<p>YUI has been my favorite AJAX library for two reasons: its unintrusiveness to the server side, and the excellent documentation. It is interesting and encouraging to see <a href="http://yuiblog.com/blog/2007/02/22/free-yui-hosting/" rel="_blank">Yahoo offer free hosting for YUI</a>. While there are obviously valid reasons for some sites not to use this service (external dependency etc.), the power of yahoo's server facility, the advanced cache control, and the on-the-fly file size reduction (up to 90% according to the announcement linked) are in no doubt going to be very appealing to many others.<span id="more-130"></span></p>
<p>This did get me thinking, though - and let me preemptively clarify that "Yahoo is evil" is definitely <strong>not</strong> what I'm about to get at. And I truly appreciate this offering as a noble intention and a community-friendly move, rather than any sleek public image stunt. Nevertheless, if we look at it in the whole bigger picture of "where F/OSS is going today", this is yet another instance of a big corporation leveraging its muscle to support an F/OSS project. Regardless of Yahoo's intention, in reality, there is still the feeling of a lesser leveling playground for those other projects without any backing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/02/28/a-few-thoughts-on-yahoos-free-yui-hosting-offer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stronger Java, no sugar please</title>
		<link>http://www.digizenstudio.com/blog/2007/02/27/stronger-java-no-sugar-please/</link>
		<comments>http://www.digizenstudio.com/blog/2007/02/27/stronger-java-no-sugar-please/#comments</comments>
		<pubDate>Tue, 27 Feb 2007 05:14:16 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/02/27/stronger-java-no-sugar-please/</guid>
		<description><![CDATA[I just wanted to expand on Richard Relos's we don't really need closures in Java into a broader argument - syntax sugar is the least of what Java really needs now.
The beauty of Java the Language, IMHO, is its simplicity. Many people, including myself, coming from a C/C++ background immediately appreciate the fact that there [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to expand on Richard Relos's <a href="http://rrelos.net/techblog/?p=255" rel="_blank">we don't really need closures in Java</a> into a broader argument - syntax sugar is the least of what Java really needs now.<span id="more-129"></span></p>
<p>The beauty of Java the Language, IMHO, is its simplicity. Many people, including myself, coming from a C/C++ background immediately appreciate the fact that there is much, much less surprise in code written in Java. Every spoonful of syntax sugar added to the language adds to the conceptual complexity of the language, not linearly, but exponentially, as every new construct has to work well with everyone that's already in there. On the other hand, it only makes things easier <em>superficially</em>. What does a closure gain us?  A few lines of less typing? Or maybe just a few key strokes in any of the modern IDE's these days?</p>
<p>Many people say that closures are easier to learn for beginners than anonymous classes. I wouldn't be so sure. For instance, which one is easier: to explain to a student that that mysterious Foo$1.class is actually generated from a closure which, whilst not being a class conceptually, actually is handled as an anonymous class? or to explain to him that an anonymous class gets compiled into, well, a class?</p>
<p>Furthermore, should everything that makes Java easier to use make into <em>the language</em>? Dependency Injection/IoC Containers have become more and more widely adopted, but that doesn't mean Java should necessarily incorporate Spring or Hivemind's definition syntax, does it?</p>
<p>Some people say syntax sugar is supposed to make Java easier to use, so it can compete with RoR, .Net, etc. I agree to the goal, but not the means. IMHO, the changes that Java, especially enterprise Java, needs in order to go up against Microsoft and RoR/the whole LAMP camp have to be much, much more fundamental than throwing in several sugar cubes. EJB 3 is a good move in that direction, as Java admits that miserable mess happens when the principle of simplicity is forgotten. But there is yet a lot left to be desired, for example, until JVM starts supporting compartmental deployment, i.e., multiple applications running and managed in isolation, there is no hope for Java to become a strong offering in the Web hosting market. Unfortunately, AFAIK, JDK 7 has yet no plans of supporting that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/02/27/stronger-java-no-sugar-please/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Singleton&#8217;s new Tinfoil Hat called &#8220;Don&#8217;t clone me!&#8221;</title>
		<link>http://www.digizenstudio.com/blog/2007/02/26/singletons-new-tinfoil-hat-called-dont-clone-me/</link>
		<comments>http://www.digizenstudio.com/blog/2007/02/26/singletons-new-tinfoil-hat-called-dont-clone-me/#comments</comments>
		<pubDate>Tue, 27 Feb 2007 01:34:03 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/02/26/singletons-new-tinfoil-hat-called-dont-clone-me/</guid>
		<description><![CDATA[I have been interviewing a number of folks to help filling up some Java developer positions. More than one of them (mind you, referred through different sources) told me, as part of the answer to "how would you implement a singleton?", that I must override clone() to make sure my previous singleton wouldn't get, well, [...]]]></description>
			<content:encoded><![CDATA[<p>I have been interviewing a number of folks to help filling up some Java developer positions. More than one of them (mind you, referred through different sources) told me, as part of the answer to "how would you implement a singleton?", that I <em>must</em> override clone() to make sure my previous singleton wouldn't get, well, cloned.  And they all told me that they learned it "somewhere," only unsure where that "somewhere" was.</p>
<p>I did some googling and actually found a couple of "Java tutorial" sites that tell people to override clone() as part of a "standard" singleton implementation. I won't be linking to any of those sites for the obvious reason of not wanting to bump up their google rankings. And I'm just gonna post some kind of "counter-jinx" here:</p>
<p>If you are preparing for an interview, and happen to stumble upon this blog, please, please remember that Object.clone() by default throws CloneNotSupportException if the class does not implement Cloneable, and I don't really think you would want to tell your interviewer that you wish to have your singleton class implementing Cloneable. So, no, it's completely unnecessary to override the clone() method in a singleton implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/02/26/singletons-new-tinfoil-hat-called-dont-clone-me/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programmatically Build a Spring Application Context</title>
		<link>http://www.digizenstudio.com/blog/2007/01/14/programmatically-build-a-spring-application-context/</link>
		<comments>http://www.digizenstudio.com/blog/2007/01/14/programmatically-build-a-spring-application-context/#comments</comments>
		<pubDate>Sun, 14 Jan 2007 19:56:55 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/01/14/programmatically-build-a-spring-application-context/</guid>
		<description><![CDATA[The new BeanDefinitionBuilder class added in Spring 2.0 allows an XML-less way to build application contexts programmatically. Can be very useful for, say, creating quick testing setups in one of those script languages.]]></description>
			<content:encoded><![CDATA[<p>The new <a href="http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/beans/factory/support/BeanDefinitionBuilder.html" rel="_blank">BeanDefinitionBuilder</a> class added in Spring 2.0 allows an XML-less way to build application contexts programmatically. Can be very useful for, say, creating quick testing setups in one of those script languages.<span id="more-126"></span></p>
<div class="igBar"><span id="ljava-23"><a href="#" onclick="javascript:showPlainTxt('java-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-23">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">GenericApplicationContext ctx = <span style="color: #000000; font-weight: bold;">new</span> GenericApplicationContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BeanDefinitionBuilder builderA = BeanDefinitionBuilder</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; .<span style="color: #006600;">rootBeanDefinition</span><span style="color: #66cc66;">&#40;</span>BeanA.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; .<span style="color: #006600;">addPropertyValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"name"</span>, <span style="color: #ff0000;">"Joe"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ctx.<span style="color: #006600;">registerBeanDefinition</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bean-a"</span>, builderA.<span style="color: #006600;">getBeanDefinition</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BeanDefinitionBuilder builderB = BeanDefinitionBuilder.<span style="color: #006600;">rootBeanDefinition</span><span style="color: #66cc66;">&#40;</span>BeanB.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; .<span style="color: #006600;">addPropertyReference</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"refA"</span>, <span style="color: #ff0000;">"bean-a"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ctx.<span style="color: #006600;">registerBeanDefinition</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bean-b"</span>, builderB.<span style="color: #006600;">getBeanDefinition</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ctx.<span style="color: #006600;">getBean</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bean-b"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The sample code above creates two bean definitions, the second one referencing the first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/01/14/programmatically-build-a-spring-application-context/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Build Subversion 1.4.2 in Ubuntu Edgy</title>
		<link>http://www.digizenstudio.com/blog/2007/01/06/build-subversion-142-in-ubuntu-edgy/</link>
		<comments>http://www.digizenstudio.com/blog/2007/01/06/build-subversion-142-in-ubuntu-edgy/#comments</comments>
		<pubDate>Sun, 07 Jan 2007 04:54:40 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2007/01/06/build-subversion-142-in-ubuntu-edgy/</guid>
		<description><![CDATA[The standard Ubuntu repository has only 1.3.2. Higepon's tips worked very well. In addition to the packages listed, I had to also install 'expat-dev'.
]]></description>
			<content:encoded><![CDATA[<p>The standard Ubuntu repository has only 1.3.2. <a href="http://higepon.blogspot.com/2006/12/install-subversion-142-to-ubuntu-edgy.html" rel="_blank">Higepon's tips</a> worked very well. In addition to the packages listed, I had to also install 'expat-dev'.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2007/01/06/build-subversion-142-in-ubuntu-edgy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arrow Operator in Java 7? Hmm&#8230;</title>
		<link>http://www.digizenstudio.com/blog/2006/12/12/arrow-operator-in-java-7-hmm/</link>
		<comments>http://www.digizenstudio.com/blog/2006/12/12/arrow-operator-in-java-7-hmm/#comments</comments>
		<pubDate>Wed, 13 Dec 2006 02:44:52 +0000</pubDate>
		<dc:creator>Jing Xue</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.digizenstudio.com/blog/2006/12/12/arrow-operator-in-java-7-hmm/</guid>
		<description><![CDATA[(Traceback to Weiqi Gao's post)
Considering "." is used as the accessor universally for all properties and methods in C#, as well as most script languages Java 6 has just made easier supporting, I for one would be very interested in learning the rationale behind using -> for property access - it's got to be a [...]]]></description>
			<content:encoded><![CDATA[<p>(Traceback to <a href="http://www.weiqigao.com/blog/2006/12/07/you_wont_believe_this_but_the_arrow_operator_is_coming_to_java_7.html">Weiqi Gao's post</a>)<br />
Considering "." is used as the accessor universally for all properties and methods in C#, as well as most script languages Java 6 has just made easier supporting, I for one would be very interested in learning the rationale behind using -> for property access - it's got to be a conscious decision.</p>
<p>Another thing that had some coffee-spilling effect on me was the "Closures, Lambdas and friends" part. On the first look, I thought they were adding "friend" support in Java 7 (as in C++), which would have been a good thing. <img src='http://www.digizenstudio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.digizenstudio.com/blog/2006/12/12/arrow-operator-in-java-7-hmm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

