<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>null</title>
	<atom:link href="http://jbaruch.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jbaruch.wordpress.com</link>
	<description>NullPointerException, probably...</description>
	<lastBuildDate>Tue, 15 Nov 2011 16:09:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jbaruch.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>null</title>
		<link>http://jbaruch.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jbaruch.wordpress.com/osd.xml" title="null" />
	<atom:link rel='hub' href='http://jbaruch.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Unified (as much as possible) Logging Using SLF4J</title>
		<link>http://jbaruch.wordpress.com/2011/06/22/unified-logging-using-slf4j/</link>
		<comments>http://jbaruch.wordpress.com/2011/06/22/unified-logging-using-slf4j/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 06:40:25 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[slf4j]]></category>
		<category><![CDATA[logback]]></category>
		<category><![CDATA[jcl]]></category>
		<category><![CDATA[jul]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/?p=34</guid>
		<description><![CDATA[Integrating, integrating, integrating. That&#8217;s what we do in Java enterprise development. Persisting objects with Hibernate wrapped by JPA using C3Po (or JTA?) (or MongoDB over Morphia?), processed with JBMP, created by JAXB (jackson-json?) from JAX-RS scheduled by Quartz &#8230; (a few dozen frameworks later) &#8230; all this glued with Spring (or Guice?) deployed on Jetty [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=34&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Integrating, integrating, integrating. That&#8217;s what we do in Java enterprise development. Persisting objects with Hibernate wrapped by JPA using C3Po (or JTA?) (or MongoDB over Morphia?), processed with JBMP, created by JAXB (jackson-json?) from JAX-RS scheduled by Quartz &#8230; (a few dozen frameworks later) &#8230; all this glued with Spring (or Guice?) deployed on Jetty (or Tomcat, JBoss, Resin?) into cluster by Terracotta (or Hadoop, GigaSpaces, JBoss cache, Infinispam?). Ah, and all this built using <span style="text-decoration:line-through;">Maven</span> Gradle with Artifactory on Jenkins. I sure forgot ½ of the frameworks we constantly use.</p>
<p>Generally we don&#8217;t mind much about the internals of the frameworks we use (as long as they are good) &#8211; the whole encapsulation stuff is the last <a href="http://tech.puredanger.com/2010/02/25/questioning-oo/" target="_blank">undoubted</a> good thing. But except for the API (part of which is the configuration) frameworks have another user-facing end – the logging. When we build a <strong>system</strong> we want it to behave as one system – single configuration from one end, and single log from another (break it to different files, if you wish, but it should still be a unified logging system).</p>
<p>The reality is that there is no standard de-facto for logging. The standard de-jure &#8211; <a href="http://java.sun.com/javase/6/docs/technotes/guides/logging/" target="_blank">JUL</a>, is not very popular because of its lack of functionality (compared to alternatives) and its suboptimal performance. And then there is <a href="http://logging.apache.org/log4j/" target="_blank">Log4J</a>, which almost became standard, but did not. And there is <a href="http://logback.qos.ch/" target="_blank">logback</a>, which is a Log4J <a href="http://logback.qos.ch/reasonsToSwitch.html">trashover</a>, and there are facades (<a href="http://commons.apache.org/logging/" target="_blank">JCL</a> and <a href="http://www.slf4j.org/" target="_blank">SLF4J</a>), which try to unite all this zoo, and some others, which you have probably never heard of, like <a href="http://www.syslog4j.org/" target="_blank">syslog4j</a>*, <a href="http://www.theobjectguy.com/javalog/" target="_blank">logging framework by the Object Guy</a>, <a href="http://java-source.net/open-source/logging" target="_blank">jLo, MonoLog, Lumberjack, Houston, JTraceDump, qflog, LN2, TracingClassLoader, SMTPHandler, Log4Ant, Simple Log, Log Bridge, Craftsman Spy, Pencil, JDLabAgent, Trace Log, JDBC Logger, LimpidLog and Microlog</a>.</p>
<p>Let it be, you’d say – why not have many logging tools, which are good and diverse! Well, the problem, as I’ve already mentioned, is that they leak out of the frameworks. Their diverse configuration leaks from one end, while their diverse output from another. Spring uses Log4J over JCL. So does Hibernate. Jetty uses Logback over SLF4J. Some (like Terracotta modules) use plain Log4J, Jersey uses JUL.  This means we end up with 5 separate configurations (Log4J, SLF4J, Logback, JCL and JUL) and 3 different types of log files (Log4j, Logback and JUL). What a system!</p>
<p>To make the long story short &#8211; How can we achieve the desired consolidation? Clearly, we need a facade. There are two most commonly used &#8211; SLF4J and JCL. JCL is known for its <a href="http://articles.qos.ch/classloader.html" target="_blank">classloader hell</a>, SLF4J is newer, better performing, smarter, simplier to use and generally provides better quality for the same buck (well, no buck &#8211; both are open source, of course), so we&#8217;ll stick to it. SLF4J is an adapter &#8211; thin layer of API to and from different logging implementations. Yap, both ways. It means with SLF4J we can use JUL API on top and log using Log4J in the bottom!</p>
<p>First we need to pick an actual logger. Log4j was considered the best choice up until recently (2006) when Ceki Gülcü decided he needed a fresh start and rewrote from scratch a new Java logging framework, just<a href="http://xhab.blogspot.com/2007/03/new-logging-experience.html" target="_blank"> better than log4j</a>, called Logback. We can give it a try as our underlying logging implementation (we can switch in a moment, as we are using  good facade, remember?).</p>
<p>So, here&#8217;s what we have to do:</p>
<ol>
<ol>
<li>Establish our own good logging:
<ol>
<ol>
<li>Add Logback to our classpath</li>
<li>Add SLF4J API to our classpath</li>
</ol>
</ol>
<p>Done here. Now our own brand new code will use top-notch logging.</li>
<li>Now for the tricky part. Let&#8217;s make the example stack I listed above taking configuration from one source (our config files) and writing to one target (files, listed in our configuration)</li>
<ol>
<li>All the tools using SLF4J will just work. That includes dozen of Apache projects, inc. Camel and Mina, some SpringSource projects and <a href="http://www.slf4j.org/" target="_blank">many others</a>.</li>
<li>Now let&#8217;s start rolling with all the rest. This is how you do it (click to enlarge):<br />
<a href="http://www.slf4j.org/images/bridging.png"><img class="alignnone" title="Bridging architecture" src="http://www.slf4j.org/images/bridging.png" alt="Bridging architecture" width="297" height="162" /></a></li>
<ol>
<li>Jakarta Commons Logging:</li>
<ol>
<li>Remove commons-logging.jar from your classpath. Usually, it is transitive dependency from the framework, so you need to instruct your build tool on how to do it. What a lucky coincidence, I just wrote <span style="text-decoration:line-through;">short</span> and instructive <a title="Banning Transitive Dependencies With Maven2/3, Gradle and Ivy" href="http://jbaruch.wordpress.com/2011/06/22/banning-transitive-dependencies-with-maven23-gradle-and-ivy/">blog post</a> about how to do it!</li>
<li>Add jcl-over-slf4j.jar instead. It contains alternative commons-logging API implementation, so the code will run just fine.</li>
</ol>
<li>Log4J:</li>
<ol>
<li>Same goes here! Remove log4j.jar from your classpath (Again, it would usually be a transitive dependency from the framework, look <a title="Banning Transitive Dependencies With Maven2/3, Gradle and Ivy" href="http://jbaruch.wordpress.com/2011/06/22/banning-transitive-dependencies-with-maven23-gradle-and-ivy/">here</a>).</li>
<li>Add log4j-over-slf4j.jar instead. It contains alternative log4j API implementation, so the code will run just fine.</li>
</ol>
<li>JUL:</li>
<ol>
<li>Well, you can&#8217;t remove JUL from classpath (it&#8217;s a part of the JRE, dude). For the same reason SLF4J can&#8217;t reimplement JUL&#8217;s API.</li>
<li>Add jul-to-slf4j.jar. It will translate java.util.logging.LogRecord objects into their SLF4J equivalent.</li>
<li>Install <a href="http://www.slf4j.org/api/org/slf4j/bridge/SLF4JBridgeHandler.html">SLF4JBridgeHandler</a> and <a href="http://logback.qos.ch/manual/configuration.html#LevelChangePropagator">LevelChangePropagator</a>.</li>
<li>Expect 20% decrease in performance (so use it wisely).</li>
</ol>
</ol>
</ol>
</ol>
</ol>
<p><strong>All done</strong>. Now both our code and all the 3rd paries configured from single source and write to single target. Hooray!</p>
<p><small>* syslog4j claims it is cross-platform. Well,  I&#8217;ll just quote: &#8220;<strong>Is Syslog4j cross-platform?</strong> Yes! Syslog4j UDP/IP and TCP/IP clients should work in any typical Java JRE environment.&#8221;</small></p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/frameworks/'>Frameworks</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/jcl/'>jcl</a>, <a href='http://jbaruch.wordpress.com/tag/jul/'>jul</a>, <a href='http://jbaruch.wordpress.com/tag/log/'>log</a>, <a href='http://jbaruch.wordpress.com/tag/log4j/'>log4j</a>, <a href='http://jbaruch.wordpress.com/tag/logback/'>logback</a>, <a href='http://jbaruch.wordpress.com/tag/slf4j/'>slf4j</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=34&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2011/06/22/unified-logging-using-slf4j/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>

		<media:content url="http://www.slf4j.org/images/bridging.png" medium="image">
			<media:title type="html">Bridging architecture</media:title>
		</media:content>
	</item>
		<item>
		<title>Banning Transitive Dependencies With Maven2/3, Gradle and Ivy</title>
		<link>http://jbaruch.wordpress.com/2011/06/22/banning-transitive-dependencies-with-maven23-gradle-and-ivy/</link>
		<comments>http://jbaruch.wordpress.com/2011/06/22/banning-transitive-dependencies-with-maven23-gradle-and-ivy/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 06:39:24 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[ivy]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[maven3]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/?p=125</guid>
		<description><![CDATA[Oh, you are using build tool with dependency management? Good! Be it Maven2/3, Gradle or Ivy, your life as devops or developer is much easier. Until you hit it. The evil transitive dependency. How can it be evil you ask? When the classes in it clash with the classes you really need.  Here&#8217;s some use-cases: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=125&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Oh, you are using build tool with dependency management? Good! Be it Maven2/3, Gradle or Ivy, your life as devops or developer is much easier. Until you hit it. The evil transitive dependency. How can it be evil you ask? When the classes in it clash with the classes you really need.  Here&#8217;s some use-cases:</p>
<ol>
<li>Same dependency, different jar names, two examples here:</li>
<ol>
<li>The Jakarta Commons renaming effort: <a href="http://repo1.maven.org/maven2/commons-io/commons-io/1.3.2/">commons-io:commons-io:1.3.2</a> and <a href="http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/">org.apache.commons:common-io:1.3.2</a></li>
<li>The Spring Framework artifacts naming convention alternatives: <a href="http://repo1.maven.org/maven2/org/springframework/">spring-beans, spring-context, etc</a> in repo1 versus <a href="http://ebr.springsource.com/repository/app/bundle/detail?name=org.springframework.beans">org.springframework.beans, org.springframework.context, etc</a>in
<div id="site-name">SpringSource EBR.</div>
</li>
</ol>
<li>Different packaging of the sample classes, many examples here:</li>
<ol>
<li>OSGi repackagings:<a href="http://repo1.maven.org/maven2/asm/asm/3.2/"> asm:asm:3.2</a> and <a href="http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.objectweb.asm&amp;version=3.2.0">org.objectweb.asm:com.springsource.org.objectweb.asm:3.2.0</a></li>
<li>Modularization of Spring 2.5.6: <a href="http://repo1.maven.org/maven2/org/springframework/spring/2.5.6/">as single jar</a> and as <a href="http://repo1.maven.org/maven2/org/springframework/">spring-whatever multiple modules</a></li>
<li>Xerces and Xalan are included in JDK since 1.5. They are still present as transitive dependencies in all the tools which support JDK 1.4.</li>
<li>Alternative packagings with and without dependencies: <a href="http://repo1.maven.org/maven2/cglib/cglib/">cglib:cgli</a>b and <a href="http://repo1.maven.org/maven2/cglib/cglib-nodep/">cglib:cglib-nodep</a></li>
<li>Project merges like <a href="http://repo1.maven.org/maven2/com/google/collections/google-collections/">Google collections</a>, which are now included in <a href="http://repo1.maven.org/maven2/com/google/guava/guava/">Google Guava</a></li>
</ol>
<li>Deliberately reimplemented interfaces, for example for <a title="Unified (as much as possible) logging using SLF4J" href="http://jbaruch.wordpress.com/2011/06/22/unified-logging-using-slf4j/">bridging legacy APIs to new implementation, such as in SLF4J</a>.</li>
<li>Your patches for 3rd-party tools.</li>
</ol>
<p>All those may end up with 2 or more classes with the same name in the classpath. Why it is bad? Java class identifier consists of fully-qualified class name and the classloader that loaded it, so if two classes with the same name reside in same classpath JVM considers them to be the same class, and only one of them will be loaded. Which one? The first classloader encounters. Which one will it be? You have no idea.<br />
When the duplicated classes are exactly the same, you will never notice. But if the classes are different, you&#8217;ll start getting runtime exceptions, such as NoSuchMethodError, NoClassDefFoundError and friends. That&#8217;s because other classes expect for find one API, but encounter another one &#8211; wrong class was loaded first. Not fun.</p>
<p>Now, when you know how evil they are, let&#8217;s take those bastards down!</p>
<h4>Maven 2/3</h4>
<p>There is no simple way (Maven&#8217;s tagline) to exclude some dependency from all the scopes. I&#8217;ll show two cases &#8211; manual exclusion and working with IntelliJ IDEA:</p>
<ol>
<ol>
<li>Stage 1: exclude all the banned dependencies one by one:</li>
<ol>
<li>Manually edit Maven&#8217;s poms</li>
<ol>
<li>For each evil dependency:</li>
<li>Find which top-level dependency brings the evil transitive hitcher with it. This is done by using Maven Dependency Plugin:
<pre>mvn dependency:tree -Dincludes=commons-logging:commons-logging</pre>
</li>
<li>You&#8217;ll get something like this:
<pre>[INFO] com.mycompany.myproduct:rest-client:1.0
[INFO] \- org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile
[INFO]    \- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO]       \- commons-logging:commons-logging:jar:1.1.1:compile</pre>
</li>
<li>Go to the pom.xml with your dependency management (you use dependency management, don&#8217;t you? If you don&#8217;t, don&#8217;t tell anyone, <a href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management">go and start using it</a>) find spring-webmvc dependency and add an exclusion to it:
<pre><span style="color:#800000;font-weight:normal;font-style:normal;">1 </span>    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">dependency</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">2 </span>    	<span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">groupId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">org.</span><span style="color:#000000;font-weight:bold;font-style:normal;">springframework</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">groupId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3 </span>    	<span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">artifactId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">spring-</span><span style="color:#000000;font-weight:bold;font-style:normal;">webmvc</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">artifactId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">4 </span>    	<span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">version</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">3.0.5.RELEASE</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">version</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">5 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclusions</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">6 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclusion</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">7 </span>                <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">artifactId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">commons-logging</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">artifactId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">8 </span>                <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">groupId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">commons-logging</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">groupId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">9 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclusion</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">10 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclusions</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">11 </span>    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">dependency</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span></pre>
</li>
</ol>
<li>Working with IntelliJ IDEA:<br />
<a href="http://jbaruch.files.wordpress.com/2011/06/2011-06-21_131016.png"><img class="alignnone size-thumbnail wp-image-129" title="IntelliJ IDEA Maven Dependencies" src="http://jbaruch.files.wordpress.com/2011/06/2011-06-21_131016.png?w=145&#038;h=150" alt="IntelliJ IDEA Maven Dependencies" width="145" height="150" /></a></li>
<ol>
<ol>
<li>Open Maven Dependencies Graph.</li>
<li>Filter it by the dependency you are looking for.</li>
<li>Select it and press Shift-Delete.</li>
</ol>
</ol>
</ol>
<li>Good job! Your nailed them down in the current version of your build. But what happens when someone adds a new 3rd party dependency and brings some bad stuff with it as transitives? You need to protect your build from this scenario. So, stage 2: Fail the build if one of the banned dependencies ever added to the build with <a href="http://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html">Maven Enforcer Plugin</a>. Add the plugin to your root project pom:
<pre style="color:#800000;font-weight:normal;font-style:normal;"><span style="color:#800000;font-weight:normal;font-style:normal;">1 </span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">project</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">2 </span>  <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">build</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3 </span>    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">plugins</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">4 </span>      <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">plugin</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">5 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">groupId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">org.apache.maven.plugins</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">groupId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">6 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">artifactId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">maven-enforcer-plugin</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">artifactId</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">7 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">version</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">1.0</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">version</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">8 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">executions</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">9 </span>          <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">execution</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">10 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">id</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">enforce-banned-dependencies</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">id</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">11 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">goals</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">12 </span>              <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">goal</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">enforce</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">goal</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">13 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">goals</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">14 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">configuration</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">15 </span>              <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">rules</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">16 </span>                <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">bannedDependencies</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">17 </span>                  <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">excludes</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">18 </span>                    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclude</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">commons-logging</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclude</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">19 </span>                    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclude</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">cglib:cglib</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclude</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">20 </span>                  <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">excludes</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">21 </span>                <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">bannedDependencies</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">23 </span>              <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">rules</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">24 </span>              <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">fail</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span><span style="color:#000000;font-weight:bold;font-style:normal;">true</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">fail</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">25 </span>            <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">configuration</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">26 </span>          <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">execution</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">27 </span>        <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">executions</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">28 </span>      <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">plugin</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">29 </span>    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">plugins</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">30</span> <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">build</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">31 </span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">project</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span></pre>
</li>
<li>As I mentioned, using the Enforcer plugin won&#8217;t exclude the unwanted dependencies, it only will fail the build. Once that happened (and trust me, it will), you need to go and exclude them manually, as described in Stage 1 above.</li>
</ol>
</ol>
<p>And we are done with Maven. Not fun? Switch your build tool!</p>
<h4>Ivy</h4>
<p>Well, comparing to Maven it&#8217;s emabrassing how easy is to add global exclusion in Ivy. All you need to do is add exclude tag, and it will do the job for all the transitive dependencies, both in current and future use:</p>
<pre><span style="color:#800000;font-weight:normal;font-style:normal;">1 </span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">dependencies</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">2 </span>    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">dependency </span><span style="color:#0000ff;background-color:#efefef;font-weight:bold;font-style:normal;">org=</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">"org.</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">" </span><span style="color:#0000ff;background-color:#efefef;font-weight:bold;font-style:normal;">name=</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">"spring-</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">webmvc</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">"</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3 </span><span style="color:#0000ff;background-color:#efefef;font-weight:bold;font-style:normal;">rev=</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">"3.0.5.RELEASE" </span><span style="color:#0000ff;background-color:#efefef;font-weight:bold;font-style:normal;">conf=</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">"compile-&gt;default"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">4 </span>    <span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">exclude </span><span style="color:#0000ff;background-color:#efefef;font-weight:bold;font-style:normal;">org=</span><span style="color:#008000;background-color:#efefef;font-weight:bold;font-style:normal;">"commons-logging"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">5 </span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-weight:bold;font-style:normal;">dependencies</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span></pre>
<p>Done.</p>
<h4>Gradle</h4>
<p>Since Gradle uses Ivy under the hood, here comes the same ease, but even groovier:</p>
<pre><span style="color:#800000;font-weight:normal;font-style:normal;">1 </span>    <span style="color:#000000;font-weight:normal;font-style:normal;">configurations</span> {
<span style="color:#800000;font-weight:normal;font-style:normal;">2 </span>        <span style="color:#000000;font-weight:normal;font-style:normal;">all</span>*.exclude module: <span style="color:#008000;font-weight:bold;font-style:normal;">'commons-logging'</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3 </span>        <span style="color:#000000;font-weight:normal;font-style:normal;">all</span>*.exclude group: <span style="color:#008000;font-weight:bold;font-style:normal;">'cglib'</span>, module: <span style="color:#008000;font-weight:bold;font-style:normal;">'cglib-nodep'</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">4 </span>    }</pre>
<p><strong>That&#8217;s all!</strong> Now your code is bullet-proof from classloading conflicts and you can do nasty class-replacing stuff, for <a title="Unified (as much as possible) logging using SLF4J" href="http://jbaruch.wordpress.com/2011/06/22/unified-logging-using-slf4j/">logging</a> or pleasure.</p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/build/'>Build</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/gradle/'>gradle</a>, <a href='http://jbaruch.wordpress.com/tag/ivy/'>ivy</a>, <a href='http://jbaruch.wordpress.com/tag/maven2/'>maven2</a>, <a href='http://jbaruch.wordpress.com/tag/maven3/'>maven3</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=125&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2011/06/22/banning-transitive-dependencies-with-maven23-gradle-and-ivy/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>

		<media:content url="http://jbaruch.files.wordpress.com/2011/06/2011-06-21_131016.png?w=145" medium="image">
			<media:title type="html">IntelliJ IDEA Maven Dependencies</media:title>
		</media:content>
	</item>
		<item>
		<title>PAX 2010</title>
		<link>http://jbaruch.wordpress.com/2010/12/06/pax-2010/</link>
		<comments>http://jbaruch.wordpress.com/2010/12/06/pax-2010/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 12:50:05 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[nfjs]]></category>
		<category><![CDATA[pax2010]]></category>
		<category><![CDATA[project automation experience 2010]]></category>

		<guid isPermaLink="false">http://blog.sadogursky.com/?p=106</guid>
		<description><![CDATA[Just back from Project Automation Experience 2010. Guess what? It was awesome! Here&#8217;s my summary: General: The conference was combined with Rich Web Experience 2010, which probably, was the right thing to do for the first ever project automation seminar. It was announced 2 months ago, bringing 52 registrants (out of ~400 total for both events). Pretty [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=106&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just back from <a href="http://projectautomationexperience.com">Project Automation Experience 2010</a>.</p>
<p>Guess what? It was awesome!</p>
<p>Here&#8217;s my summary:</p>
<h3>General:</h3>
<p>The conference was combined with Rich Web Experience 2010, which probably, was the right thing to do for the first ever project automation seminar. It was announced 2 months ago, bringing 52 registrants (out of ~400 total for both events). Pretty impressive for such a short notice on such a narrow subject. The organization was fantastic, everything felt well-planned and well-orchestrated. It was my second <a href="http://www.nofluffjuststuff.com/home/main">NFJS</a> conference, and like with the first one, they delivered!</p>
<h3>Sessions:</h3>
<p>The first speaker in the conference was the one and only Douglas Crockford in his notorious <a href="http://video.yahoo.com/watch/529579/2724346">Quality talk</a>. Top quality (pun intended) &#8211; funny, entertaining, and touching the right points. Bottom line &#8211; read <a href="http://www.amazon.com/Mythical-Man-Month-Engineering-Anniversary-ebook/dp/B000OZ0N6M">The Mythical Man-Month</a> and <a href="http://www.literateprogramming.com/">Literate Programming</a>.</p>
<p>Yet another <a href="https://prezi.com/secure/90f1d01e0fe98653691efa6a56221c2e4a72ee01/">keynote</a> was devoted to actually Project Automation. <a href="http://gradle.org">Hans Dockter</a> laid down his vision on the topic, the idea being &#8211; we are entering very interesting times, better understanding of the needs combining with the right tools will enable us whole new level of project automation, way beyond what we are used to today.</p>
<p>Lots of fun and enriching talks, like <a href="http://www.augusttechgroup.com/tim/blog/">Tim Berglund</a>&#8216;s <a href="http://www.slideshare.net/tlberglund/complexity-theory-and-software-development">Complexity Theory and Software Development</a> or an experts panel, moderated by <a href="http://www.tedneward.com/">Ted Neward</a> (who honestly tried to recall who I was and where did we met), and tons of useful and deep sessions and workshops, just to name a few: <a href="http://blogs.jfrog.org/">Fred</a>&#8216;s modularity and smart BRMs talks, Kohsuke&#8217;s updated <a href="http://vimeo.com/13581660">Doing More with Hudson</a>, Git, Sonar and Liquibase sessions from <a href="http://denverdev.blogspot.com/">Matthew McCullough</a>, <a href="http://www.sonarsource.org/author/oliviergaudin/">Olivier Gaudin</a> and <a href="http://www.augusttechgroup.com/tim/blog/">Tim Berglund</a>. The integration with Rich Web Experience gave the participans the opportunity to mix and match the sessions, and there was a lot of stuff to attend &#8211; HTML5, CSS3, Flash, iOS and Android development, Grails, Wicket and what&#8217;s not! 10 parallel sessions in any given time, now go choose one!</p>
<h3>The sessions I gave:</h3>
<p>First of all, it was my first speaking experience outside of Israel. I think I did well. At least the feedbacks say so <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The high speaker:attendee ratio produced small classes with live interaction, I loved it. As I suspected, 90 minutes are too long, looks like 60 minutes is my favorite format, but I managed to keep the audience awake <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here are my sessions:</p>
<ul>
<li><a href="http://prezi.com/hyyrityxmv5f/maven-2-gradle/">Maven 2 Gradle</a> how to move away from Maven2 to Gradle (using <a title="Maven2 to Gradle Convertor" href="http://blog.sadogursky.com/2010/02/23/maven2-to-gradle-convertor/">gradle2maven</a>, <a title="Maven2 to Gradle Convertor - Take II" href="http://blog.sadogursky.com/2010/10/11/maven2-to-gradle-convertor-take-2/">maven-metadata plugin</a> or even manually). Demo included converting the whole Artifactory project to Gradle.</li>
<li><a href="http://prezi.com/kxhwh7liugoa/java-build-automation-tools-jungle/">Java Build Tools Jungle</a> &#8211; overview the tons of Java build tools. Winners are (in that order): Gralde, Buildr, SBT.</li>
</ul>
<p>By the way, <a href="http://prezi.com">Prezi</a> rocks, as usual.</p>
<p>My next goal &#8211; speaking in a bigger seminar around spring 2011, probably on different topic, more relevant to my new job.</p>
<h3>Florida:</h3>
<p>December 1st &#8211; 30ºC, sun and ocean. <a href="http://www.flickr.com/photos/nshontz/5220491077/">That&#8217;s</a> a typical room view. No additional comments needed, I guess.</p>
<p>Everglades and alligators rock too. It looks like <a href="http://www.smartdestinations.com/images/blog_images/2008/01/miami-everglades.jpg">this</a>.</p>
<div id="_mcePaste" class="mcePaste" style="position:absolute;left:-10000px;top:100px;width:1px;height:1px;">
<h2 class="shortBio" style="font-family:Georgia, 'Times New Roman', Times, serif;color:#000000;font-weight:normal;font-size:1em;line-height:1.2em;background-image:initial;background-attachment:initial;background-color:#cfcfcf;border-top-width:1px;border-top-style:dotted;border-top-color:#000000;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:#000000;background-position:initial initial;background-repeat:initial initial;margin:0 0 5px;padding:5px 0 5px 10px !important;"><a style="color:#efce52;text-decoration:none;font-weight:bold;margin:0;padding:0;" href="http://projectautomationexperience.com/conference/fort_lauderdale/2010/11/speakers/olivier_gaudin">Olivier Gaudin</a></h2>
</div>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/build/'>Build</a>, <a href='http://jbaruch.wordpress.com/category/presentation/'>presentation</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/build-2/'>build</a>, <a href='http://jbaruch.wordpress.com/tag/gradle/'>gradle</a>, <a href='http://jbaruch.wordpress.com/tag/nfjs/'>nfjs</a>, <a href='http://jbaruch.wordpress.com/tag/pax2010/'>pax2010</a>, <a href='http://jbaruch.wordpress.com/tag/project-automation-experience-2010/'>project automation experience 2010</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=106&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/12/06/pax-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
		<item>
		<title>Maven2 to Gradle Convertor &#8211; Take II</title>
		<link>http://jbaruch.wordpress.com/2010/10/11/maven2-to-gradle-convertor-take-2/</link>
		<comments>http://jbaruch.wordpress.com/2010/10/11/maven2-to-gradle-convertor-take-2/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 08:27:39 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[project automation experience 2010]]></category>

		<guid isPermaLink="false">http://blog.sadogursky.com/?p=96</guid>
		<description><![CDATA[Well, it&#8217;s time to another solution for something that I see as the biggest absent feature of Gradle - decent migration tool from Maven2. Gradle provides some cool Maven2 integration features &#8211; you can use Maven repositories, Gradle (well, Ivy inside Gradle) understand your dependencies&#8217; poms in terms of transitive dependencies, you can even generate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=96&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, it&#8217;s time to another solution for something that I see as the biggest absent feature of <a href="http://gradle.org/" target="_blank">Gradle </a>- decent migration tool from Maven2.  Gradle <a href="http://gradle.org/maven_plugin.html" target="_blank">provides </a>some cool Maven2 integration features &#8211; you can use Maven repositories, Gradle (well, Ivy inside Gradle) understand your dependencies&#8217; poms in terms of transitive dependencies, you can even generate pom for your artifact and deploy it to Maven repo, but what about the build itself? For now it should it be trashed over and rewritten completely. That is a show-stopper for a lot of projects. They worked so hard to make their Maven work (you know what I mean&#8230; Maven == working hard), and now I have to say them to just throw it away and rewrite? No way!  Some time ago I took @psynikal&#8217;s script for generating Gradle like dependencies from Maven like ones and improved it a bit to generate usable Gradle build file out of pom. The full story is <a href="http://blog.sadogursky.com/2010/02/23/maven2-to-gradle-convertor/" target="_blank">here</a>. That solution, while definitely is better than void is far from being perfect for number of reasons:</p>
<ol>
<li>It is fragile.</li>
<li>It uses maven-help-plugin. Did I say fragile?</li>
<li>Changes in pom.xml aren&#8217;t reflected in your build &#8211; you need to regenerate the gradle build files (writing them over, destroying all changes you made &#8211; the script isn&#8217;t perfect in that sense).</li>
<li>Probably some annoying bugs.</li>
</ol>
<p>Now it&#8217;s time for something more serious &#8211; the m2metadata plugin. In an essence, it takes metadata from Maven&#8217;s Project Object Model and builds Gradle project out of it.</p>
<p>More specifically it does the following:</p>
<ol>
<li>Ask Maven to parse poms and settings xmls as it does during regular Maven build.</li>
<li>Set group, version and status (snapshot/release) for Gradle project.</li>
<li>Apply Gradle plugins according to packaging (jar -&gt; java, war -&gt; war). Currently those two are the only supported, but more are coming.</li>
<li>Get some metadata from well-known Maven plugins and configure Gradle plugins with it. This step currently includes setting Java compiler level and configuring sources and resources directories.</li>
<li>Add repositories.</li>
<li>Add dependencies (both external and inter-project).</li>
</ol>
<p>That&#8217;s about it.</p>
<p>Now for the dark side. Currently, the m2metada-plugin clashes with maven-plugin (classloading issues). It can be worked around, but:</p>
<ol>
<li>Maven-plugin is bundled, so it must be explicitly removed by deleting jars from Gradle&#8217;s lib directory.</li>
<li>The true power of m2metadata plugin is using it together with maven-plugin. M2metadata-plugin retrieves metadata part of maven build, while maven-plugin runs Maven&#8217;s runtime to execute goals like generating poms and deploying to maven repositories.</li>
</ol>
<p>Yet another, more methodological than technical downside of m2metadata-plugin is that it preserves the usage of pom.xml. It works, so you don&#8217;t touch it, and it stays forever instead of being replaced with fully-blown build.gradle. For that concern, I see clear benefits in using the <a href="http://blog.sadogursky.com/2010/02/23/maven2-to-gradle-convertor/" target="_blank">script solution</a>, which trashes the pom.xml, leaving you with pure-gradle solution, and in conjunction with the<a href="http://gradle.org/idea_plugin.html" target="_blank"> idea-plugin</a> gives you all you need to start going.</p>
<p>All in all, once the classloading issues will be sorted out, It looks to me that the mission of creating migration tool can be considered as accomplished.</p>
<p>You can find my work <a href="http://github.com/jbaruch/Gradle-M2Metadata-Plugin" target="_blank">here</a> (Usage guide in Wiki, TODOs in issues). I am going to present it (together with the <a href="http://blog.sadogursky.com/2010/02/23/maven2-to-gradle-convertor/" target="_blank">script</a>, which,as mentioned, has it own benefits) at <a href="http://projectautomationexperience.com" target="_blank">The Project Automation Experience 2010</a> in the <a href="http://projectautomationexperience.com/conference/fort_lauderdale/2010/11/session?id=20291" target="_blank">Java Build Automation Tools Jungle</a> session. The presentation will be posted here once it will be ready.</p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/build/'>Build</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/build-2/'>build</a>, <a href='http://jbaruch.wordpress.com/tag/gradle/'>gradle</a>, <a href='http://jbaruch.wordpress.com/tag/maven2/'>maven2</a>, <a href='http://jbaruch.wordpress.com/tag/project-automation-experience-2010/'>project automation experience 2010</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=96&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/10/11/maven2-to-gradle-convertor-take-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
		<item>
		<title>Integrating MongoDB with Spring</title>
		<link>http://jbaruch.wordpress.com/2010/05/30/integrating-mongodb-with-spring/</link>
		<comments>http://jbaruch.wordpress.com/2010/05/30/integrating-mongodb-with-spring/#comments</comments>
		<pubDate>Sun, 30 May 2010 14:25:58 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Friendly Java Blogs]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/?p=70</guid>
		<description><![CDATA[Looking for plain, short and simple MongoDB and Spring integration - here  you go!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=70&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Apparently, most of the visitors to my <a href="http://jbaruch.wordpress.com/2010/04/27/integrating-mongodb-with-spring-batch/" target="_blank">&#8220;Integrating MongoDB with Spring Batch&#8221;</a> post can&#8217;t find what they look for, because they look for instructions how to integrate <a href="http://www.mongodb.org/" target="_blank">MongoDB</a> with plain <a href="http://www.springsource.org/" target="_blank">Spring Core</a>.<br />
Well, the source includes that integration, but it&#8217;s on <a href="http://github.com/jbaruch/springbatch-over-mongodb" target="_blank">github</a>, and anyway that wasn&#8217;t the focus of that post.<br />
So, here&#8217;s the integration &#8211; short, plain and simple:</p>
<ul>
<li><strong>Properties file with server and database details (resides in classpath in this example):</strong></li>
</ul>
<pre style="color:#000000;font-weight:normal;font-style:normal;border:thin solid;font-family:monospace;font-size:small;padding:5px;"><span style="color:#800000;font-weight:normal;font-style:normal;">1    </span><span style="color:#000080;font-style:normal;">db.host</span>=<span style="color:#008000;font-style:normal;">localhost</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">2    </span><span style="color:#000080;font-style:normal;">db.port</span>=<span style="color:#008000;font-style:normal;">27017</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3    </span><span style="color:#000080;font-style:normal;">app.db.name</span>=<span style="color:#008000;font-style:normal;">app</span>
</pre>
<ul>
<li><strong>If you don&#8217;t use <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-java" target="_blank">Java-based container configuration</a> (you should start using it!):</strong></li>
</ul>
<ol>
<li>application-config.xml (or whatever you call it):
<pre style="color:#000000;font-weight:normal;font-style:normal;border:thin solid;font-family:monospace;font-size:small;padding:5px;"><span style="color:#800000;font-weight:normal;font-style:normal;">1</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;</span><span style="color:#000080;background-color:#efefef;font-style:normal;">beans</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">xmlns=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"http://www.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.org/schema/beans"</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">2</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">       </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">xmlns:xsi=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">       </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">xmlns:context=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"http://www.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.org/schema/context"</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">4</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">       </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">xsi:schemaLocation=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"http://www.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.org/schema/beans</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">5</span><span style="color:#008000;background-color:#efefef;font-style:normal;">           http://www.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.org/schema/beans/spring-beans-3.0.xsd</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">6</span><span style="color:#008000;background-color:#efefef;font-style:normal;">           http://www.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.org/schema/context</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">7</span><span style="color:#008000;background-color:#efefef;font-style:normal;">           http://www.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">springframework</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.org/schema/context/spring-context-3.0.xsd</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">8</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">    &lt;</span><span style="color:#000080;background-color:#efefef;font-style:normal;">context:property-placeholder</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">
</span><span style="color:#800000;">9</span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">                location=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"classpath:db.properties"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">10</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">    &lt;</span><span style="color:#000080;background-color:#efefef;font-style:normal;">bean</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">id=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#008000;background-color:#efefef;font-style:normal;">mongo</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">class=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"com.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">mongodb</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">Mongo</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">11</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">       &lt;</span><span style="color:#000080;background-color:#efefef;font-style:normal;">constructor-arg</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">value=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"${db.host}"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">12</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">       &lt;</span><span style="color:#000080;background-color:#efefef;font-style:normal;">constructor-arg</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">value=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"${db.port}"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">13</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">   &lt;/</span><span style="color:#000080;background-color:#efefef;font-style:normal;">bean</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">14</span><span style="color:#000080;background-color:#efefef;font-style:normal;">   &lt;bean</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">id=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"db"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">
</span><span style="color:#800000;">15</span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">      class=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"com.</span><span style="color:#008000;background-color:#efefef;font-style:normal;">mongodb</span><span style="color:#008000;background-color:#efefef;font-style:normal;">.spring.config.DbFactoryBean"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">16</span><span style="color:#000080;background-color:#efefef;font-style:normal;">       &lt;property</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">name=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#008000;background-color:#efefef;font-style:normal;">mongo</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">ref=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#008000;background-color:#efefef;font-style:normal;">mongo</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">17</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">       &lt;</span><span style="color:#000080;background-color:#efefef;font-style:normal;">property</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">name=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"name"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;"> </span><span style="color:#0000ff;background-color:#efefef;font-style:normal;">value=</span><span style="color:#008000;background-color:#efefef;font-style:normal;">"${app.db.name}"</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">/&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">18</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">   &lt;/</span><span style="color:#000080;background-color:#efefef;font-style:normal;">bean</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&gt;</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">19</span><span style="color:#000000;background-color:#efefef;font-weight:normal;font-style:normal;">&lt;/</span><span style="color:#000080;background-color:#efefef;font-style:normal;">beans&gt;</span></pre>
</li>
<li>The com.mongodb.spring.config.DbFactoryBean class:
<pre style="color:#000000;font-weight:normal;font-style:normal;border:thin solid;font-family:monospace;font-size:small;padding:5px;"><span style="color:#800000;font-weight:normal;font-style:normal;">1 </span><span style="color:#000080;font-weight:bold;font-style:normal;">public</span> <span style="color:#000080;font-weight:bold;font-style:normal;">class</span> <span style="color:#000000;font-weight:normal;font-style:normal;">DbFactoryBean</span> <span style="color:#000080;font-weight:bold;font-style:normal;">implements</span> FactoryBean&lt;DB&gt; {
<span style="color:#800000;font-weight:normal;font-style:normal;">2    </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">3    </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">private</span> Mongo <span style="color:#660e7a;font-weight:bold;font-style:normal;">mongo</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">4    </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">private</span> String <span style="color:#660e7a;font-weight:bold;font-style:normal;">name</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">5    </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">6    </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Override</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">7    </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> DB getObject() <span style="color:#000080;font-weight:bold;font-style:normal;">throws</span> Exception {
<span style="color:#800000;font-weight:normal;font-style:normal;">8    </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">return</span> <span style="color:#660e7a;font-weight:bold;font-style:normal;">mongo</span>.getDB(<span style="color:#660e7a;font-weight:bold;font-style:normal;">name</span>);
<span style="color:#800000;font-weight:normal;font-style:normal;">9    </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">10   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">11   </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Override</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">12   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> Class&lt;?&gt; getObjectType() {
<span style="color:#800000;font-weight:normal;font-style:normal;">13   </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">return</span> DB.<span style="color:#000080;font-weight:bold;font-style:normal;">class</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">14   </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">15   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">16   </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Override</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">17   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> <span style="color:#000080;font-weight:bold;font-style:normal;">boolean</span> isSingleton() {
<span style="color:#800000;font-weight:normal;font-style:normal;">18   </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">return</span> <span style="color:#000080;font-weight:bold;font-style:normal;">true</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">19   </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">20   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">21   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> <span style="color:#000080;font-weight:bold;font-style:normal;">void</span> set<span style="color:#000000;font-weight:normal;font-style:normal;">Mongo</span>(Mongo mongo) {
<span style="color:#800000;font-weight:normal;font-style:normal;">22   </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">this</span>.<span style="color:#660e7a;font-weight:bold;font-style:normal;">mongo</span> = mongo;
<span style="color:#800000;font-weight:normal;font-style:normal;">23   </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">24   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">25   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> <span style="color:#000080;font-weight:bold;font-style:normal;">void</span> setName(String name) {
<span style="color:#800000;font-weight:normal;font-style:normal;">26   </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">this</span>.<span style="color:#660e7a;font-weight:bold;font-style:normal;">name</span> = name;
<span style="color:#800000;font-weight:normal;font-style:normal;">27   </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">28 </span>}
</pre>
</li>
</ol>
<ul>
<li><strong>If you do use <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-java" target="_blank">Java-based container configuration</a> &#8211; here&#8217;s your @Configuration class:</strong></li>
</ul>
<pre style="color:#000000;font-weight:normal;font-style:normal;border:thin solid;font-family:monospace;font-size:small;padding:5px;"><span style="color:#800000;font-weight:normal;font-style:normal;">1    </span><span style="color:#808000;font-weight:normal;font-style:normal;">@Configuration</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">2    </span><span style="color:#000080;font-weight:bold;font-style:normal;">public</span> <span style="color:#000080;font-weight:bold;font-style:normal;">class</span> ApplicationConfiguration {
<span style="color:#800000;font-weight:normal;font-style:normal;">3    </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">4    </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Value</span>(<span style="color:#008000;font-weight:bold;font-style:normal;">"${app.db.name}"</span>)
<span style="color:#800000;font-weight:normal;font-style:normal;">5    </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">private</span> String <span style="color:#660e7a;font-weight:bold;font-style:normal;">appDbName</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">6    </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">7    </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Value</span>(<span style="color:#008000;font-weight:bold;font-style:normal;">"${db.host}"</span>)
<span style="color:#800000;font-weight:normal;font-style:normal;">8    </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">private</span> String <span style="color:#660e7a;font-weight:bold;font-style:normal;">dbHost</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">9    </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">10   </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Value</span>(<span style="color:#008000;font-weight:bold;font-style:normal;">"${db.port}"</span>)
<span style="color:#800000;font-weight:normal;font-style:normal;">11   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">private</span> <span style="color:#000080;font-weight:bold;font-style:normal;">int</span> <span style="color:#660e7a;font-weight:bold;font-style:normal;">dbPort</span>;
<span style="color:#800000;font-weight:normal;font-style:normal;">12   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">13   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">14   </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Bean</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">15   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> DB db() <span style="color:#000080;font-weight:bold;font-style:normal;">throws</span> UnknownHostException {
<span style="color:#800000;font-weight:normal;font-style:normal;">16   </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">return</span> mongo().getDB(<span style="color:#660e7a;font-weight:bold;font-style:normal;">appDbName</span>);
<span style="color:#800000;font-weight:normal;font-style:normal;">17   </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">18   </span>
<span style="color:#800000;font-weight:normal;font-style:normal;">19   </span>    <span style="color:#808000;font-weight:normal;font-style:normal;">@Bean</span>
<span style="color:#800000;font-weight:normal;font-style:normal;">20   </span>    <span style="color:#000080;font-weight:bold;font-style:normal;">public</span> Mongo mongo() <span style="color:#000080;font-weight:bold;font-style:normal;">throws</span> UnknownHostException {
<span style="color:#800000;font-weight:normal;font-style:normal;">21   </span>        <span style="color:#000080;font-weight:bold;font-style:normal;">return</span> <span style="color:#000080;font-weight:bold;font-style:normal;">new</span> Mongo(<span style="color:#660e7a;font-weight:bold;font-style:normal;">dbHost</span>, <span style="color:#660e7a;font-weight:bold;font-style:normal;">dbPort</span>);
<span style="color:#800000;font-weight:normal;font-style:normal;">22   </span>    }
<span style="color:#800000;font-weight:normal;font-style:normal;">23   </span>}
</pre>
<p>That&#8217;s, actually, it &#8211; enjoy. If you feel some part of the puzzle is missing, please leave a comment.</p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/frameworks/'>Frameworks</a>, <a href='http://jbaruch.wordpress.com/category/friendly-java-blogs/'>Friendly Java Blogs</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/java/'>java</a>, <a href='http://jbaruch.wordpress.com/tag/mongodb/'>mongodb</a>, <a href='http://jbaruch.wordpress.com/tag/spring/'>spring</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=70&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/05/30/integrating-mongodb-with-spring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
		<item>
		<title>Towards My Gradle Talk In Beyond Java AlphaCSP Seminar</title>
		<link>http://jbaruch.wordpress.com/2010/05/20/towards-gradle-talk/</link>
		<comments>http://jbaruch.wordpress.com/2010/05/20/towards-gradle-talk/#comments</comments>
		<pubDate>Thu, 20 May 2010 20:23:10 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[alphacsp]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[buildr]]></category>
		<category><![CDATA[gant]]></category>
		<category><![CDATA[gmaven]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[javaedge]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[prezi]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/2010/05/20/your-next-successful-build/</guid>
		<description><![CDATA[sing Maven2 to build tools was like AWT to UI frameworks: revolutionary, but not without downsides.Concepts such as standardization of project layout and centralized dependency management are preserved in almost every new and future build tool.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=65&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Using Maven2 to build tools was like AWT to UI frameworks: revolutionary, but not without downsides.Concepts such as standardization of project layout and centralized dependency management are preserved in almost every new and future build tool.<span style="display:block;width:425px;margin:0 auto;"> <embed src='http://widgets.vodpod.com/w/video_embed/ExternalVideo.942934' type='application/x-shockwave-flash' AllowScriptAccess='sameDomain' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent' flashvars='prezi_id=ngwwf1wcfn7n&lock_to_path=1&color=ffffff&autoplay=no' width='425' height='350' /> </span></p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/build/'>Build</a>, <a href='http://jbaruch.wordpress.com/category/presentation/'>presentation</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/alphacsp/'>alphacsp</a>, <a href='http://jbaruch.wordpress.com/tag/ant/'>ant</a>, <a href='http://jbaruch.wordpress.com/tag/build-2/'>build</a>, <a href='http://jbaruch.wordpress.com/tag/buildr/'>buildr</a>, <a href='http://jbaruch.wordpress.com/tag/gant/'>gant</a>, <a href='http://jbaruch.wordpress.com/tag/gmaven/'>gmaven</a>, <a href='http://jbaruch.wordpress.com/tag/gradle/'>gradle</a>, <a href='http://jbaruch.wordpress.com/tag/javaedge/'>javaedge</a>, <a href='http://jbaruch.wordpress.com/tag/maven2/'>maven2</a>, <a href='http://jbaruch.wordpress.com/tag/prezi/'>prezi</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=65&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/05/20/towards-gradle-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
		<item>
		<title>Integrating MongoDB with Spring Batch</title>
		<link>http://jbaruch.wordpress.com/2010/04/27/integrating-mongodb-with-spring-batch/</link>
		<comments>http://jbaruch.wordpress.com/2010/04/27/integrating-mongodb-with-spring-batch/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 13:10:55 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Friendly Java Blogs]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring-batch]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/?p=39</guid>
		<description><![CDATA[Update (May 30th 2010): If you look for plain core Spring integration with MongoDB &#8211; here&#8217;s a post for you. Spring Batch is a superb batch framework from, well, Spring. It covers all the concepts of batch architecture and, generally, spares you from reinventing the wheel. It&#8217;s cool, really. If you have batch-oriented application, you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=39&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="background-attachment:scroll;background-color:#f7f7f1;background-image:none;display:block;height:51px;line-height:15px;min-height:51px;width:95%;border:1px solid #e3e3d1;margin:0 5px 0 0;padding:5px 2px 3px 10px;"><strong><span style="color:#000000;">Update (May 30th 2010):</span><span style="color:#000000;"> </span></strong><br />
If you look for <a href="http://www.springsource.org/" target="_blank">plain core Spring</a> integration with <a href="http://www.mongodb.org/" target="_blank">MongoDB</a> &#8211; <a href="http://jbaruch.wordpress.com/2010/05/30/integrating-mongodb-with-spring/" target="_self">here&#8217;s a post for you</a>.</div>
<p style="text-align:left;"><a href="http://static.springsource.org/spring-batch/" target="_blank">Spring Batch</a> is a superb batch framework from, well, <a href="http://www.springsource.org/" target="_blank">Spring</a>. It covers all the concepts of batch architecture and, generally, spares you from reinventing the wheel. It&#8217;s cool, really. If you have batch-oriented application, you <strong>must</strong> go and take a look at Spring Batch. And if you don&#8217;t know what batch-oriented application is, just think about reading-validating-saving-to-db a zillion text files every night, unattended. Now you know what batch-oriented application is, go and look at Spring Batch.</p>
<p style="text-align:left;">Welcome back. As you&#8217;ve seen, Spring Batch constantly saves its state in order to be able to recover/restart exactly when it stopped. <a href="http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/core/repository/JobRepository.html" target="_blank">JobRepository </a>is the bean in charge of saving the state, and its sole implementation uses data access objects layer, which currently has two implementations &#8211; in-memory maps and JDBC. It looks like this:</p>
<p style="text-align:left;"><a href="http://jbaruch.files.wordpress.com/2010/04/jobrepository.png"><img class="alignnone size-full wp-image-40" title="JobRepository" src="http://jbaruch.files.wordpress.com/2010/04/jobrepository.png?w=460&#038;h=253" alt="JobRepository class diagram" width="460" height="253" /></a></p>
<p style="text-align:left;">Of course, the maps are for <span style="text-decoration:line-through;">losers</span> testing,  JDBC implementation is the one to use in your production environment, since you have RDBMS at your application anyway, right? Or not&#8230;</p>
<p style="text-align:left;">Today, when <a href="http://en.wikipedia.org/wiki/NoSQL" target="_blank">NoSQL</a> is gaining momentum (justified, if you ask me) the assumption that  &#8220;you always have RDBMS in enterprise application&#8221; is not true anymore. So, how can you work with Spring Batch now? Using in-memory DAOs? Not good enough. Installing, setting up, maintaining, baby-sitting RDBMS only for Spring Batch meta-data? Hum, you&#8217;d rather not. There is a great solution &#8211; just keep the meta-data in the NoSQL database you use for the application itself. Thanks to Spring, the Spring Batch architecture is modularized and loosely-coupled, and all you have to do in order to make it work is to re-implement the four DAOs.</p>
<p style="text-align:left;">So, here&#8217;s the plan:</p>
<ul>
<li>Implement *Dao with NoSqlDb*Dao</li>
<li>Add them to Spring application context</li>
<li>Create new SimpleJobRepository, injecting your new NoSqlDb DAOs into it</li>
<li>Use it instead of the one you would create from JobRepositoryFactoryBean</li>
<li>&#8230;</li>
<li>Profit</li>
</ul>
<p style="text-align:left;">That was exactly what I did for our customer, implementing the DAOs using <a href="http://www.mongodb.org/" target="_blank">MongoDB</a>. Guess what, you <strong>must</strong> go and take a look at MongoDB.  It&#8217;s lightning-fast, schema-less document-oriented database, that kicks ass. When you suddenly have a strange feeling that RDBMS might <a href="http://perspectives.mvdirona.com/CommentView,guid,afe46691-a293-4f9a-8900-5688a597726a.aspx" target="_blank">not be the best solution</a> for whatever you do, chances are you&#8217;d love MongoDB, as I do now. There are use-cases, in which you just can&#8217;t implement whatever you need to do with relational storage. Well, I lied. You can. It will take a year, it will look ugly and perform even worse. That&#8217;s my case, and I am just happy the year is 2010 and we know by now that one size doesn&#8217;t fit all.</p>
<p style="text-align:left;">I have to admit -implementing Spring Batch DAOs with MongoDB was fun. Even Spring Batch meta-data model, which was designed with relational storage in mind, persists nicely in MongoDB. Should I even mention that the code is cleaner comparing to JDBC? Even on top of JDBC template?</p>
<p style="text-align:left;">
<p style="text-align:left;">Now go and grab the Spring Batch over MongoDB implementation and the reference configuration: <a href="http://github.com/jbaruch/springbatch-over-mongodb" target="_blank">http://github.com/jbaruch/springbatch-over-mongodb</a>. I have used the samples and the tests from original Spring Batch distribution, trying to make as few changes as necessary. You&#8217;ll need <a href="http://www.mongodb.org/display/DOCS/Downloads" target="_blank">MongoDB build</a> for your platform and <a href="http://gradle.org/" target="_blank">Gradle</a> <a href="http://dist.codehaus.org/gradle/gradle-0.9-preview-1-all.zip" target="_blank">0.9p1</a> to build and run. (Why Gradle? Because it is truly <a href="http://en.wordpress.com/tag/gradle/" target="_blank">a better way to build</a>).</p>
<p style="text-align:left;">If you use MongoDB &#8211; enjoy the implementation as is. If you use some other document-oriented DB, the conversion should be straightforward. In any case, I&#8217;ll be glad to hear your feedback.</p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/frameworks/'>Frameworks</a>, <a href='http://jbaruch.wordpress.com/category/friendly-java-blogs/'>Friendly Java Blogs</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/mongodb/'>mongodb</a>, <a href='http://jbaruch.wordpress.com/tag/spring/'>spring</a>, <a href='http://jbaruch.wordpress.com/tag/spring-batch/'>spring-batch</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=39&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/04/27/integrating-mongodb-with-spring-batch/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>

		<media:content url="http://jbaruch.files.wordpress.com/2010/04/jobrepository.png" medium="image">
			<media:title type="html">JobRepository</media:title>
		</media:content>
	</item>
		<item>
		<title>Maven2 to Gradle Convertor</title>
		<link>http://jbaruch.wordpress.com/2010/02/23/maven2-to-gradle-convertor/</link>
		<comments>http://jbaruch.wordpress.com/2010/02/23/maven2-to-gradle-convertor/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 02:29:32 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[Friendly Java Blogs]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[maven2]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/?p=24</guid>
		<description><![CDATA[Maven2Gradle.groovy script can generate build.gradle out of multi-module Maven poms, including dependencies (with scopes and exclusions), correct plugins selection, groupId &#38; version, repositories, compiler level settings, etc.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=24&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="background-attachment:scroll;background-color:#f7f7f1;background-image:none;display:block;height:51px;line-height:15px;min-height:51px;width:95%;border:1px solid #e3e3d1;margin:0 5px 0 0;padding:5px 2px 3px 10px;"><strong><span style="color:#000000;"><strong>Update (04/05/2010):</strong></span></strong><span style="color:#000000;"><br />
</span> <span style="color:#000000;">The code has been refactored from script to class, and it is now hosted on </span><a href="http://github.com/jbaruch/maven2gradle" target="_blank"><span style="color:#000000;">github</span></a><span style="color:#000000;">.</span></div>
<div style="background-attachment:scroll;background-color:#f7f7f1;background-image:none;display:block;height:95px;line-height:15px;min-height:95px;width:95%;border:1px solid #e3e3d1;margin:0 5px 0 0;padding:5px 2px 3px 10px;">
<div><strong>Update (31/07/2010):</strong><br />
Thanks to @lilithapp I have discovered a limitation &#8211; your project will be considered multi-module only if your reactor is also a parent of at least one of your modules. I probably won&#8217;t fix it, since that&#8217;s the case in most projects and since <a href="blog.sadogursky.com/2010/10/11/maven2-to-gradle-convertor-take-2/" target="_blank">gradle-m2metadata-plugin</a> doesn&#8217;t have that limitation.</div>
</div>
<p>Last <a href="http://www.javaedge.com/web/guest/javaedge-2009/about" target="_blank">JavaEdge</a> I delivered a <a href="http://prezi.com/ngwwf1wcfn7n/" target="_blank">session</a> about Java build tools landscape. My impression from this overview is solid &#8211; <a href="http://www.gradle.org/" target="_blank">Gradle</a> rocks. It is a best of breed and takes the best from Ant and Maven2, leaving the downsides of both behind. Take at look, it is worth it (Prezi rocks too, but it&#8217;s another blog post).</p>
<p>The only fly in the ointment I found is lack of good maven2 to Gradle convention. Gradle has good maven support. First of all, it can use dependenices&#8217; POMs to determine their transitive dependencies. Second, it has Maven plugin, but it works in the opposite direction &#8211; it can generate POM for your project, built with Gradle. I need the other side &#8211; something similar Gradle has for Ant &#8211; <code>ant.importBuild()</code> imports an Ant build into the Gradle project, and each Ant target is treated as a Gradle task. This is cool! Franky, I need much less with Maven.</p>
<p>Here&#8217;s the shopping list: I need to generate the following settings from POM.xml</p>
<ul>
<li>Dependencies (inc. scopes and exclusions)</li>
<li>Correct plugins selection (e.g. war for web application module)</li>
<li>GroupId</li>
<li>Version</li>
<li>Repositories</li>
<li>Compiler level settings</li>
<li>All those with full multi-module support</li>
<li>All those with reuse support from inheritance and settings.xml</li>
</ul>
<p>After a short search I discovered JIRA issue <a href="http://jira.codehaus.org/browse/GRADLE-154" target="_blank">GRADLE-154</a>,  in which <a id="issue_summary_reporter_antony.stubbs@gmail.com" href="http://stubbisms.wordpress.com/" target="_blank">Antony  Stubbs</a> <a href="http://stubbisms.wordpress.com/2008/07/11/groovy-converter-from-maven-to-gradle-dependencies-gradle-154/" target="_blank">asks</a> for a subset of such functionality, and finally attaches a small Groovy script that parses given POM.xml and dumps to the console dependencies in Gradle format. That was a great start for me, but the drawbacks were obvious &#8211; no support for multi-module projects (I can&#8217;t recall when I saw single-module project last time), no support for parts, coming from settings.xml, etc. One specific pom.xml file in view has very little to do with the <em>effective </em>pom in runtime. You already got it, right? The parsing should be done on the effective pom, which is easily obtained using maven-help-plugin. So, having effective pom in hand, I can rip it apart and build nice set of build.gradle files, and the settings.gradle for the multi module support, and they include all the items from the above list!</p>
<p>I can assure you there are some bugs here and there in this script, but generally it works, and I managed to migrate fairly complicated project with war assembly, transitive dependencies, poms inheritance, artifacts exclusions etc. in a single click. &#8220;Is this cool or is this cool?&#8221;</p>
<p>So, <a href="http://jira.codehaus.org/secure/attachment/47641/Maven2Gradle.groovy" target="_blank">grab the script</a>, and give it a shot. It has two flags: -verbose prints out Maven output during effective pom resolution and -keepFile keeps the effective pom file for you.</p>
<p>Note the new task in the generated gradle.build &#8211; replacePoms. The idea is to solve the lack of IntelliJ Gradle integration when it comes to dependency management (IDEA knows how to run the build). Gradle generates poms for your modules. The gradle.build knows to copy them to the place where IntelliJ needs them. Just run &#8220;build replacePoms&#8221;, and IDEA will recognize dependencies from Gradle! Yup!</p>
<p>Enjoy.</p>
<p>P.S. You should check the new <a href="blog.sadogursky.com/2010/10/11/maven2-to-gradle-convertor-take-2/" target="_blank">gradle-m2metadata-plugin</a>, it&#8217;s the real thing &#8211; Maven3 embedded  into Gradle&#8217;s plugin. It gets all the metadata in runtime!</p>
<p>P.P.S. Sorry for my Groovy, it&#8217;s not my mother tongue.</p>
<br />Filed under: <a href='http://jbaruch.wordpress.com/category/build/'>Build</a>, <a href='http://jbaruch.wordpress.com/category/friendly-java-blogs/'>Friendly Java Blogs</a> Tagged: <a href='http://jbaruch.wordpress.com/tag/gradle/'>gradle</a>, <a href='http://jbaruch.wordpress.com/tag/groovy/'>groovy</a>, <a href='http://jbaruch.wordpress.com/tag/maven2/'>maven2</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=24&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/02/23/maven2-to-gradle-convertor/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
		<item>
		<title>Artifactory as Training Labs Provisioning Platform</title>
		<link>http://jbaruch.wordpress.com/2010/01/18/artifactory-as-training-labs-delivery-platform/</link>
		<comments>http://jbaruch.wordpress.com/2010/01/18/artifactory-as-training-labs-delivery-platform/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:23:12 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
				<category><![CDATA[Friendly Java Blogs]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[alphacsp]]></category>
		<category><![CDATA[artifactory]]></category>

		<guid isPermaLink="false">http://jbaruch.wordpress.com/?p=4</guid>
		<description><![CDATA[Artifactory as labs provisioning platform dramatically simplifies both lecturer's and student's life, enabling rapid exercises development and rollout without any preparation from student's part and minimal preparation from training organizer's part, all those thanks to Maven2 dependency management capabilities, good IDE Maven integration, and, of course, Artifactory's ease of use.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=4&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As<a href="http://www.alphacsp.com/web/guest/training" target="_blank"> AlphaCSP</a>&#8216;s training guy I deliver a lot of trainings. They come in different flavors, on different topics, and in different companies. The common in all of them is the problem I encounter on labs setups.</p>
<p>First, problem definition:<br />
Let&#8217;s take, for example, some serious global financial company, which needs training in Spring, Hibernate and JAX-RS. My contact point is a nice Training Activities Administrator. She just organized &#8220;Micro-Expressions Training for HR&#8221; and her next task is to organize my Java course. What do you say, will she be able to install IntelliJ IDEA (or Eclipse?), Spring 3 bundles, Hibernate dependencies and Jersey? And yes, the classroom network is detached from both Intranet and Internet (BIG financial company, remember?). Oh, I almost forgot a bonus &#8211; the training workstations rollback all changes after every restart.</p>
<p>Now, here are two possible provisioning solutions:</p>
<ol>
<li>Come over day before for installs. Well, probably the classroom is occupied with another course. If not, the guy that should let me in the classroom, the network, and the computers is busy, sick or in Thailand, but probably all three in the same time. Ah, and I have another work to do on this day! And the customer won&#8217;t pay for it anyway. You got the point &#8211; bad idea.</li>
<li>Prepare the labs on CDs. Well, it generally works, most of the software courses delivered that way, one successful example is SpringSource trainings. You get nicely branded CD full of all you need &#8211; The IDE, the dependencies, and the labs source code. Good stuff, really. It works for SpringSource because of the high volume of catalog courses they deliver. They have a stock of identical CDs they use during every single training, worldwide. When it comes to tailor-made courses, things are different. No course is similar to any other course, the topics, installs, dependencies and exercises are unique set each time. That rather complicates the CDs craft &#8211; composing, burning, labeling. I don&#8217;t say it&#8217;s impossible &#8211; I did it for each and every course, but it&#8217;s a real <acronym title="Pain In The Ass">PITA</acronym>. And thanks to the reverting workstations, students will have to copy, extract, setup, define variables every day from scratch over and over again. Did I mention PITA?</li>
</ol>
<p>And there is a third solution. The best one. You can use Enterprise Repository Manager to recreate students environment in a couple of minutes in any given time. Now, it rocks. It really is. Watch the steps:</p>
<ol>
<li>Customer Requirements
<ol>
<li>Two simple installs, every Training Administrator and/or Sysadmin can manage:
<ol>
<li>IntelliJ IDEA (next-next-next) from <a href="http://www.jetbrains.com/idea/" target="_blank">JetBrains</a> site. Or Eclipse?</li>
<li>Maven2 (unzip) from <a href="http://maven.apache.org/" target="_blank">Apache</a> site.</li>
</ol>
</li>
<li>Create .m2 directory under user home for <a href="http://maven.apache.org/settings.html" target="_blank">Maven user settings</a>.</li>
<li>Permission to connect your notebook to the class&#8217; Intranet. It is isolated, the machines revert themselves, shouldn&#8217;t be a problem.</li>
</ol>
</li>
<li>Exercises development
<ol>
<li>Develop the exercises on  your notebook with all the Maven goodies &#8211; pom.xml, dependencies, superb IntelliJ-Maven integration (or Eclipse?).</li>
<li>Install <a href="http://www.jfrog.org/" target="_blank">Artifactory</a> locally (you&#8217;ll see why Artifactory and not <a href="http://nexus.sonatype.org" target="_blank">Nexus</a> in the following steps). I mean &#8211; <a href="http://www.jfrog.org/download.php" target="_blank">download</a> and unzip, heh. Run it (not even as a service)</li>
<li><a href="http://wiki.jfrog.org/confluence/display/RTF/Importing+and+Exporting" target="_blank">Import</a> your local repository to Artifactory (can&#8217;t do it in Nexus #1) &#8211; zip it and make half-dozen of clicks in Artifactory UI.</li>
<li>Deploy the exercises to the local repository. They probably won&#8217;t compile &#8211; they are exercises, right? Then just zip them and <a href="http://wiki.jfrog.org/confluence/display/RTF/Deploying+Via+the+Web+UI" target="_blank">deploy from UI</a>. Students will download them through Artifactory UI.</li>
<li>Take the Artifactory down. You are ready to go to class.</li>
</ol>
</li>
<li>Exercises delivery
<ol>
<li>&#8220;Good morning, students!&#8221; &#8211; deliver the hell of the course, get to the hands-on part.</li>
<li>Connect your notebook to the class&#8217; Intranet, get dynamic IP (yap, dynamic is good enough).</li>
<li>Get Artifactory up and running.</li>
<li>Let the students browse to Artifactory&#8217;s homepage. There they will found <a href="http://wiki.jfrog.org/confluence/display/RTF/Configuring+Artifacts+Resolution" target="_self">Maven Settings Generator</a> (can&#8217;t do it in Nexus #2), which will generate settings.xml to work with your instance of Artifactory from their machines. All they need to do is check &#8220;Mirror-Any&#8221;, select &#8220;repo&#8221; and save the generated file under .m2 directory.<strong> That&#8217;s all, their machines are fully configured</strong> to get all the dependencies needed for Spring, Hibernate, Jersey, and whatever you need for your training.</li>
<li>Let the students browse the repository to download the exercises zip, unzip it, export Maven project into IntelliJ IDEA (or Eclipse?) and just start working!</li>
</ol>
</li>
</ol>
<p>As you saw, using Artifactory as labs delivery platform dramatically simplifies both lecturer&#8217;s and student&#8217;s life, enabling rapid exercises development and rollout without any preparation from student&#8217;s part and minimal preparation from training organizer&#8217;s part, all those thanks to Maven2 dependency management capabilities, good IDE Maven integration, and, of course, <strong>Artifactory&#8217;s ease of use</strong>. And frankly, there is nothing I love more than ease of use. Maybe only chocolate ice-cream.</p>
<br />Posted in Friendly Java Blogs, Training Tagged: alphacsp, artifactory, Friendly Java Blogs, Training <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=4&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2010/01/18/artifactory-as-training-labs-delivery-platform/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
		<item>
		<title>Coding to a Bug</title>
		<link>http://jbaruch.wordpress.com/2007/06/01/coding-to-a-bug/</link>
		<comments>http://jbaruch.wordpress.com/2007/06/01/coding-to-a-bug/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 13:23:17 +0000</pubDate>
		<dc:creator>jbaruch</dc:creator>
		
		<guid isPermaLink="false">http://blog.sadogursky.com/?p=117</guid>
		<description><![CDATA[Well, the story goes like this. Once you have a closed source application to extend (well, you decomiple it of course, but it doesn&#8217;t make it open source, do it?). And it is damn old (like 2001 or something, did people actually code then?). And it uses some weird database like MS SQL Server, and, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=117&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, the story goes like this.<br />
Once you have a closed source application to extend (well, you decomiple  it of course, but it doesn&#8217;t make it open source, do it?). And it is  damn old (like 2001 or something, did people actually code then?). And  it uses some weird database like  MS SQL Server, and, of course a JDBC  driver for it, <a href="http://jtds.sourceforge.net/">jTDS</a>. Back  then, in 2001 version 1.0 of the jTDS was available. It was a little  very buggy, for example, putting the driver&#8217;s jar in WEB-INF/libs  generates NPE, so it have to live in Tomcat&#8217;s share lib.<br />
And of course, as any respectable company the vendor of the application  developed it&#8217;s own wrapper arround JDBC with  DatabaseUtilities.getConnection, releaseConnection, and so on.</p>
<p>Now, to the story.<br />
On the surface it looked easy. We obtain connection, bla-bla,  executeQuery, ResultSet.hasNext, etc. Works like a charm on clearly  installed application. Once they populate the database with their  home-made utility for migration from excel&#8230; boom. Thier code works,   our throws IOEXception &#8211; &#8220;system cannot find the path specified&#8221;.  The  root of the exception somewhere inside the driver. Google suggests to  update the driver to the last version. No prob! Done. Of course I move  it from Tomcat&#8217;s share to the application lib on that occasion.<br />
Guess what? Our code works like charm, but all other updates in  application start failing on it can&#8217;t manually commit when auto-commit  is on! As I understood it, they just didn&#8217;t turn auto-commit off, and  the old buggy driver forgave them!</p>
<p>What can you do? The old driver stops working on durty database, the  new driver won&#8217;t work with their application code. You can&#8217;t change the  source of their driver wrapper to turn the auto-commit off, because it  is closed-source, and you can&#8217;t be sure decompiler did a perfect work  (and usually it don&#8217;t).</p>
<p>Anyway, we rolled-back the driver version, returned it to Tomcat&#8217;s  shared lib, and went to their JDBC wrapper to look which shaman  ceremonies they perform to make it work. We&#8217;d better not. They cast the  driver to the actual jTDS class and call all kind of implementation  methods. I am thankful to them they wrapped all those inside their JDBC  wrapper, so all we needed to do is to replace JDBC code with some really  strange calls like getQueryResults, which gets the SQL string (not  parametrized, of course), and returns array of strings (contatining all  the data, including dates and numbers).</p>
<p>So, what do you say? Any better way to do it except coding to the bug?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/jbaruch.wordpress.com/117/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/jbaruch.wordpress.com/117/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbaruch.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbaruch.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbaruch.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbaruch.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbaruch.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbaruch.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbaruch.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbaruch.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbaruch.wordpress.com&amp;blog=481424&amp;post=117&amp;subd=jbaruch&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbaruch.wordpress.com/2007/06/01/coding-to-a-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d73332968c0bf62e1ece7299deb8b37?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">JBaruch</media:title>
		</media:content>
	</item>
	</channel>
</rss>
