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

<channel>
	<title>Pragmatic Programmer Issues - pietrowski.info</title>
	<atom:link href="http://pietrowski.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://pietrowski.info</link>
	<description></description>
	<lastBuildDate>Wed, 27 Jan 2010 13:58:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Myths of innovation</title>
		<link>http://pietrowski.info/2010/01/myths-of-innovation/</link>
		<comments>http://pietrowski.info/2010/01/myths-of-innovation/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 13:58:28 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pietrowski.info/2010/01/myths-of-innovation/</guid>
		<description><![CDATA[I&#8217;ve just finished &#8220;The myths of innovation book by Scott Berkun, it&#8217;s well written book, what I want to share with you. Author made great research about innovation, and categorize myths about innovation. In most cases this myths are used to excuse ourself, that we don&#8217;t try to make innovation. 
Everyone should read this book, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished &#8220;The myths of innovation book by Scott Berkun, it&#8217;s well written book, what I want to share with you. Author made great research about innovation, and categorize myths about innovation. In most cases this myths are used to excuse ourself, that we don&#8217;t try to make innovation. </p>
<p>Everyone should read this book, don&#8217;t wait, buy or borrow and read this book. If someday you have idea, just start making it. If you find excuse for this idea, check if this excuse is not one of those myths. The myths:
<ol>
<li>The myth of epiphany</li>
<li>We understand the history of innovation</li>
<li>There is a method for innovation</li>
<li>People love new ideas</li>
<li>The lone inventor</li>
<li>Good ideas are hard to find</li>
<li>Your boss knows more about innovation than you</li>
<li>The best idea win</li>
<li>Problems and solutions</li>
<li>Innovation is always good</li>
</ol>
<p>One supplement for this is <a href="http://www.oreillynet.com/onlamp/blog/2005/08/ideas_are_just_a_multiplier_of.html">Derek Sivers post</a>. He provides very easy equation.<br />
<blockquote>Successful Business = Idea x Execution</p></blockquote>
<p> Where idea is valued as:
<dl>
<dt>AWFUL IDEA</dt>
<dd>-1</dd>
<dt>WEAK IDEA</dt>
<dd>1</dd>
<dt>SO-SO IDEA</dt>
<dd>5</dd>
<dt>GOOD IDEA</dt>
<dd>10</dd>
<dt>GREAT IDEA</dt>
<dd>15</dd>
<dt>BRILLIANT IDEA</dt>
<dd>20</dd>
</dl>
<p> and execution as:
<dl>
<dt>NO EXECUTION</dt>
<dt>
<dd>$1</dd>
<dt>WEAK EXECUTION</dt>
<dd>$1000</dd>
<dt>SO-SO- EXECUTION</dt>
<dd>$10,000</dd>
<dt>GOOD EXECUTION</dt>
<dd>$100,000</dd>
<dt>GREAT EXECUTION</dt>
<dd>$1,000,000</dd>
<dt>BRILLIANT EXECUTION</dt>
<dd>$10,000,000</dd>
</dt>
</dl>
<p> Too summarize that I will provide one of my favorite quote:<br />
<blockquote>&#8220;Try not. Do, or do not. There is no try&#8221;</p></blockquote>
<p> I hope that this post helps somebody.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2010/01/myths-of-innovation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guava &#8211; Google Collections</title>
		<link>http://pietrowski.info/2010/01/guava-google-collections/</link>
		<comments>http://pietrowski.info/2010/01/guava-google-collections/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 17:34:40 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=221</guid>
		<description><![CDATA[Guava
Guava is Google Core Libraries for Java 1.5, it include extension libraries which provides many common pieces of code. Long long time ago apache starts with commons-* libraries, but unfortunately most of them lack java 5 support. 
Currently Google Collection is included into Guava and on 30 Dec google released Google Collection 1.0-fianal version. This [...]]]></description>
			<content:encoded><![CDATA[<h3>Guava</h3>
<p style="clear: both">Guava is Google Core Libraries for Java 1.5, it include extension libraries which provides many common pieces of code. Long long time ago apache starts with commons-* libraries, but unfortunately most of them lack java 5 support. </p>
<p style="clear: both">Currently Google Collection is included into Guava and on 30 Dec google released Google Collection 1.0-fianal version. This version is not 1.0 but it has frozen API. It&#8217;s nearly done, but it is used in google production projects now. </p>
<p style="clear: both">So, what&#8217;s inside ?</p>
<p style="clear: both">
<ul style="clear: both">
<li>Immutable Collections</li>
<li>Multisets</li>
<li>Multimaps</li>
<li>New types</li>
<li>Static utilitis</li>
</ul>
<h3>Immutable Collections</h3>
<p>JDK currently has utility wrapper in Collections which can change our map/set/list into unmodifiable, but this is just a partial solution because internally our collection is mutable. Immutable means that we can never change the object state. So there are:
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableMap.html">com.google.common.collect.ImmutableMap<K,V></a></dt>
<dd>An immutable, hash-based Map</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableSortedMap.html">com.google.common.collect.ImmutableSortedMap<K,V></a></dt>
<dd>An immutable SortedMap</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableBiMap.html">com.google.common.collect.ImmutableBiMap<K,V></a></dt>
<dd>An immutable BiMap</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableCollection.html">com.google.common.collect.ImmutableCollection<e></e></a></dt>
<dd> An immutable collection.</dd>
<dt><a href="com.google.common.collect.ImmutableList<E> http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableList.html&#8221;>com.google.common.collect.ImmutableList<e></e></a></dt>
<dd>A high-performance, immutable, random-access List implementation.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableMultiset.html">com.google.common.collect.ImmutableMultiset<e></e></a></dt>
<dd>An immutable hash-based multiset</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableSet.html">com.google.common.collect.ImmutableSet<e></e></a></dt>
<dd>A high-performance immutable Set</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableSortedSet.html">com.google.common.collect.ImmutableSortedSet<e></e></a></dt>
<dd> An immutable SortedSet that stores its elements in a sorted array.</dd>
</dl>
<p> All this Collections don&#8217;t allow Null values and Maps don&#8217;t allow Null keys or values. </p>
<h3>Multisets</h3>
<p style="clear: both">Multiset is a type of collection which allows duplicate elements and has unordered equality (lists have ordered equality). A multiset is also called bag. Multiset is better from list in such operation as contains(), checking if two collection are equal ignoring order and providing histograms (providing info about element count). Additionally Multiset performance depends on the number of <strong>distinct</strong> elements. </p>
<p style="clear: both">There are a lot of different implementation of <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multiset.html">Multiset interface</a>.
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ConcurrentHashMultiset.html">com.google.common.collect.ConcurrentHashMultiset<E></a></dt>
<dd>A multiset that supports concurrent modifications</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/EnumMultiset.html">com.google.common.collect.EnumMultiset<E></a></dt>
<dd>Multiset implementation backed by an EnumMap.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ForwardingMultiset.html">com.google.common.collect.ForwardingMultiset<E></a></dt>
<dd>A multiset which forwards all its method calls to another multiset. (Decorator pattern alike)</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/HashMultiset.html">com.google.common.collect.HashMultiset<E></a></dt>
<dd>Multiset implementation backed by a HashMap.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableMultiset.html">com.google.common.collect.ImmutableMultiset<E></a></dt>
<dd>Immputable hash-based.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/LinkedHashMultiset.html">com.google.common.collect.LinkedHashMultiset<E></a></dt>
<dd>A Multiset implementation with predictable iteration order.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/TreeMultiset.html">com.google.common.collect.TreeMultiset<E></a></dt>
<dd>Multiset which maintains the ordering of its elements.</dd>
</dl>
<h3>Multimaps</h3>
<p style="clear: both">Similar to Multiset is Multimap iterface. It provides abstraction like a Map but keys aren&#8217;t unique or we can thing about this that unique key has a list of values, so if you have somewhere in the code type such as Map<Key, List<>> Multimap is for you. As 1.0 version we&#8217;ve got <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multimap.html">Multimap</a> interface implementation such as:
<ul>
<li>Multimap<K,V></li>
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ForwardingMultimap.html">com.google.common.collect.ForwardingMultimap<K,V></a></dt>
<dd>A multimap which forwards all its method calls to another multimap.</dd>
</dl>
<li>ListMultimap<K,V>
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ArrayListMultimap.html">com.google.common.collect.ArrayListMultimap<K,V></a></dt>
<dd>Multimap that uses an ArrayList to store the values for a given key</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableListMultimap.html">com.google.common.collect.ImmutableListMultimap<K,V></a></dt>
<dd>Immutable ListMultimap</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/LinkedListMultimap.html">com.google.common.collect.LinkedListMultimap<K,V></a></dt>
<dd>Implementation of ListMultimap that supports deterministic iteration order for both keys and values.</dd>
</dl>
</li>
<li>SetMultimap<K,V&#038;gt
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/HashMultimap.html">com.google.common.collect.HashMultimap<K,V></a></dt>
<dd>The multimap does not store duplicate key-value pairs.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableSetMultimap.html">com.google.common.collect.ImmutableSetMultimap<K,V></a></dt>
<dd>Immutable SetMultimap</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/LinkedHashMultimap.html">com.google.common.collect.LinkedHashMultimap<K,V></a></dt>
<dd>Multimap that does not allow duplicate key-value entries and that returns collections whose iterators follow the ordering in which the data was added to the multimap.</dd>
</dl>
</li>
<li>SortedSetMultimap<K,V>
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/TreeMultimap.html">com.google.common.collect.TreeMultimap<K,V></a></dt>
<dd>Multimap whose keys and values are ordered by their natural ordering or by supplied comparators.</dd>
</dl>
</li>
</ul>
<h3>BiMap</h3>
<p style="clear: both">BiMap is the map with unique values. Than it can be inverted so bimap.inverse().inverse() == bimap. There are few implementation of BiMap interface:
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/EnumBiMap.html">com.google.common.collect.EnumBiMap<K,V></a></dt>
<dd>BiMap backed by two EnumMap instances</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/EnumHashBiMap.html">com.google.common.collect.EnumHashBiMap<K,V></a></dt>
<dd>BiMap backed by an EnumMap instance for keys-to-values, and a HashMap instance for values-to-keys.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/HashBiMap.html">com.google.common.collect.HashBiMap<K,V></a></dt>
<dd>BiMap backed by two HashMap instances.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableBiMap.html">com.google.common.collect.ImmutableBiMap<K,V></a></dt>
<dd>Immutable BiMap</dd>
</dl>
<h3>Static Utility Class</h3>
<p style="clear: both">In this category there are a lot of class which has only static members to extend and provide function which are useful but not available today.
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Collections2.html">Collections2</a></dt>
<dd>Provides <strong>filter</strong> with Predicate and <strong>transform</strong> with Function methods</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Functions.html">Functions</a></dt>
<dd>Function extension eg compose</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Lists.html">Lists</a></dt>
<dd>Provides such methods as <strong>new*</strong> for easier List creation and two additional methods <strong>partition</strong>(create sublists of the same size) and <strong>transform</strong> which takes Function as a parameter and apply it to every list element.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Maps.html">Maps</a></dt>
<dd>Provides such methods as <strong>new*</strong> for easier Map creation, <strong>difference</strong> method, <strong>filter*</strong> methods with Predicate, <strong>fromProperties</strong>, <strong>transformValues</strong> with Function parameter. </dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multimaps.html">Multimaps</a></dt>
<dd>Provides methods such as <strong>new*</strong>, <strong>synchronized*</strong>, <strong>unmodifiable*</strong></dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ObjectArrays.html">ObjectArrays</a></dt>
<dd>Provides <strong>contact</strong> and <strong>newArray</strong> methods</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Sets.html">Sets</a></dt>
<dd>Provides methods: <strong>differece</strong>, <strong>filter</strong>, <strong>intersecton</strong>, <strong>new*</strong>, <strong>union</strong></dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Suppliers.html">Suppliers</a></dt>
<dd>Some Supplier extensions</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Predicates.html">Predicates</a></dt>
<dd>Predicate extension eg. <strong>and</strong>, <strong>or</strong>, <strong>not</strong> etc</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Preconditions.html">Preconditions</a></dt>
<dd>Static methods to be called at beginning of methods to check preconditions.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Objects.html">Objects</a></dt>
<dd>Helper for Object class has great <strong>hashCode(Object &#8230;) </strong>method for generating hash code for multiple objects.</dd>
</dl>
<h3>And more &#8230;</h3>
<dl>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Ordering.html">Ordering<T></a></dt>
<dd>Comparator with added methods to support common functions such as min, max etc. So instead of iterate over list to find min value, we can use min(Iterable) method.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/MapMaker.html">MapMaker</a></dt>
<dd>ConcurrentMap builder, providing any combination of these features: soft or weak keys, soft or weak values, timed expiration, and on-demand computation of values.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Function.html">Function<F,T></a></dt>
<dd>A transformation from one object to another. Used in transform static utility methods for Collection API extension.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Predicate.html">Predicate<T></a></dt>
<dd>Determines a true or false value for a given input. Used in filter static utility methods.</dd>
<dt><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Supplier.html">Supplier<T></a></dt>
<dd>Class that supply object of single type. Used in new* static utility methods</dd>
</dl>
<h3>Final thoughts</h3>
<p>So&#8230;, in my opinion this library is must have in every project and there are a chance that this library will be standard JDK7 library, there are a lot of structures and static utility methods which makes our code much cleaner and simpler. Googler made great job!</p>
<h3>References</h3>
<ul>
<li><a href="http://www.javalobby.org/articles/google-collections/">What is the Google Collections Library?</a> &#8211; interview with authors Kevin Bourrillion and Jared Levy.
<li><a href="http://google-collections.googlecode.com/">Google Collections Home Page</a></li>
</li>
</ul>
<p><br class="final-break" style="clear: both" />  </p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2010/01/guava-google-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Springframework utils classes</title>
		<link>http://pietrowski.info/2009/09/springframework-utils-classes/</link>
		<comments>http://pietrowski.info/2009/09/springframework-utils-classes/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 09:39:30 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=217</guid>
		<description><![CDATA[Today I talked with my friend about mocking classes when there are no setter for dependency. Typically when we use springframework @Autowire support, spring will inject dependency for us. Of course we can overcame this issue by Reflection API or by using groovy. Finally I thought that spring must have some utility class for that, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I talked with my friend about mocking classes when there are no setter for dependency. Typically when we use springframework @Autowire support, spring will inject dependency for us. Of course we can overcame this issue by Reflection API or by using groovy. Finally I thought that spring must have some utility class for that, simple search confirmed my thoughts. There is <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/util/ReflectionUtils.html">ReflectionUtils </a>and we can simply use it. So while searching I spot many *Utils classes, maybe there is more such utility classes. I wrote a python script to figure.</p>
<p>Here is the script </p>
<pre class="brush:python">
#!/usr/bin/env python
#coding=utf-8
import os
sources = r"put_your_path"
utilsClassesDict = dict()

def processFile(fileName, className):
    import fileinput
    commentSpoted = False
    for line in fileinput.input(fileName):
        if commentSpoted:
            utilsClassesDict[className] = line
            fileinput.close()
        if "**" in line:
            commentSpoted = True

def processDirectory(fileName):
    fileList = os.listdir(fileName)
    for file in fileList:
        newFile = os.path.join(fileName, file)
        if os.path.isdir(newFile):
            processDirectory(newFile)
        elif os.path.isfile(newFile) and ("Utils" in file):
            processFile(newFile, file[:-5])                

def printDict():
    keys = utilsClassesDict.keys()
    keys.sort()
    for k in keys:
        print("%s %s" % (k, utilsClassesDict[k]))

if os.path.exists(sources):
    processDirectory(sources)
    printDict()
else:
    print("wrong source path %s" % sources)
</pre>
<p>And for spring 2.5.6.SEC01 it returns this list.</p>
<ul>
<li>AopConfigUtils  * Utility class for handling registration of AOP auto-proxy creators.</li>
<li>AopNamespaceUtils  * Utility class for handling registration of auto-proxy creators used internally</li>
<li>AopProxyUtils  * Utility methods for AOP proxy factories.</li>
<li>AopUtils  * Utility methods for AOP support code.</li>
<li>AspectJAopUtils  * Utility methods for dealing with AspectJ advisors.</li>
<li>AspectJProxyUtils  * Utility methods for working with AspectJ proxies.</li>
<li>AutoProxyUtils  * Utilities for auto-proxy aware components.</li>
<li>AutowireUtils  * Utility class that contains various methods useful for</li>
<li>BeanDefinitionReaderUtils  * Utility methods that are useful for bean definition reader implementations.</li>
<li>BeanFactoryUtils  * Convenience methods operating on bean factories, in particular</li>
<li>BeanUtils  * Static convenience methods for JavaBeans: for instantiating beans,</li>
<li>BindingResultUtils  * Convenience methods for looking up BindingResults in a model Map.</li>
<li>BshScriptUtils  * Utility methods for handling BeanShell-scripted objects.</li>
<li>ClassLoaderUtils  * Utility class for diagnostic purposes, to analyze the</li>
<li>ClassUtils  * Miscellaneous class utility methods. Mainly for internal use within the</li>
<li>CollectionUtils  * Miscellaneous collection utility methods.</li>
<li>ConnectionFactoryUtils  * Helper class for managing a JMS {@link javax.jms.ConnectionFactory}, in particular</li>
<li>DataAccessUtils  * Miscellaneous utility methods for DAO implementations.</li>
<li>DataSourceUtils  * Helper class that provides static methods for obtaining JDBC Connections from</li>
<li>DelegatingActionUtils  * Common methods for letting Struts Actions work with a</li>
<li>DomUtils  * Convenience methods for working with the DOM API,</li>
<li>ExpressionEvaluationUtils  * Convenience methods for transparent access to JSP 2.0&#8217;s built-in</li>
<li>FacesContextUtils  * Convenience methods to retrieve the root WebApplicationContext for a given</li>
<li>FileCopyUtils  * Simple utility methods for file and stream copying.</li>
<li>FileSystemUtils  * Utility methods for working with the file system.</li>
<li>FreeMarkerTemplateUtils  * Utility class for working with FreeMarker.</li>
<li>HtmlUtils  * Utility class for HTML escaping. Escapes and unescapes</li>
<li>JBossWorkManagerUtils  * Utility class for obtaining the JBoss JCA WorkManager,</li>
<li>JRubyScriptUtils  * Utility methods for handling JRuby-scripted objects.</li>
<li>JasperReportsUtils  * Utility methods for working with JasperReports. Provides a set of convenience</li>
<li>JavaScriptUtils  * Utility class for JavaScript escaping.</li>
<li>JdbcUtils  * Generic utility methods for working with JDBC. Mainly for internal use</li>
<li>JmsUtils  * Generic utility methods for working with JMS. Mainly for internal use</li>
<li>JmxMetadataUtils  * Utility methods for converting Spring JMX metadata into their plain JMX equivalents.</li>
<li>JmxUtils  * Collection of generic utility methods to support Spring JMX.</li>
<li>JstlUtils  * Helper class for preparing JSTL views,</li>
<li>LangNamespaceUtils  * @author Rob Harrop</li>
<li>LobCreatorUtils  * Helper class for registering a transaction synchronization for closing</li>
<li>NamedParameterUtils  * Helper methods for named parameter parsing.</li>
<li>NestedExceptionUtils  * Helper class for implementing exception classes which are capable of</li>
<li>NumberUtils  * Miscellaneous utility methods for number conversion and parsing.</li>
<li>ObjectUtils  * Miscellaneous object utility methods. Mainly for internal use within the</li>
<li>PatternMatchUtils  * Utility methods for simple pattern matching, in particular for</li>
<li>PersistenceManagerFactoryUtils  * Helper class featuring methods for JDO PersistenceManager handling,</li>
<li>PortletApplicationContextUtils  * Convenience methods for retrieving the root WebApplicationContext for a given</li>
<li>PortletRequestUtils  * Parameter extraction methods, for an approach distinct from data binding,</li>
<li>PortletUtils  * Miscellaneous utilities for portlet applications.</li>
<li>PropertiesLoaderUtils  * Convenient utility methods for loading of <code>java.util.Properties</code>,</li>
<li>PropertyAccessorUtils  * Utility methods for classes that perform bean property access</li>
<li>ReflectionUtils  * Simple utility class for working with the reflection API and handling</li>
<li>RemoteInvocationUtils  * General utilities for handling remote invocations.</li>
<li>RequestContextUtils  * Utility class for easy access to request-specific state which has been</li>
<li>RequestUtils  * Parameter extraction methods, for an approach distinct from data binding,</li>
<li>ResourcePatternUtils  * Utility class for determining whether a given URL is a resource</li>
<li>ResourceUtils  * Utility methods for resolving resource locations to files in the</li>
<li>RmiClientInterceptorUtils  * Factored-out methods for performing invocations within an RMI client.</li>
<li>ScopedProxyUtils  * Utility class for creating a scoped proxy.</li>
<li>ServletRequestUtils  * Parameter extraction methods, for an approach distinct from data binding,</li>
<li>SessionFactoryUtils  * Helper class featuring methods for TopLink Session handling,</li>
<li>SqlParameterSourceUtils  * Class that provides helper methods for the use of {@link SqlParameterSource}</li>
<li>StatementCreatorUtils  * Utility methods for PreparedStatementSetter/Creator and CallableStatementCreator</li>
<li>StringUtils  * Miscellaneous {@link String} utility methods.</li>
<li>StylerUtils  * Simple utility class to allow for convenient access to value </li>
<li>SystemPropertyUtils  * Helper class for resolving placeholders in texts. Usually applied to file paths.</li>
<li>TagUtils  * Utility class for tag library related code, exposing functionality</li>
<li>TransactionSynchronizationUtils  * Utility methods for triggering specific {@link TransactionSynchronization}</li>
<li>TransformerUtils  * Contains common behavior relating to {@link javax.xml.transform.Transformer Transformers}.</li>
<li>TxNamespaceUtils  * @author Rob Harrop</li>
<li>TypeUtils  * Utility to work with Java 5 generic type parameters.</li>
<li>UiApplicationContextUtils  * Utility class for UI application context implementations.</li>
<li>ValidationUtils  * Utility class offering convenient methods for invoking a {@link Validator}</li>
<li>VelocityEngineUtils  * Utility class for working with a VelocityEngine.</li>
<li>WebApplicationContextUtils  * Convenience methods for retrieving the root</li>
<li>WebUtils  * Miscellaneous utilities for web applications.</li>
</ul>
<p>This is quite nice list (74 utility classes), isn&#8217;t it? </p>
<p>Most of them are really internal for context building issues, but there are some ninjas which should be useful for us in daily job, In next post I will try to pick up some of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2009/09/springframework-utils-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala Implicit Conversion</title>
		<link>http://pietrowski.info/2009/07/scala-implicit-conversion/</link>
		<comments>http://pietrowski.info/2009/07/scala-implicit-conversion/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 16:09:57 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pietrowski.info/2009/07/scala-implicit-conversion/</guid>
		<description><![CDATA[I&#8217;ve just finished Programming in Scala by Martin Odersky. So in next few post I will describe my thoughts about Scala. Shortly I recommend you to get know something about this language. I quote:

&#34;If I were to pick a language to use today other than Java, it would be Scala&#34; by James Gosling


&#34;I can honestly [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished <a href="http://www.amazon.com/Programming-Scala-Martin-Odersky/dp/0981531601">Programming in Scala by Martin Odersky</a>. So in next few post I will describe my thoughts about Scala. Shortly I recommend you to get know something about this language. I quote:</p>
<blockquote>
<p>&quot;If I were to pick a language to use today other than Java, it would be Scala&quot; by James Gosling</p>
</blockquote>
<blockquote>
<p>&quot;I can honestly say if someone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon &amp; Bill Venners back in 2003 I&#8217;d probably have never created Groovy.&quot; by James Strachan.</p>
</blockquote>
<p>Interesting, isn&#8217;t it?</p>
<p>Scala has a lot of futures we do not have in java, one thing I like about scala is that most of new features  are de facto libraries, this libraries simply extend language (the name scala comes from <strong>sca</strong>lable <strong>la</strong>nguage). </p>
<p>In this post I will focus on implicit conversions. It is similar to java cast, which are explicit, but of course implicit conversion are more powerful feature, which is used in scala to extend existing libraries easier.</p>
<p>Implicit conversion is a function which takes one type as parameter and return other type. Example in java space will be <em>String.valueOf(int i)</em> which takes int type and return String object. So where is the fun in this <img src='http://pietrowski.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The fun comes from fact that this functions are applied implicitly by compiler with full type check. To do this compiler require to follow some rules:</p>
<ol>
<li>
Implicit conversion must be in scope as single identifier, or be associated with the source or target type.</p>
<pre class="brush:scala">
/* put conversion into scope */
import Preamble._  /* many libraries import in this way library implicit conversions"
/* or  as companion object */
class Person { ... }
object Person {
/* implicit conversions goes here for Person type */
}
</pre>
</li>
<li>One conversion at the time, so there isn&#8217;t implicit conversion chaining.</li>
<li>There may be only one way to apply implicit conversion, otherwise compiler rise error.</li>
<li>And the last is of course that explicit has priority.</li>
</ol>
<p>Writing implicit conversion is very easy, we just put <strong>implicit</strong> keyword before method, and we are done. The name of the implicit conversion depends on developer, I mostly saw type2target convention as example some implicit conversion from Predef: any2ArrowAssoc, int2double etc. Of course there are also typeToTarget and typeWrapper as well.<br/><br />
Want to assign double to int just wirte this implicit and it works.</p>
<pre class="brush:scala">
scala>  implicit def double2int(d:Double): Int = d.toInt
scala> val i : Int = 3.5
</pre>
</p>
<p>Ok so what we can do with implicit conversions. Implicit conversion is tried in such situations:</p>
<ol>
<li>As expected type (extended cast alike).</li>
<li>Receiver conversion.</li>
<li>Also as implicit parameters</li>
</ol>
<p>First rule applies in many cases, as behind the scene action. For example assume this code:</p>
<pre class="brush:scala">
val d : Double = 3 /* 3 is Integer */
/* this code is translated by compiler into val d: Double - Predef.int2double(3) */
</pre>
<p>It works perfectly because in fact compiler is using Predef.int2double implicit conversion. We can do in such way proper object translation to use it with current libraries. </p>
<pre class="brush:scala">
Map( "first"-&gt;"Test", "second"-&gt;"Code")
</pre>
<p>It looks like a special syntax but in fact it is just implicit conversion in action. The code is translated into:</p>
<pre class="brush:scala">
  Map.apply(any2ArrowAssoc("first").-&gt;("Test"), any2ArrowAssoc("second").-&gt;("Code"))
</pre>
<p>I omit generics and Predef package to make this code more readable, as we see this &quot;syntax&quot; in fact use any2ArrowAssoc implicit conversion defined in Predef. </p>
<p>As all we know with great power, comes great responsibility. It may be hard to know what is going on with my code, when implicit conversions are overused. So key fact is that always we can use implicit conversion as normal method and call it explicit. Second scala compiler has <strong>-Xprint:typer</strong> option parameter which can be use to show scala code after applying implicit conversions. I was using it to show the code of Map pseudo-syntax. Example looks like this:</p>
<pre class="brush:scala">
/* scala code Test.scala */
object Test extends Application {
  Map( "first"-&gt;"Test", "second"-&gt;"Code")
}
</pre>
<p>Console output</p>
<pre>
pedro$ scalac -Xprint:typer Test.scala
[[syntax trees at end of typer]]// Scala source: Test.scala
package  {
  final object Test extends java.lang.Object with Application with ScalaObject {
    def this(): object Test = {
      Test.super.this();
      ()
    };
    scala.this.Predef.Map.apply[java.lang.String, java.lang.String](
scala.this.Predef.any2ArrowAssoc[java.lang.String]("first").-&gt;[java.lang.String]("Test"),
scala.this.Predef.any2ArrowAssoc[java.lang.String]("second").-&gt;[java.lang.String]("Code"))
  }
}
</pre>
<p>There are also implicit parameter which also use implict to add additional parameter to the method calls. Implicit conversion is quite simple but very powerful feature, isn&#8217;t it? What do you think about it? In my opinion is quite useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2009/07/scala-implicit-conversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven 2.2.0 Released</title>
		<link>http://pietrowski.info/2009/07/maven-2-2-0-released/</link>
		<comments>http://pietrowski.info/2009/07/maven-2-2-0-released/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 10:59:42 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=201</guid>
		<description><![CDATA[New version of maven was released. One of the benefit is that there are many bug fixes and some regression from 2.1.0 was fixed.
The main issue when upgrading is that new maven requires Java 1.5 or later! If you still have system which must be build for Java 1.4 you&#8217;ve got trouble to overcome. There [...]]]></description>
			<content:encoded><![CDATA[<p>New version of maven was released. One of the benefit is that there are many bug fixes and some regression from 2.1.0 was fixed.</p>
<p>The main issue when upgrading is that new maven requires Java 1.5 or later! If you still have system which must be build for Java 1.4 you&#8217;ve got trouble to overcome. <a href="http://maven.apache.org/guides/mini/guide-building-jdk14-on-jdk15.html">There is guide</a> how you can configure your pom to use ensure that you do not use API from later version t han suggested.</p>
<p>This is achieved by using <a href="https://animal-sniffer.dev.java.net/">animal-sniffer</a>. Animal-sniffer is project which goal is to provide tools for developers which must use many different Java versions. For example I use java 1.4, java 5 and java 6 in my daily work. </p>
<p>Currently there are maven plugin and command line tool. Command line help us to find which class is compiled by which java version, it may help to spot libraries or modules compiled by higher version than our project.</p>
<p>Most helpful is maven plugin which can be configure in such way that it rise build error if we use API from higher java version. Assume the code:</p>
<pre class="brush:java">
package info.pietrowski;

public class Main {
    public static void main(String[] args) {
        BigDecimal d = new BigDecimal(10); // this constructor is since 1.5
        System.out.println(d);
    }
}
</pre>
<p>Now we configure maven to target for 1.4 java platform, but JAVA_HOME points to java 5 or higher</p>
<pre class="brush:xml">
...
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.4</source>
    <target>1.4</target>
  </configuration>
</plugin>
...
</pre>
<p>Running this program with different java version drive to the output</p>
<pre>
$ jdk1.6.0_13/bin/java -classpath test.jar info.pietrowski.Main
10
$ j2sdk1.4.2_16/bin/java -classpath test.jar info.pietrowski.Main
Exception in thread "main" java.lang.NoSuchMethodError: java.math.BigDecimal.<init>(I)V
        at info.pietrowski.Main.main(Main.java:10)
</pre>
<p>The problem is that compiler choose BigDecimal constructor based on rt.jar, and despite produce bytecode  1.4 compatible, can run it because rt.jar in java 1.4 do not have this constructor. </p>
<p>The rescue for this problem is animal-sniffer maven plugin which we can configure like this:</p>
<pre class="brush:xml">
...
<plugin>
    <groupId>org.jvnet</groupId>
    <artifactId>animal-sniffer</artifactId>
      <executions>
        <execution>
          <id>animal-sniffer</id>
<phase>compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <signature>
                <groupId>org.jvnet.animal-sniffer</groupId>
                <artifactId>java${jdk.level}</artifactId>
                <version>1.0</version>
              </signature>
            </configuration>
          </execution>
        </executions>
      <dependencies>
        <dependency>
          <groupId>org.jvnet.animal-sniffer</groupId>
          <artifactId>java${jdk.level}</artifactId>
          <version>1.0</version>
          <type>sig</type>
        </dependency>
     </dependencies>
   </plugin>
...
</pre>
<p>Where jdk.level is property for target java version. Also this two resource has some configuration guidance:<br />
<a href="https://animal-sniffer.dev.java.net/signature-checker.html">Signature Checker guideline</a> and <a href="http://maven.apache.org/guides/mini/guide-building-jdk14-on-jdk15.html">Guide to building 1.4 project</a>.</p>
<p>Currently they have signatures for </p>
<ul>
<li>java1.3</li>
<li>java1.4</li>
<li>java1.5</li>
<li>java1.6</li>
</ul>
<p>And hopefully you do not have to use older java than 1.3.</p>
<p>After this change pom like suggested and try to build by java higher than 1.5 we get this error message:</p>
<pre>
[INFO] [animal-sniffer:check {execution: animal-sniffer}]
[INFO] Checking unresolved references to org.jvnet.animal-sniffer:java1.4:1.0
[ERROR] Undefined reference: java/math/BigDecimal.<init>(I)V in ...\target\classes\info\pietrowski\Main.class
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Signature errors found. Verify them and put @IgnoreJRERequirement on them.
</pre>
<p>Thanks to Marcin who test with me this configuration and finally put this into our organization parent pom for all our developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2009/07/maven-2-2-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
