<?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>Gerbrand on ICT &#187; java</title>
	<atom:link href="http://www.gerbrand-ict.nl/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gerbrand-ict.nl</link>
	<description>Weblog on JEE and software-engineering</description>
	<lastBuildDate>Wed, 11 Aug 2010 20:51:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Google buys Instantiations</title>
		<link>http://www.gerbrand-ict.nl/2010/08/google-buys-instantiations/</link>
		<comments>http://www.gerbrand-ict.nl/2010/08/google-buys-instantiations/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:51:12 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Various]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=451</guid>
		<description><![CDATA[A while a go I used to do Swing development, and I sometimes used the tool of Instantiations to develop my GUI. I quite liked the tool. Before that I used Visual Basic and Visual Studio frequently. I never fully understood why people would fiddle so much with pixels, stylesheets, colors etc when you could [...]]]></description>
			<content:encoded><![CDATA[<p>A while a go I used to do Swing development, and I sometimes used the tool of <a href="http://instantiations.com/">Instantiations </a>to develop my GUI. I quite liked the tool.<br />
Before that I used Visual Basic and Visual Studio frequently. I never fully understood why people would fiddle so much with pixels, stylesheets, colors etc when you could just design your GUI visually.<br />
Well, Instantiations has GWT design tool as well. I recently tried it out very shortly. The tool looked very nice.<br />
I just recently Google bought Instantiations. Will this mean developer productivity in frontend development is cool again?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/08/google-buys-instantiations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stuff to research: JDO on Cassandra, GIT on Windows, Restlet, VMForce</title>
		<link>http://www.gerbrand-ict.nl/2010/07/stuff-to-research-jdo-on-cassandra-git-on-windows-restlet-vmforce/</link>
		<comments>http://www.gerbrand-ict.nl/2010/07/stuff-to-research-jdo-on-cassandra-git-on-windows-restlet-vmforce/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 22:15:13 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=452</guid>
		<description><![CDATA[Just had evening of just trying out stuff and not finishing anything on my Windows machine. I wanted to try out a persistence API for Cassandra. There&#8217;s a JPA implementation for Cassandra: Kundera, as well as JDO implementation, on top (or using) datanucleus: datanucleus-cassandra. Just to clarify why I would want such a thing: nosql [...]]]></description>
			<content:encoded><![CDATA[<p>Just had evening of just trying out stuff and not finishing anything on my Windows machine.</p>
<p>I wanted to try out a persistence API for <a href="http://cassandra.apache.org/">Cassandra</a>. There&#8217;s a JPA implementation for Cassandra: <a href="http://anismiles.wordpress.com/2010/06/30/kundera-knight-in-the-shining-armor/">Kundera</a>, as well as JDO implementation, on top (or using) datanucleus: <a href="http://github.com/PedroGomes/datanucleus-cassandra">datanucleus-cassandra</a>.</p>
<p>Just to clarify why I would want such a thing: <strong>nosql </strong>solutions such as Cassandra are, in essence distributed key-value stores. I know, from following a few classes on databases and distributed databases when attending the university that&#8217;s a whole lot more complicated to implement then it may seem.<br />
Nevertheless, to do anything useful with that you need a layer on top of the key-value store. Basically all SQL databases like Oracle or MySQL have SQL layer around there key-value store. But the nice thing about stuff like Cassandra you can put something more convenient on top.</p>
<p>I wanted to try out both, starting with the JDO version, as that seemed  more like a natural fit, and I once started ORM with JDO 1.0 many years  ago.<br />
I&#8217;d need a git client on Windows, and apparently there&#8217;s already a <a href="http://code.google.com/p/tortoisegit/">Tortoise Git client</a>, based on the truly great <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a>, on of the tools I really miss on my Mac. The client version of git first had to be installed, but that was quite easy as well, just download and install <a href="http://code.google.com/p/msysgit/">msysgit</a>.<br />
The tortoisegit client looks very well, and seems easy to use. At least I got the code of datanucleus-cassandra in a breeze. Well now it&#8217;s kind of late, I&#8217;ll try out later.</p>
<p><a href="http://commons.wikimedia.org/wiki/File:Hector_Cassandra_Pomarici_Santomasi.jpg"><img class="alignnone size-medium wp-image-456" title="541px-Hector_Cassandra_Pomarici_Santomasi" src="http://www.gerbrand-ict.nl/wp-content/uploads/2010/07/541px-Hector_Cassandra_Pomarici_Santomasi-270x300.jpg" alt="" width="270" height="300" /></a></p>
<p>Other stuff I want to try out: creating a Rest service using <a href="http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet.html">Restlet </a>on Google AppEngine. Just to find out how that works. But later.</p>
<p>Finally I saw a demo on <a href="http://www.vmforce.com/">VMForce</a>. Looks very promising, as I like Spring for development and that&#8217;s what you&#8217;d use. Nothing is released however, now there&#8217;s just articles and a demo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/07/stuff-to-research-jdo-on-cassandra-git-on-windows-restlet-vmforce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proxying authentication using JBoss</title>
		<link>http://www.gerbrand-ict.nl/2010/06/proxying-authentication-using-jboss/</link>
		<comments>http://www.gerbrand-ict.nl/2010/06/proxying-authentication-using-jboss/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 23:00:19 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=264</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice if the connection to the database is done using the same username as the username used to login to a (JEE) application? Oracle has a solution for that: proxy authentication.  When using proxy authentication, every application user is also a database user: meaning when someone logins to your JEE webapplication using [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice if the connection to the database is done using the same username as the username used to login to a (JEE) application? Oracle has a solution for that: <a href="http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/proxya.htm">proxy authentication</a>.  When using proxy authentication, every application user is also a database user: meaning when someone logins to your JEE webapplication using username john, he&#8217;ll also access the database as user john. This way all actions of the user are logged at the database-level: an administrator or auditer can see exactly what data a certain user modified or accessed during a JEE session.</p>
<p><span id="more-264"></span></p>
<p>Also, this allows for fine-grained security at database level: <a href="http://www.oracle.com/technology/deploy/security/database-security-10g/virtual-private-database/index.html">Virtual Private Database</a>.</p>
<div id="attachment_297" class="wp-caption alignnone" style="width: 466px"><a href="http://www.oracle.com/technology/deploy/security/database-security-10g/virtual-private-database/index.html"><img class="size-full wp-image-297" title="virtual-private-database1" src="http://www.gerbrand-ict.nl/wp-content/uploads/2009/06/virtual-private-database1.gif" alt="Virtual private database" width="456" height="175" /></a><p class="wp-caption-text">(c) Oracle</p></div>
<p>As described in the above image and referenced article, the user identified by userid 106 (let&#8217;s say that&#8217;s user john) will access the database using a private database connection. The user can only access rows that have that userid as primary or foreign key.  John can&#8217;t see the passwords, orders, credit card data or anything of other users even if he would somehow hack the webapplication. How to set up this finegrained securiy is beyond this article, but I hope the above example explains what the purpose VPD is.</p>
<p>If you develop your JEE software using Oracle software  proxy authentication requires only a bit of configuration, for example, see the following article how to setup proxy authentication using <a href="http://blogs.oracle.com/jheadstart/2008/01/28/">JHeadstart</a>.</p>
<p>However, what if you&#8217;re JEE applicication consists of non-oracle software? Can you still use proxy authentication when you use software like JBoss, Hibernate, IBatis, MyFaces, Wicket etc? Yes you can! I&#8217;ll explain below how to set up proxy authentication using JBoss in such a way you don&#8217;t have to modify any of the code that uses JDBC, directly or indirectly.</p>
<ul>
<li>First a way is needed to set a username for each (JDBC) database connection retrieved. <a href="http://www.it-eye.nl/weblog/2005/09/12/oracle-proxy-users-by-example/">It-eye weblog</a> explains how to open a connection to a database using java, and then switch to another username.</li>
<li>Secondly, in your application users should authenticate them self using the default mechanism of J2EE 1.4 (and higher) application, using <a href="http://java.sun.com/javase/technologies/security/">JAAS</a>. Usually creating a security policy inside your web.xml or inside your ear is enough. Here&#8217;s the information how to do this under JBoss: <a href="http://www.jboss.org/community/wiki/SecureAWebApplicationUsingACustomForm">Secure a webapplication</a>.<br />
Since we&#8217;re using a database, the best option would be to use database based authentication, meaning user information comes out of a database table. There&#8217;s a lot of documentation on the web how to do add security, so I won&#8217;t repeat that here.</li>
<li>Database connection in JBoss are retrieved using connection pooling, as is custom in any JEE server.  You can create a custom connection pool, that changes the switches to the user name that is currently logged in at the webapplication. That way, every action on the database is done under a database user that is currently logged in.Do to be able to do that, first, you&#8217;ll need a custom connection factory that extends the default connection factory. Our connection factory will return a customized datasource that modifies code.Here&#8217;s a code listing:
<pre class="brush: java;">package nl.gerbrandict.dbconnaudit;

import java.sql.SQLException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;

import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
import org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory;

/**
 * An extended connection factory, that uses the Oracle feature to change the username of an existing connection
 *

 * When a user authenticated on the application server, the database connection will switch to that username.
 * This allows for better auditing and potentially for improved security.
 *
 * Properties (get'ers and set'ters) can be set via the configuration section of the -ds file
 * @author gvdieijen
 */
public class DBConnAuditConnectionFactory extends LocalManagedConnectionFactory {

    private String defaultProxyUser;

    public DBConnAuditConnectionFactory() throws SQLException {
        super();

    }

    @Override
    public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
        return new OracleWrapperDataSource(this, cm);
    }

    public void setEnableProxySession(Boolean enableProxySession) {
        this.enableDbConnAudit = enableProxySession;
    }

    public void setDefaultProxyUser(final String defaultProxyUser) {
        if (StringUtils.isEmpty(defaultProxyUser)) {
            this.defaultProxyUser=null;
        } else {
             this.defaultProxyUser = defaultProxyUser;
        }
    }

    /**
     * Default db user to open proxy session for, when no authenticated user is active
     * @return
     */
    public String getDefaultProxyUser() {
    	return this.defaultProxyUser;
    }
}</pre>
<p>As you can see, the file returns a OracleWrapperDatasource. That&#8217;s custom class, that extends the default WrapperDatasource of JBoss, and changes the user of jdbc connection just before the connection is handed of to the application. To speak in terms of the fine book</li>
<li>Now, How can you use that new class? They have to be packed into a rar file. Functionally, that&#8217;s a Resource Adapter, a module that allows a J2EE application to use resources. Technically (and practically), it&#8217;s just a jar-archive similar to a war, with a different extension. Maven can create these files automatically for you, if you set the packaging type to rar instead of jar (which is the default).</li>
<li>When you download JBoss, you&#8217;ll get a sample connection pool for a in-memory database: default-ds.xml, located in the server/default/deploy directory of jboss. To use the custom classses, copy the file into (for example) myoracleproxy-ds.xml and create a minor modification so a custom connection factory is used &#8211; update the managedconnectionfactory property, that a custom connectionfactory is used, that returns the proxied connections:
<pre class="brush: xml;">&lt;managedconnectionfactory-class&gt;nl.gerbrandict.dbconnaudit.DBConnAuditConnectionFactory&lt;/managedconnectionfactory-class&gt;</pre>
</li>
</ul>
<p>All in all, after some tweaking, all queries and updates to your Oracle database are done under the J2EE username. This means when user Joe logs in, all his database access will be logged under user Joe as well. This can improve auditing as well as security.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/06/proxying-authentication-using-jboss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala and Java</title>
		<link>http://www.gerbrand-ict.nl/2010/03/scala-and-java/</link>
		<comments>http://www.gerbrand-ict.nl/2010/03/scala-and-java/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 12:53:22 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=408</guid>
		<description><![CDATA[When you say Ruby, you say Rails. When you say Groovy, you say unit-tests, scripting and integration. Well that might be over-acted, but that&#8217;s what most people make of it. Some people remark Scala is best-suited for backend-code, or very good at parallel code, but apart from that I&#8217;ve never heard that Scala is the [...]]]></description>
			<content:encoded><![CDATA[<p>When you say Ruby, you say Rails. When you say Groovy, you say unit-tests, scripting and integration. Well that might be over-acted, but that&#8217;s what most people make of it.<br />
Some people remark Scala is best-suited for backend-code, or very good at parallel code, but apart from that I&#8217;ve never heard that Scala is the language for the Lift framework. Or the language to use when you want to create multi-threaded code. What I hear mostly, Scala is the new Java.<br/><br />
Would that be true: could you use Scala as a dropin replacement for Java, as, let&#8217;s say, a <strong>Java 2.0</strong> or <strong>Java 8</strong>?</p>
<p>
In the coming postings I want to investigate that claim using my knowledge of experience in Java/J2EE and my complete lack of experience in Scala. Can you say to you&#8217;re developers, or yourself, from this day on, we&#8217;ll use Scala instead of Java to do our development?</p>
<p>
For now, I found this nice presentation I want to share: <a title="Miles Sabin Introduction To Scala For Java Developers" href="http://www.slideshare.net/skillsmatter/miles-sabin-introduction-to-scala-for-java-developers">Introduction To Scala For Java Developers</a> by Miles Sabin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/03/scala-and-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Develop with faster with smarter tools</title>
		<link>http://www.gerbrand-ict.nl/2010/02/develop-with-jrebel/</link>
		<comments>http://www.gerbrand-ict.nl/2010/02/develop-with-jrebel/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 23:23:58 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[coder]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=401</guid>
		<description><![CDATA[I develop software for a living. This involves quite a lot of talking, coaching, attending meetings, drinking coffee, etc. but the actual work is done during programming &#8211; when the software is created. That programming involves repeated cycles of the following: modify or type some code, compile, deploy and then run the code and perform [...]]]></description>
			<content:encoded><![CDATA[<p>I develop software for a living. This involves quite a lot of talking, coaching, attending meetings, drinking coffee, etc. but the actual work is done during programming &#8211; when the software is created. That programming involves repeated cycles of the following: modify or type some code, compile, deploy and then run the code and perform some tests to see if it works. How cumbersome that process was ranged from:</p>
<ul>
<li>Hitting &#8216;Run&#8217; and waiting a few seconds,</li>
<li>to hitting &#8216;Run and deploy&#8217; in my IDE and waiting about 20-30 seconds,</li>
<li>to executing a ant script, restarting the application server and waiting 5 minutes</li>
<li>to compiling a class file, uploading the class and accompanied libraries using a cumbersome webinterface and then executing a PLSQL script to run that class, wasting in total time amount 15 minutes (<em>yes, that was a a very big and professional company)<br />
</em></li>
</ul>
<p>In my opinion, the programmer is productive when he either codes, or when he tests his codes. Any time spent on waiting or performing some troublesome actions like accessing a web interface is pure waste. In short the above time ranging from a few seconds to 15 minutes is <a href="http://www.oreillynet.com/onjava/blog/2006/03/dead_time_code_compile_wait_wa.html">dead time</a>.</p>
<p>Of course all that time wasted not only frustrates developers, it&#8217;ll cost quite some time and thus money. Now how can you limit that dead time, that is wasted by developers? One way is your have your developers write perfect code at once. Of course that&#8217;s not very realistic. Recently I found a very nice tool to limit that dead time, when you develop Java software: <a href="http://www.zeroturnaround.com/jrebe">JRebel</a>. What does that mean for you as java-developer:<br />
JRebel runs as a software agent within your virtual machine, that in turn runs your application server. What JRebel does, is taking over the class-loader.<br />
You can specify the output directories of your IDE (target/classes, /bin, etc.). Now whenever you make a change in your code, IDE&#8217;s like Eclipse can compile that code into a new class file in the output directory. JRebel will automatically detect the changed class file. Thus no waste! Since JRebel plugs into the VM, it&#8217;ll work with virtually any application server.</p>
<p><a href="http://www.zeroturnaround.com/blog"><img class="alignnone" title="JRebel Hotswap" src="http://www.zeroturnaround.com/wp-content/uploads/2009/11/hotswap.png" alt="" width="550" height="302" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/02/develop-with-jrebel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JFall report</title>
		<link>http://www.gerbrand-ict.nl/2009/11/jfall-report/</link>
		<comments>http://www.gerbrand-ict.nl/2009/11/jfall-report/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 21:43:22 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jfall]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=368</guid>
		<description><![CDATA[Ik heb een verslag geschreven over JFall 2009 voor Whitehorses, het bedrijf waarvoor ik werk. Hier is de officiele introductie Op 11 november 2009 werd JFall 2009, een van de twee congressen die jaarlijks door de NLJug worden georganiseerd, gehouden. Naast de inhoudelijke sessies, is een van de mooiste aspecten van JFall (en JSpring) het [...]]]></description>
			<content:encoded><![CDATA[<p>Ik heb een verslag geschreven over JFall 2009 voor <a href="http://www.whitehorses.nl">Whitehorses</a>, het bedrijf waarvoor ik werk.</p>
<p>Hier is de officiele introductie</p>
<blockquote><p>
Op 11 november 2009 werd JFall 2009, een van de twee congressen die jaarlijks door de NLJug worden georganiseerd, gehouden. Naast de inhoudelijke sessies, is een van de mooiste aspecten van JFall (en JSpring) het ontmoeten van andere Java programmeurs. In dit Whitebook vind je een verslag van dit congres en van een aantal sessies, o.a. over Java SE 7 en de nieuwe Google ontwikkelingen. Lees het volledige artikel »
</p></blockquote>
<p>en hier is de whitebook: <a href="http://www.whitehorses.nl/whitebooks/2009/jfall-2009-een-verslag">JFall 2009, een verslag </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/11/jfall-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whitebook on parallel programming</title>
		<link>http://www.gerbrand-ict.nl/2009/11/whitebook-on-parallel-programming/</link>
		<comments>http://www.gerbrand-ict.nl/2009/11/whitebook-on-parallel-programming/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 09:42:47 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jee]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=365</guid>
		<description><![CDATA[Via the newsletter of Whitehorses, the company I work for, an article written by me is published: Gebruik de multi-core omgeving met Java 7 . As the title suggest, the article is in Dutch. The article explains some of the new features of Java 7 for creating software that runs in parallel on multiple cores.]]></description>
			<content:encoded><![CDATA[<p>Via the newsletter of <a href="http://www.whitehorses.nl">Whitehorses</a>, the company I work for, an article written by me is published: <a href="http://www.whitehorses.nl/whitebooks/2009/gebruik-de-multi-core-omgeving-met-java-7">Gebruik de multi-core omgeving met Java 7 </a>. As the title suggest, the article is in Dutch. The article explains some of the new features of Java 7 for creating software that runs in parallel on multiple cores.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/11/whitebook-on-parallel-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JFall on Google Guice</title>
		<link>http://www.gerbrand-ict.nl/2009/09/google-guice/</link>
		<comments>http://www.gerbrand-ict.nl/2009/09/google-guice/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 12:47:55 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Various]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jee]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=358</guid>
		<description><![CDATA[Yesterday I&#8217;ve submitted a paper to NLJUG, the Dutch Java User Group for the JFall 2009 conference. Together with colleagues we worked on a proposal for a very nice presentation on the Google Guice. Like many programmers we were quite skeptical on yet-another Dependency Injection/IC framework. We all know Spring, and dependency injection is now [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I&#8217;ve submitted a paper to <a href="http://www.nljug.org/">NLJUG</a>, the Dutch Java User Group for the <a href="http://www.nljug.org/pages/events/content/jfall_2009/">JFall 2009</a> conference. Together with colleagues we worked on a proposal for a very nice presentation on the <a href="http://code.google.com/p/google-guice/">Google Guice</a>. Like many programmers we were quite skeptical on yet-another <a href="http://en.wikipedia.org/wiki/Inversion_of_control">Dependency Injection</a>/IC framework. We all know Spring, and dependency injection is now also part of the J2EE 1.5 / EJB3 standard. What makes Guice worth looking at?<br />
In our talk we&#8217;ll explain (of course) what Google Guice is, and how Guice compares to Spring and EJB3. Hope to see you on JFall!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/09/google-guice/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JBoss on Linux</title>
		<link>http://www.gerbrand-ict.nl/2009/07/jboss-on-linux/</link>
		<comments>http://www.gerbrand-ict.nl/2009/07/jboss-on-linux/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 11:21:26 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jboss]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=342</guid>
		<description><![CDATA[Lately I tried to run JBoss on my Linux-installation (KUBuntu 9). I got lots of java.lang.OutOfMemoryError: PermGen space errors while starting JBoss 5. First I thought that had something to do with Linux. I google&#8217;d the error, and from what I read, permgen errors are caused by bugs in either JBoss or the JavaVM. So [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I tried to run JBoss on my Linux-installation (KUBuntu 9). I got lots of  <code>java.lang.OutOfMemoryError: PermGen</code> space errors while starting JBoss 5. First I thought that had something to do with Linux. I google&#8217;d the error, and from what I read, permgen errors are caused by bugs in either JBoss or the JavaVM. So increasing memory won&#8217;t help, besides, JBoss ran fine on my Windows installation.<br />
Then I remembered JBoss had a separate package for Java JDK 1.5 and JDK 1.6. I used the JBoss- version for JDK 1.5, but I have JDK 1.6 installed on my Linux installation. After I switched to the JBoss 5.0 version for JDK 1.5, JBoss ran smoothly!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/07/jboss-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generics support for Apache commons collections</title>
		<link>http://www.gerbrand-ict.nl/2009/05/generics-support-for-apache-commons-collections/</link>
		<comments>http://www.gerbrand-ict.nl/2009/05/generics-support-for-apache-commons-collections/#comments</comments>
		<pubDate>Sat, 16 May 2009 21:30:00 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=281</guid>
		<description><![CDATA[In my day to day work program I use the Apache Commons library quite a lot.  One of those libraries is the commons collections library, of which I use the CollectionUtils class and ListUtils mostly. One great disadvantage of the commons collection library is lack of Java Generics support, added in Java 1.5.  This means [...]]]></description>
			<content:encoded><![CDATA[<p>In my day to day work program I use the <a href="http://commons.apache.org/">Apache Commons</a> library quite a lot.  One of those libraries is the<a href="http://commons.apache.org/collections/"> commons collections </a>library, of which I use the <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/CollectionUtils.html">CollectionUtils</a> class and <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/ListUtils.html">ListUtils </a>mostly. One great disadvantage of the commons collection library is lack of Java Generics support, added in Java 1.5.  This means if you call a function like <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/ListUtils.html#predicatedList(java.util.List,%20org.apache.commons.collections.Predicate)">predicatedList</a> with a typed list and predicate argument, the function will return an untyped list. The list has to be cast again, which clutters up the code and doesn&#8217;t look very nice, like the following example:</p>
<pre class="brush: java;">
class Address {
    String firstName;
}

List <Address> myAddresses ;
...
List <Address> onlyJohns = (List <Address>) ListUtils.predicatedList(myAddresses,new Predicate() {
   public boolean evaluate(Object o) {
       Address a=(Address)o;
       return a.firstName.equals("John");
   }
});
 </pre>
<p>Quite a lot of casting as you can see in the above code. Less code would be needed if generics support would be added to the collection framework. Added generics support to the collections library should be too hard, and would improve my code.<br/><br />
I&#8217;d think other people would have that idea, and I quickly found the following posting on <a href="http://www.devx.com/Java/Article/36183">devx</a>. Turns out there&#8217;s a sourceforge project that has modified the collections library to have generics support: <a href="http://sourceforge.net/projects/collections">Commons Collections with generics</a>.<br />
The project is even added to the central maven repository, so to use the new collection library adding the following dependency is enough:</p>
<pre class="brush: xml;">
<groupId>net.sourceforge.collections</groupId>
<artifactId>collections-generic</artifactId>
<version>4.01</version>
</pre>
<p>The new code now becomes (excluding the Address class, which is the same):</p>
<pre class="brush: java;">
List <Address> onlyJohns = ListUtils.predicatedList(myAddresses,new Predicate<Address>() {
        @Override
   public boolean evaluate(Address a) {
       return a.firstName.equals("John");
   }
});
</pre>
<p>The code looks quite better! A lot less code would be needed if <a href="http://www.javac.info/">closures </a>would be added to Java too, but that&#8217;ll have to wait until JDK 1.8 or something is released.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/05/generics-support-for-apache-commons-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
