<?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>Rich Internet Applications (RIA) &#187; Java</title>
	<atom:link href="http://www.canoo.com/blog/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.canoo.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 18 Jan 2012 14:30: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>HTML5 for iOS</title>
		<link>http://www.canoo.com/blog/2011/11/01/html5-for-ios/</link>
		<comments>http://www.canoo.com/blog/2011/11/01/html5-for-ios/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 10:36:30 +0000</pubDate>
		<dc:creator>Erik Jan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2330</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/01/html5-for-ios/";</script>My grandfather used to say: &#8220;Makkelijker gezegd dan gedaan&#8221; (easier said then done). So when I talked about how HTML5 could be the new platform in-depended development paradigm, in this previous post, I better come with some real world examples instead of only saying it. So that is exactly what I&#8217;ve been doing. My wife [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/01/html5-for-ios/";</script><p>My grandfather used to say: &#8220;<em>Makkelijker gezegd dan gedaan</em>&#8221; (easier said then done). So when I talked about how HTML5 could be the new platform in-depended development paradigm, in this <a href="http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/">previous post</a>, I better come with some real world examples instead of only saying it.</p>
<p>So that is exactly what I&#8217;ve been doing. My wife is a bit of an apple fan woman. And she has a book that she would like to publish. She couldn&#8217;t find a publisher, so the next best thing would be to put her book on an iPad, but you still need an publisher to put something on the iBook store and publishers are still stuck in the dark ages. So we&#8217;ve decided to make an application out of her book. Now I&#8217;ve written some objective-c code before and I must say it wasn&#8217;t the best experience I&#8217;ve had. Xcode at that time was awful, it was like writing software 10 years ago. So I started to look for alternatives. It could be a simple html page, but how to create a native iPad application out of that?</p>
<p>I&#8217;ve found something that I&#8217;m really exited about. <a href="http://playn.googlecode.com">Playn</a> is a cross-platform game abstraction library for writing games that compile to multiple platforms one of these is html using gwt. Now if I use this in combination with <a href="http://phonegap.com/">phonegap</a> then I can create a iPad app that can also run on android based pads. Not only that I could make it interactive add a game to the book and best of all do it in Java.</p>
<p>If you think about it, for companies this makes a lot of sense. Unless your companies key platform is iOS, having developers in-house that have objective-c knowledge is expensive. Also hiring external company to build an iPhone app is expensive and they have to work together with you to integrate your existing architecture. So having something like this where one can use existing knowhow to create a android and iPhone solution that works on both platforms is a huge cost saver.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/11/01/html5-for-ios/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/11/01/html5-for-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne 2011 Thursday and wrap-up</title>
		<link>http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/</link>
		<comments>http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 05:15:10 +0000</pubDate>
		<dc:creator>Dierk</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[canoo]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Dierk König]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2291</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/";</script>Opinions expressed in the post are solely my own and not necessarily those of my employer. Thursday started with the Community Keynote. Well, it actually started with a 25 minutes IBM presentation about their cloud story. This had obviously nothing to do with the topic of the event and later speakers pointed this out rather [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/";</script><div id="_mcePaste"><em>Opinions expressed in the post are solely my own and not necessarily those of my employer.</em></div>
<div><em><br />
</em></div>
<div>Thursday started with the Community Keynote. Well, it actually started with a 25 minutes IBM presentation about their cloud story. This had obviously nothing to do with the topic of the event and later speakers pointed this out rather frankly. At least it was interesting to hear that there is a job title like &#8220;Cloud Architect&#8221;.</div>
<div id="_mcePaste">The real part of the Community Keynote started with a <em>quiet moment to honor Steve Jobs</em>.</div>
<div id="_mcePaste">Later on, various winners of the Duke choice award and JUG luminaries cared for a lighter mood again, presented their work and asked the audience for participation in their local JUGs and in the advancement of Java via the OpendJDK. The JavaPosse appeared on stage and presented a funny show.</div>
<div id="_mcePaste">It was also announced that many of the JavaOne talks will be available on parleys.com, which provide by far the best experience when it comes to viewing live-captured talks.</div>
<div id="_mcePaste">Afterwards I attended the ZeroTurnaround (JRebel) talk on classloader issues. The rather big room (~300 ppl) was packed and left the impression that many Java developers share a common pain around classloaders. It was a good talk, covering the basics and typical pifalls. The only surprise for me was *how* easily you can end up with a classloader leak.</div>
<div id="_mcePaste">In order to improve my fathering skills, I went into Ken Sipe&#8217;s talk on &#8220;Rocking the Gradle&#8221;, where I met Adam Bien. Ken is a great presenter. However, convincing the crowd is a challenge especially as many Maven users seem to suffer from the Stockholm syndrome.</div>
<div id="_mcePaste">Then onto &#8220;Visualization of Geomaps and Topic Maps with JavaFX 2.0&#8243;, which had some interesting visuals captured <a href="http://www.lodgon.com/lodgon/NEWS/Artikelen/2010/9/22_Our_CTO_presented_a_JavaOne_session_on_JavaFX.html">here</a>.</div>
<div>For me JavaOne 2011 finished with Jim Clarke and Dean Iverson on GroovyFX, where they made some really good points suggesting that Groovy is the best language to drive the JavaFX 2.0 API.</div>
<div>As a side note, James Weaver introduced me to Jim Clarke by pointing out &#8220;He is from *<strong>Canoo</strong>*&#8221;. Then the discussion went into how well-known Canoo is in the community and that all employees must be true geniuses to achieve so much with so few people <img src='http://www.canoo.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </div>
<div>Fazit: Still, JavaOne is nowhere near where it was before the Oracle acquisition both in terms of size and in terms of being an unparalleled community experience. Distribution all over various hotels just doesn&#8217;t feel right. However, meeting friends has been and still remains the most important part of JavaOne and the conference still delivers on that account.</div>
<div id="_mcePaste">Important topics were new Java versions, JavaEE (+cloud), and Java for the Desktop with 50+ talks on JavaFX. Whenever the audience was asked about which alternative languages they use, Groovy was the clear winner. It appears that in the mainstream, Groovy has become the default choice for dynamic programming on the JVM.</div>
<div id="_mcePaste">The topic of concurrent programming was in my eyes underrepresented. Guillaume and myself had simple usage of GPars in our demos but for such a big and increasingly important topic the coverage should be much more extensive.</div>
<div>Finally, some visual impressions.</div>
<div>Good-bye SF</div>
<div>Dierk Koenig</div>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-01.jpg"><img class="alignnone size-medium wp-image-2292" title="j1-01" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-01-225x300.jpg" alt="" width="225" height="300" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-02.jpg"><img class="alignnone size-medium wp-image-2293" title="j1-02" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-02-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-03.jpg"><img class="alignnone size-medium wp-image-2294" title="j1-03" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-03-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-04.jpg"><img class="alignnone size-medium wp-image-2295" title="j1-04" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-04-225x300.jpg" alt="" width="225" height="300" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-17.jpg"><img class="alignnone size-medium wp-image-2296" title="j1-17" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-17-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-25.jpg"><img class="alignnone size-medium wp-image-2297" title="j1-25" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-25-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-27.jpg"><img class="alignnone size-medium wp-image-2298" title="j1-27" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-27-300x225.jpg" alt="" width="300" height="225" /></a></p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne 2011 Wednesday</title>
		<link>http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/</link>
		<comments>http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 17:11:44 +0000</pubDate>
		<dc:creator>Dierk</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[Dierk König]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2286</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/";</script>Opinions expressed in this post are totally my own and not necessarily that of my employer. Wednesday started with the infamous &#8220;scriptbowl&#8221;, a competition between various scripting languages. This year the contenters were JRuby, Groovy, Scala, and Clojure. I wondered whether Scala considers itself a scripting language but obviously they either do or just seek [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/";</script><p><em>Opinions expressed in this post are totally my own and not necessarily that of my employer.</em></p>
<p>Wednesday started with the infamous &#8220;scriptbowl&#8221;, a competition between various scripting languages. This year the contenters were JRuby, Groovy, Scala, and Clojure. I wondered whether Scala considers itself a scripting language but obviously they either do or just seek the opportunity to be on stage.</p>
<p>To keep a long story short: <strong>Groovy has won this event for the third time in a row</strong>! This year the race was tied with Scala. Guillaume presented Groovy in the typical Groovy-idomatic style and explained every single line of his concurrent visual analyzer for Google+ postings. Dick Wall presented only non-idomatic Scala code. I interpret this as: to make Scala appealing you have to make it look like Groovy. Furthermore, he presented Kojo, which is a great interactive learning environment written in Play/Scala. In contrast to all other presentations, this was not specifically created for the scriptbowl, nor was it written by the presenter, nor was it clear how much effort went into it, nor did the audience see a single line the implementation code. How much this skewed the comparison, I leave to everybody&#8217;s judgement. The show was good, though.</p>
<p>I felt a bit sorry for Clojure. It is a great language and deserves a presentation that is more visually appealing to convince the crowd.</p>
<p>Afterwards, I attended a hands-on lab for &#8220;rapid enterprise development with netbeans&#8221;, which was essentially creating a Swing app for database CRUD actions. If I remember correctly, I did the exact same task 1997 with JBuilder. It left me with the feeling of &#8220;Yes, it works&#8221; but it is not less complex than it was 13 years ago.</p>
<p>Early afternoon Gerrit Grunwald (better known as @hansolo_) presented his work on simplified custom components for Swing. Given that he speaks about an activity that is both utterly important and highly underadvertised he would really deserve speaking at the center stage.</p>
<p>Graeme Rocher&#8217;s great session about Grails, polyglot datastores (hibernate, jpa, redis, mongodb, &#8230;), and the cloud was overshadowed by the news that Steve Jobs has died. Accidentally, the demo application was about showing a BBC News stream, which displayed this information live on stage. Both the presenter and the audience were equally touched.</p>
<p>The day officially ended with a big event at treasure island. I decided to not go there, though, and meet the former Canooey Denis Antonioli in Berkely where we had a great evening.</p>
<p>Dierk Koenig</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaOne 2011 Tuesday</title>
		<link>http://www.canoo.com/blog/2011/10/05/javaone-2011-tuesday/</link>
		<comments>http://www.canoo.com/blog/2011/10/05/javaone-2011-tuesday/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 05:33:59 +0000</pubDate>
		<dc:creator>Dierk</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Dierk König]]></category>
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2281</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/05/javaone-2011-tuesday/";</script>The Java strategy keynote started slowly with Juniper networks presenting their take on Java, which was in my eyes not really related to the topic of the keynote. It then went on into the Java roadmap with the announcement that new Java versions should come every two years, which sounded to me like an excuse [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/05/javaone-2011-tuesday/";</script><div id="_mcePaste">The Java strategy keynote started slowly with Juniper networks presenting their</div>
<div id="_mcePaste">take on Java, which was in my eyes not really related to the topic of the keynote.</div>
<div id="_mcePaste">It then went on into the Java roadmap with the announcement that new Java versions</div>
<div id="_mcePaste">should come every two years, which sounded to me like an excuse for Java 8 being</div>
<div id="_mcePaste">deferred until &#8220;Summer 2013&#8243;.</div>
<div id="_mcePaste">The real surprise was a demonstration of JavaFX running various devices like</div>
<div id="_mcePaste">tablets and smartphones running Windows, Android, and even iOS! It appeard to</div>
<div id="_mcePaste">be experimental but the sheer possibility makes a difference.</div>
<div id="_mcePaste">In addition, JavaFX will be fully open-source such that everybody is free to</div>
<div id="_mcePaste">port it to his platform of choice.</div>
<div id="_mcePaste">Over lunch, the &#8220;Java Desktop Community&#8221; assembled in a nearby restaurant.</div>
<div id="_mcePaste">That was an awesome opportunity for meeting the Swing and JavaFX luminaries just like in the years before.</div>
<div id="_mcePaste">In the early afternoon, I headed for the talk about custom JavaFX components</div>
<div id="_mcePaste">presented by Jonathan Giles and Jasper Potts. It appears customizing any</div>
<div id="_mcePaste">control is mainly done via CSS. In other words, there is no typesafe API.</div>
<div id="_mcePaste">I would rather prefer to use CSS only for &#8220;skinning&#8221; and keeping an API for</div>
<div id="_mcePaste">source-code integration.</div>
<div id="_mcePaste">It also came out that the current JavaFX version doesn&#8217;t contain e.g. a</div>
<div id="_mcePaste">ComboBox. This came as a surprise since I would expect this as being part</div>
<div id="_mcePaste">of the standard widget set. I curious what else is missing.</div>
<div id="_mcePaste">There also is a distinction between public and private APIs that didn&#8217;t</div>
<div id="_mcePaste">make immediate sense to me &#8211; other than the private parts are not yet</div>
<div id="_mcePaste">finished.</div>
<div id="_mcePaste">The afternoon JavaPosse BOF was rather disappointing. They re-told the</div>
<div id="_mcePaste">story of this morning&#8217;s keynote. Who needs that?</div>
<div id="_mcePaste">Visiting the pavillion was nice even though it was just as small as</div>
<div id="_mcePaste">last year. Anyway, I ran into a number of friends and dropped by the</div>
<div id="_mcePaste">gradleware booth. They liked my animated Gradle logo, that I implemented</div>
<div id="_mcePaste">with the Groovy-based FXG interpreter.</div>
<div id="_mcePaste">The SpringSource friends were just shutting down the booth and invited</div>
<div id="_mcePaste">me to dinner: http://t.co/LfxhjIH8 . Thanks a lot!</div>
<p>Finally, late in the evening I joined Dan Sline&#8217;s talk on WebServices in the Groovy space. The major take-away for me was a repercussion of the well-known advice: &#8220;keep it simple&#8221;.</p>
<p>Throughout the day, a lot of people approached me to tell how much they liked my talks yesterday. That was a really nice experience. Last year I had the very last talk of the conference and only this year I recognized how much of a difference the scheduling of the talks make.</p>
<p>Dierk Koenig</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/10/05/javaone-2011-tuesday/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/05/javaone-2011-tuesday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne 2011 Arrival</title>
		<link>http://www.canoo.com/blog/2011/10/02/javaone-2011-arrival/</link>
		<comments>http://www.canoo.com/blog/2011/10/02/javaone-2011-arrival/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 14:36:37 +0000</pubDate>
		<dc:creator>Dierk</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Dierk König]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2261</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/02/javaone-2011-arrival/";</script>This is gonna be a short series about my impressions of JavaOne 2011. As always, it is nice to see the town decorated for the event, even though Oracle World gets certainly much higher attention. So the immigration officer as well as the nice guy sitting next to me on a bench at Union Square [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/02/javaone-2011-arrival/";</script><p>This is gonna be a short series about my impressions of JavaOne 2011.</p>
<p>As always, it is nice to see the town decorated for the event, even though Oracle World gets certainly much higher attention. So the immigration officer as well as the nice guy sitting next to me on a bench at Union Square ask &#8220;ah &#8211; you are a programmer? Are you here for Oracle World?&#8221; &#8220;Hmpf&#8230;&#8221;</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/IMG_2737.jpg"><img class="alignnone size-medium wp-image-2262" title="town decoration" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/IMG_2737-225x300.jpg" alt="" width="225" height="300" /></a></p>
<p>Should you ask yourself &#8220;what&#8217;s in for me&#8221;? Here is a first answer: the conference material</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/IMG_2733.jpg"><img class="alignnone size-medium wp-image-2263" title="JavaOne 2011 material" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/IMG_2733-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The bag is not very practical for a software developer. I guess the selection has been taken by an Oracle employee who assumes that their conference attendees never carry any material themselves in the first place (which may be true for OracleWorld). The jacket is very nice, though.</p>
<p>And, yes, you can rate conference organizers by the badges they produce. Hey, that should not be too difficult, right? Here is what you still can make wrong:</p>
<ul>
<li>Printing the delegate&#8217;s name so small that it is hardly readable from more than 20 cm away. Now since the badge usually hangs at belly height (if not lower) this can be a bit embarrassing for both involved parties.</li>
<li>Second, the name belongs on both sides of the badge! Really! How often did you try to read the name only finding that the badge hangs the wrong way around?</li>
</ul>
<p>Otherwise, the waiting time was not too long. The speakers registration was actually empty when I arrived. The attendees registration was pretty well filled, though. But then everybody has to go to the material pickup which was for me in Moscone West 3rd floor where I waited in line for about 20 minutes and I was very early and the queue grew much longer afterwards.</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/IMG_2734.jpg"><img class="alignnone size-medium wp-image-2265" title="material pickup waiting line" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/IMG_2734-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>This made me think about my latest work on highly concurrent producer-consumer scenarios (http://people.canoo.com/mittie/kanbanflow.html) and what it would need to improve the situation.</p>
<p>Otherwise, from studying the program schedule, I found that Oracle has wisely chosen to pretty much always put two Groovy-related talks in parallel as if to make sure that nobody can escape the Groovy (\G) in these time-slots.</p>
<p>I&#8217;m eager to see what the week will bring.</p>
<p>Dierk Koenig, @mittie</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/10/02/javaone-2011-arrival/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/02/javaone-2011-arrival/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testdata generation</title>
		<link>http://www.canoo.com/blog/2011/09/26/testdata-generation/</link>
		<comments>http://www.canoo.com/blog/2011/09/26/testdata-generation/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 12:01:53 +0000</pubDate>
		<dc:creator>Erik Jan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2234</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/09/26/testdata-generation/";</script>code { font-size: 12px; overflow: auto; } We&#8217;ve all being there, we&#8217;ve all had this on a project once or maybe even more times. The assignment is to build an application, but there is no data for you to work with. There could be any number of reasons this could be the case to name [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/09/26/testdata-generation/";</script><style>
code {
font-size: 12px;
overflow: auto;
}
</style>
<p>We&#8217;ve all being there, we&#8217;ve all had this on a project once or maybe even more times. The assignment is to build an application, but there is no data for you to work with. There could be any number of reasons this could be the case to name a few, the web-service that should be connected is not done in time, the database migration is postponed. Then someone has to create database scripts with test data, or implement a test web-services. This is all a waste of time.</p>
<p>But lucky for you now there is a solution.</p>
<p>I&#8217;ve created an little <a href="https://github.com/edewit/testdata-generator">test data framework</a> that is easy to setup and will create test data automatically. So how does it work? Simple, its entry point is a method interceptor that you can wrap around anything you want, it doesn&#8217;t even have to be an implementation. So that DAO you want to use, but the database is still empty, just let the framework step into place and all the methods return the data that you want.</p>
<p>It can also be handy to create test data for you unit test. You need to test if you bean serialization works, or want to put an entity into a in memory database with <a href="http://www.dbunit.org/">dbunit</a>. Just call the framework with you bean class and the framework will return an instance filled with test data. It will read the existing annotations that you have on your entity bean an will only generate data that is valid for you bean.</p>
<p>Here is an example of how it works:<br />
<pre><code>
 //Create an instance of the Employee class and fill it with test data.
 Employee employee = TestData.createBeanInstance(Employee.class);

 //Annotations that restrict the data for first name are recognized.
 assertNotNull(employee.getFirstName());
</code></pre></p>
<p>To create a service that returns test data on it&#8217;s service methods:<br />
<pre><code>
 //create a instance of the service class/interface that will return test data
 Service exampleService = TestData.createService(Service.class);

 //this now returns a list of employee instances that are filled with test data
 List&lt;Employee&gt; employees = exampleService.findByName(&quot;name&quot;);
</code></pre></p>
<p>Create a dbunit xml file:<br />
<pre><code>
 //create a file
 File fileLocation = File.createTempFile(&quot;file&quot;, &quot;.xml&quot;);

 //populate the file with test data for the employee
 TestData.createDBUnitDataSet(Employee.class, fileLocation);
</code></pre><br />
If employee has relations with other classes, like employees have managers these objects will also be in the generated xml file.</p>
<p>To give it a spin add the following into you pom.xml<br />
<pre><code>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;dependency&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;groupId&gt;ch.nerdin&lt;/groupId&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;artifactId&gt;testdata-framework&lt;/artifactId&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;version&gt;0.10&lt;/version&gt;
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/dependency&gt;
</code></pre><br />
or if you use ivy, gradle or something else you properly know how to use this information as well.</p>
<p>So nothing holding you back to make your data driven test easier to setup, or to stub out you migration points. I&#8217;m hosting this code on <a href="https://github.com/edewit/testdata-generator" title="testdata-generator on github">github</a> so if you have issues, comments or even better contribute please do so.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/09/26/testdata-generation/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/09/26/testdata-generation/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>GWT and HTML5 Canvas, the future of the web?</title>
		<link>http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/</link>
		<comments>http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 11:35:52 +0000</pubDate>
		<dc:creator>Erik Jan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java RIA]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2217</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/";</script>The future of computing lies in mobile computing, more and more devices come on the market, tablets and phones that will connect through the Internet as technology is getting cheaper and wifi and 3g more common. That means our software will also need to run on these handheld devices, because our clients will want their [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/";</script><p>The future of computing lies in mobile computing, more and more devices come on the market, tablets and phones that will connect through the Internet as technology is getting cheaper and wifi and 3g more common. That means our software will also need to run on these handheld devices, because our clients will want their services on all platforms. This is what Java set out to do 15 years ago, so that we have the ability to write software once and run it everywhere. The problem is these new platforms, that I believe will make up a large part of the future have, until now, no Java. It would be great if we can find something that will give us the ability to write our software only once.</p>
<p>I believe that the technology that is going to deliver us this promise is called HTML5. More and more applications will run inside you browser. I&#8217;m typing this article in google docs, which is a perfect example of how applications will evolve. No need to install anything or maintain up to date versions, even an operating system could be very minimalistic (<a href="http://chrome.blogspot.com/search/label/chrome%20os">google chrome</a>). So Google is obviously sharing this vision, but also Microsoft is building it&#8217;s next version of office on something that is based on their web-browser.</p>
<p>Sadly the development language of HTML5 Javascript and not Java. Java has been around a long time and there are a lot of libraries that people have made. Would be cool if we can still use these, the answer is <a href="http://code.google.com/webtoolkit/">Googles Web Toolkit</a>. GWT provides a way to code in Java and then translate that code into Javascript. This way we can still use all that great stuff that others made.</p>
<p>A good example of this future is <a href="http://chrome.angrybirds.com/">Angry Birds</a>, you have probably heard of this game. To create this game they have taken the java implementation of <a href="http://box2d.org/">box2d</a> called <a href="http://www.jbox2d.org/">jbox2d</a> and created a javascript version of that with the help of GWT. Once that is done you can use <a href="http://en.wikipedia.org/wiki/Canvas_element">HTML5 Canvas</a> to draw the Birds and calculate their positions if they are falling. Now because they have build it this way with HTML5 this game could also work on an iPhone, but even better because android is based on java you could create from this source a android version with only one line of code.</p>
<p>Have a look at some of the great things people are building with the HTML5, be sure that your browser supports it.</p>
<ol>
<li>Drawing program <a href="http://muro.deviantart.com/">deviantART</a></li>
<li>Old style game with new technology <a href="http://www.kevs3d.co.uk/dev/arena5/">area5</a></li>
<li><a href="http://www.youtube.com/watch?v=XhMN0wlITLk">Quake GWT HTML5 port</a></li>
</ol>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java 7 Small Language Changes Screencast</title>
		<link>http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/</link>
		<comments>http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 19:53:46 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Screencast]]></category>
		<category><![CDATA[hamlet]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2212</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/";</script>This screencast demonstrates the small language changes that are part of Open JDK 7, which is available from the Open JDK website. It demonstrates multi-catch, try with resources, strings in switch statements, underscores in literals, and the diamond operator. If you have any issues watching the video below, then you may have better luck viewing [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/";</script><p>This screencast demonstrates the <a href="http://openjdk.java.net/projects/coin/">small language changes</a> that are part of <a href="http://openjdk.java.net/">Open JDK 7</a>, which is available from the Open JDK website. It demonstrates multi-catch, try with resources, strings in switch statements, underscores in literals, and the diamond operator.</p>
<p>If you have any issues watching the video below, then you may have better luck viewing it on the <a href="http://tv.jetbrains.net/videocontent/java-7-small-language-changes">JetBrains.tv</a> site. </p>
<p><object width="400" height="300" id="_ipad" data="http://tv.jetbrains.net/flowplayer/flowplayer-3.2.7.swf" type="application/x-shockwave-flash"><param name="movie" value="http://tv.jetbrains.net/flowplayer/flowplayer-3.2.7.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value='config={"clip":{"scaling":"orig","autoPlay":false,"autoBuffering":true,"url":"/sites/default/files/videos/converted/projectcoin.mp4"},"plugins":{"controls":{"stop":true}},"playlist":[{"scaling":"orig","autoPlay":false,"autoBuffering":true,"url":"http://tv.jetbrains.net/sites/default/files/videos/converted/projectcoin.mp4"}]}' /></object>
<p>I&#8217;ve made a lot of screencasts and blog posts over the years. If you like this, then there are many ways to see the other stuff I&#8217;ve done:&nbsp;</p>
<ul>
<li>My main blog:&nbsp;<a href="http://hamletdarcy.blogspot.com">http://hamletdarcy.blogspot.com</a></li>
<li>My other JetBrains.tv posts:&nbsp;<a href="http://tv.jetbrains.net/tags/hamlet">http://tv.jetbrains.net/tags/hamlet</a></li>
<li>IDEA&nbsp;related posts on my blog:&nbsp;<a href="http://hamletdarcy.blogspot.com/search/label/IDEA">http://hamletdarcy.blogspot.com/search/label/IDEA</a></li>
<li>My screencasts on YouTube:&nbsp;<a href="http://www.youtube.com/user/HamletDRC">http://www.youtube.com/user/HamletDRC</a></li>
<li>IDEA related Posts on my work blog:&nbsp;<a href="http://www.canoo.com/blog/tag/idea/">http://www.canoo.com/blog/tag/idea/</a></li>
<li>Or follow me on Twitter:&nbsp;<a href="http://twitter.com/hamletdrc">@HamletDRC</a></li>
</ul>
<p>The screencast was created with Ubuntu 10.04, PiTiVi, Audicity, gtk-RecordMyDesktop, IntelliJ IDEA, and LibreOffice. OS from top to bottom.</p>
<p>Thanks for watching, and leave a comment! </p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://tv.jetbrains.net/sites/default/files/videos/converted/projectcoin.mp4" length="10103645" type="video/mp4" />
		</item>
		<item>
		<title>Code generation in GWT with Deferred Binding (CDI-like events)</title>
		<link>http://www.canoo.com/blog/2011/07/04/code-generation-in-gwt-with-deferred-binding-cdi-like-events/</link>
		<comments>http://www.canoo.com/blog/2011/07/04/code-generation-in-gwt-with-deferred-binding-cdi-like-events/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 11:22:30 +0000</pubDate>
		<dc:creator>alberto</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Sample Apps]]></category>
		<category><![CDATA[alberto]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[event bus]]></category>
		<category><![CDATA[GIN]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2176</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/07/04/code-generation-in-gwt-with-deferred-binding-cdi-like-events/";</script>code { font-size: 12px; overflow: auto; } If you read my series on GWT dependency injection (parts: first, second and third), maybe you remember that, in part 3, I mentioned how convenient would be to reduce the boilerplate required to define events in GWT. I also mentioned how elegant I find the event definition in [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/07/04/code-generation-in-gwt-with-deferred-binding-cdi-like-events/";</script><style type="text/css">
    code {
        font-size: 12px;
        overflow: auto;
    }
</style>
<p>If you read my series on GWT dependency injection (parts: <a href='http://www.canoo.com/blog/2011/04/05/gwt-dependency-injection-recipes-using-gin'>first</a>, <a href='http://www.canoo.com/blog/2011/06/14/gwt-dependency-injection-recipes-using-gin-ii'>second</a> and <a href='http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii'>third</a>), maybe you remember that, in part 3, I mentioned how convenient would be to reduce the boilerplate required to define events in GWT. I also mentioned how elegant I find the event definition in CDI. Wouldn&#8217;t it be nice to have a lightweight event model like that in GWT?</p>
<p>Let&#8217;s see first how an event is defined and handled in CDI:<br />
<pre><code>
public class CDISample {
&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;private Event&lt;String&gt; event;

&nbsp;&nbsp;&nbsp;&nbsp;public void handler(@Observes String payload) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(payload);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String[] args) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.fire(&quot;Hello event world!&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre><br />
As you can grasp from the code, to define a new type of event in CDI it is enough to define an injected field of the parametrized class Event and the CDI container will do all the wiring for us. The parametrized type of the event defines its payload type by mean of the type parameter. To listen to the event, we just need to define a method that receives a parameter of the event payload type  and annotate it with &#8220;@Observes&#8221;.</p>
<p>While exactly this is maybe not doable in GWT (at least not yet), what about something like this?:<br />
<pre><code>
public class GWTSample {
&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;private SampleEvent event;

&nbsp;&nbsp;&nbsp;&nbsp;public void execute() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.dispatchTo(new Handler&lt;String&gt;() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void onEvent(String payload) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Window.alert(payload);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.fire(&quot;Hello event world!&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;public interface SampleEvent extends Event&lt;String&gt; {
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre><br />
While I can agree with you that it is not as elegant as the events approach in CDI, it is (IMO) a big improvement compared with, for instance, the ping / pong event definition in the demo application of my GIN series (source code <a href='http://www.canoo.com/blog/wp-content/uploads/2011/06/Part0.zip'>here</a>):<br />
<pre><code>
public class PingEvent extends GwtEvent&lt;Handler&gt; {
&nbsp;&nbsp;&nbsp;&nbsp;public static Type&lt;Handler&gt; TYPE = new Type&lt;Handler&gt;();

&nbsp;&nbsp;&nbsp;&nbsp;@Override
&nbsp;&nbsp;&nbsp;&nbsp;public Type&lt;Handler&gt; getAssociatedType() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return TYPE;
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;@Override
&nbsp;&nbsp;&nbsp;&nbsp;protected void dispatch(Handler handler) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handler.onEvent(this);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;public interface Handler extends EventHandler {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void onEvent(PingEvent event);
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre><br />
With the new approach, the resulting &#8220;PingEvent&#8221; would look like this:<br />
<pre><code>
public interface PingEvent extends Event&lt;Void&gt; {}
</code></pre><br />
If you are wondering why not to avoid defining the &#8220;PingEvent&#8221; class itself, two are the reasons:</p>
<ul>
<li>First, the events have the same payload type (Void in this case), and therefore we need explicit types to distinguish the ping event from the pong event. This also happens in CDI where we would define explicit payload types instead.</li>
<li>Second, in this implementation we will be using GWT&#8217;s deferred binding and, during the code generation phase, we need to know the parametrized type. Because of Java generics limitations, for this last it is necessary to define a new parametrized type which captures the payload type in its type parameter (wrapper).</li>
</ul>
<p>Did I convince you? If I did, let&#8217;s go on and see how to use deferred binding and dependency injection to achieve it.</p>
<h3>Letting GWT generate the boilerplate</h3>
<p>Deferred binding in GWT is a really powerful feature implemented in the GWT compiler to substitute class implementations depending in environment properties like the user agent. This way, while the developer has the illusion of using the same classes independently of the browser, the deferred binding mechanism allows to select the adequate implementation for each browser.</p>
<p>Far from being static, deferred binding allows to generate code on the fly by mean of a generator class. This happens when the developer invokes the &#8220;GWT.create()&#8221; method on an interface. For the operation to succeed, a generator for the interface must exist. This will be invoked during GWT compilation time and its result (one or more Java classes) will be compiled and linked into the resulting JS application.</p>
<p>To configure which generator should be used for which interface, it is necessary to add a new &#8220;generate-with&#8221; entry in the GWT module descriptor. In the case of the demo application, the following code has been added to the &#8220;PingPong.gwt.xml&#8221; file:<br />
<pre><code>
...
&nbsp;&nbsp;&nbsp;&nbsp;&lt;generate-with class=&quot;com.canoo.gwt.events.server.eventsfwk.EventGenerator&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;when-type-assignable class=&quot;com.canoo.gwt.events.client.eventsfwk.Event&quot;/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/generate-with&gt;
...
</code></pre></p>
<p>The contents of the &#8220;Event&#8221; and &#8220;EventGenerator&#8221; classes are the following:<br />
<pre><code>
public interface Event&lt;T&gt; {
&nbsp;&nbsp;&nbsp;&nbsp;public void fire(T payload);

&nbsp;&nbsp;&nbsp;&nbsp;public void dispatchTo(Handler&lt;T&gt; callback);

&nbsp;&nbsp;&nbsp;&nbsp;public interface Handler&lt;T&gt; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void onEvent(T payload);
&nbsp;&nbsp;&nbsp;&nbsp;}
}

public class EventGenerator extends Generator {
&nbsp;&nbsp;&nbsp;&nbsp;private static final String EVENT_IMPL = &quot;EventImpl&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;private static final CodeTemplate GWT_SIMPLE_EVENT_TEMPLATE = new GwtSimpleEventTemplate();
&nbsp;&nbsp;&nbsp;&nbsp;private static final CodeTemplate EVENT_IMPL_TEMPLATE = new EventImplTemplate();

&nbsp;&nbsp;&nbsp;&nbsp;@Override
&nbsp;&nbsp;&nbsp;&nbsp;public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String typeName) throws UnableToCompleteException {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TypeOracle typeOracle = generatorContext.getTypeOracle();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JClassType parentEventType = typeOracle.findType(Event.class.getName());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JClassType eventType = typeOracle.findType(typeName);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JClassType payloadType = findPayloadType(eventType, parentEventType);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String gwtSimpleEventImplName = generateGwtSimpleEvent(treeLogger, generatorContext, eventType, payloadType);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String eventImplTypeName = generateEventImpl(treeLogger, generatorContext, eventType, payloadType, gwtSimpleEventImplName);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return qualifyInGwtEvents(eventImplTypeName);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;private static JClassType findPayloadType(JClassType eventType, JClassType parentEventType) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JClassType interfaces[] = eventType.getImplementedInterfaces();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (JClassType anInterface : interfaces) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((anInterface instanceof JParameterizedType) &amp;&amp; (anInterface.getErasedType() == parentEventType.getErasedType())) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JParameterizedType parametrizedType = (JParameterizedType) anInterface;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return parametrizedType.getTypeArgs()[0];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new IllegalStateException(&quot;Payload type not found for: &#039;&quot; + eventType + &quot;&#039;.&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;private String generateGwtSimpleEvent(TreeLogger treeLogger, GeneratorContext generatorContext, JClassType eventType, JClassType payloadType) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String gwtSimpleEventImplName = getGwtSimpleEventImplName(eventType);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintWriter gwtSimpleEventPrintWriter = generatorContext.tryCreate(treeLogger, getEventsPackageName(), gwtSimpleEventImplName);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GWT_SIMPLE_EVENT_TEMPLATE.generate(gwtSimpleEventPrintWriter, getEventsPackageName(), gwtSimpleEventImplName, payloadType.getName());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generatorContext.commit(treeLogger, gwtSimpleEventPrintWriter);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return gwtSimpleEventImplName;
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;private String generateEventImpl(TreeLogger treeLogger, GeneratorContext generatorContext, JClassType eventType, JClassType payloadType, String gwtSimpleEventImplName) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String eventImplTypeName = getEventImplTypeName(eventType);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String eventTypeName = getEventTypeName(eventType);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintWriter eventPrintWriter = generatorContext.tryCreate(treeLogger, getEventsPackageName(), eventImplTypeName);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EVENT_IMPL_TEMPLATE.generate(eventPrintWriter, getEventsPackageName(), eventType.getQualifiedSourceName(), eventImplTypeName, eventTypeName, gwtSimpleEventImplName, payloadType.getName());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generatorContext.commit(treeLogger, eventPrintWriter);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return eventImplTypeName;
&nbsp;&nbsp;&nbsp;&nbsp;}

... (some methods omitted)
</code></pre></p>
<p>While the &#8220;Event&#8221; class contains the interface definition for our events and lives in the &#8220;client&#8221; package of our GWT application, the &#8220;EventGenerator&#8221; is a GWT specific class that resides in the &#8220;server&#8221; package of our GWT application. In order to compile the code, we will need to add a new dependency to our project: &#8220;gwt-dev-&lt;version&gt;.jar&#8221;.</p>
<p>This generator class, by mean of some templates included in the source code, generates the boilerplate classes and saves us the tedious work of writing these classes. If you want to see this in detail, please refer to the &#8220;eventsfwk&#8221; packages in the client and server part of the application (source code <a href='http://www.canoo.com/blog/wp-content/uploads/2011/06/Part1.zip'>here</a>).</p>
<h3>Using GIN to bring everything together</h3>
<p>Following what I mentioned until now, it seems that if we define an interface extending the &#8220;Event&#8221; interface (ex: &#8220;SampleEvent&#8221;) and we use the generator to generate and wire the code by mean of &#8220;GWT.create(SampleEvent.class)&#8221;, we should be able to use the result as shown in the &#8220;GWTSample&#8221; execute method. Not really.</p>
<p>One piece that is missing in the puzzle is which event bus should the underlying GWT events use. We could create an own one without loosing functionality but a better thing that we can do is to provide an injection point and provide a mechanism to make our events participate in the application&#8217;s dependency injection context and use the application&#8217;s event bus instead of an own instance.</p>
<p>To achieve this, we have created a GIN module in the &#8220;eventsfwk&#8221; package:<br />
<pre><code>
public class EventsModule extends AbstractGinModule {
&nbsp;&nbsp;&nbsp;&nbsp;@Override
&nbsp;&nbsp;&nbsp;&nbsp;protected void configure() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;requestStaticInjection(GwtSimpleEvent.class);
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre></p>
<p>This module should be installed in the application&#8217;s dependency context and it will inject an static field in the &#8220;GwtSimpleEvent&#8221; class which is the event bus used for our improved events. To install it in our application, the injection module has been modified like this (note the line &#8220;install(EventsModule.class);&#8221;):<br />
<pre><code>
@GinModules(Module.class)
public interface Injector extends Ginjector {
&nbsp;&nbsp;&nbsp;&nbsp;public static class Module extends AbstractGinModule {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@Override
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected void configure() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;install(new EventsModule());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;install(new GinFactoryModuleBuilder().build(Factory.class));

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bindConstant().annotatedWith(named(&quot;PingText&quot;)).to(&quot;Ping&quot;);

... (code omitted)
}
</code></pre></p>
<p>This means that, when the dependency injection module is initialized at the beginning of the application execution, the previously configured event bus will be statically injected in the &#8220;GwtSimpleEvent&#8221; class used by all the generated event classes.</p>
<p>I can not read minds, but maybe you are also wondering why the event fields annotated with &#8220;@Inject&#8221; get generated and injected. All in all, we don&#8217;t call anywhere &#8220;GWT.create()&#8221; to use the generator class.</p>
<p>Well, we are not doing it but GIN does. Whenever GIN finds a dependency (something annotated with &#8220;@Inject&#8221;) and that dependency has not explicitly been configured (bound in the GIN modules), GIN invokes &#8220;GWT.create()&#8221; as fallback strategy. This simple mechanism allows us to generate and inject our event in only one step.</p>
<p>Wow! This post has been &#8220;hardcore&#8221; GWT, don&#8217;t you think? Maybe even too &#8220;hardcore&#8221;. Please, just let me know if you like it and what do you think about the approach.</p>
<p>See you in a future post!</p>
<p>The source code for the initial version of the application can be downloaded <a href='http://www.canoo.com/blog/wp-content/uploads/2011/06/Part0.zip'>here</a>. The final version <a href='http://www.canoo.com/blog/wp-content/uploads/2011/06/Part1.zip'>here</a>. To see any of the applications working, unzip the corresponding file, change to the folder where the Maven pom file is stored and type the command: &#8220;mvn clean gwt:run&#8221;. After the GWT &#8220;Development mode&#8221; application starts, click on the &#8220;Launch Default Browser&#8221; button.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/07/04/code-generation-in-gwt-with-deferred-binding-cdi-like-events/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/07/04/code-generation-in-gwt-with-deferred-binding-cdi-like-events/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>GWT Dependency Injection recipes using GIN (III)</title>
		<link>http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii/</link>
		<comments>http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 10:25:32 +0000</pubDate>
		<dc:creator>alberto</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Sample Apps]]></category>
		<category><![CDATA[alberto]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[GIN]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2161</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii/";</script>code { font-size: 12px; overflow: auto; } This is the third part of a series about Dependency Injection in Google Web Toolkit using GIN. If you have not yet read the first and second parts, you maybe should do it before reading this third and last article. In this article, we will introduce two GIN [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii/";</script><style type="text/css">
    code {
        font-size: 12px;
        overflow: auto;
    }
</style>
<p>This is the third part of a series about Dependency Injection in Google Web Toolkit using GIN. If you have not yet read the <a href='http://www.canoo.com/blog/2011/04/05/gwt-dependency-injection-recipes-using-gin/'>first</a> and <a href='http://www.canoo.com/blog/2011/06/14/gwt-dependency-injection-recipes-using-gin-ii/'>second</a> parts, you maybe should do it before reading this third and last article.</p>
<p>In this article, we will introduce two GIN features: &#8220;constants binding&#8221; and &#8220;static injection&#8221;.<br />
To do this with an example, let&#8217;s refactor the &#8220;serve button&#8221; in the &#8220;Simulator&#8221; main class of the second part into an own class:<br />
<pre><code>
...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;final Button button = new Button(&quot;Serve!&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;button.addClickHandler(new ClickHandler() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void onClick(ClickEvent event) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;button.setVisible(false);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;injector.getRacket().serve();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
...
</code></pre></p>
<p>Here the new extracted &#8220;ServeView&#8221; class:<br />
<pre><code>
public class ServeView extends Button {
&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;public ServeView(final Racket racket, @Named(&quot;ServeText&quot;) String serveText) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(serveText);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;addClickHandler(new ClickHandler() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void onClick(ClickEvent event) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setVisible(false);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;racket.serve();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre></p>
<p>As you can see, the constructor of this new class is annotated with the &#8220;@Inject&#8221; annotation and receives two parameters. One of them is the racket and the other is the button&#8217;s label. In the case of the racket, it is already defined as an injectable dependency in the injector interface and in the case of the button&#8217;s label, it should be a configurable constant.<br />
GIN, by mean of &#8220;constants binding&#8221;, performs the binding of injectable dependencies to constants.<br />
Because the type of the &#8220;serveText&#8221; is String, we need to be more specific here and therefore we have annotated this dependency with the &#8220;@Named&#8221; annotation. To configure the constant value to bind to, we need to add the following line into our &#8220;InjectorModule&#8221; class:<br />
<pre><code>
...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bindConstant().annotatedWith(named(&quot;ServeText&quot;)).to(&quot;Serve!&quot;);
...
</code></pre></p>
<p>To let the other constants in the application be configured in the same way and to introduce the last GIN feature (&#8220;static injection&#8221;), let&#8217;s now modify the &#8220;Simulator&#8221; main class as follows:<br />
<pre><code>
public class Simulator implements EntryPoint {
&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;static ServeView SERVE_VIEW;

&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;static AssistedInjectionFactory FACTORY;

&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;@Named(&quot;PingText&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;static String PING_TEXT;

&nbsp;&nbsp;&nbsp;&nbsp;@Inject
&nbsp;&nbsp;&nbsp;&nbsp;@Named(&quot;PongText&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;static String PONG_TEXT;

&nbsp;&nbsp;&nbsp;&nbsp;public void onModuleLoad() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initInjection();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RootPanel.get(&quot;buttonSlot&quot;).add(SERVE_VIEW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RootPanel.get(&quot;pingSlot&quot;).add(FACTORY.createPingPongView(PING_TEXT, PingEvent.class));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RootPanel.get(&quot;pongSlot&quot;).add(FACTORY.createPingPongView(PONG_TEXT, PongEvent.class));
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;private void initInjection() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GWT.create(Injector.class);
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre></p>
<p>And our &#8220;InjectorModule&#8221; like this:<br />
<pre><code>
public class InjectorModule extends AbstractGinModule {
&nbsp;&nbsp;&nbsp;&nbsp;@Override
&nbsp;&nbsp;&nbsp;&nbsp;protected void configure() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;install(new GinFactoryModuleBuilder().build(AssistedInjectionFactory.class));

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bindConstant().annotatedWith(named(&quot;PingText&quot;)).to(&quot;Ping&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bindConstant().annotatedWith(named(&quot;PongText&quot;)).to(&quot;Pong&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bindConstant().annotatedWith(named(&quot;ServeText&quot;)).to(&quot;Serve!&quot;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;requestStaticInjection(Simulator.class);
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre></p>
<p>The &#8220;static injection&#8221; allows us to inject the static fields of a class. This happens by mean of the method &#8220;requestStaticInjection&#8221; of the GIN module class and, in our application, we use it to inject the static dependencies of the &#8220;Simulator&#8221; class.</p>
<p>This way, even when the &#8220;Simulator&#8221; class does not participate in the dependency injection context, its static members will be injected making the explicit references to the injector not required.</p>
<p>This has the side-effect of making the &#8220;Injector&#8221; getters no more necessary leaving our injector interface &#8220;empty&#8221;:<br />
<pre><code>
@GinModules(InjectorModule.class)
public interface Injector extends Ginjector {
}
</code></pre></p>
<p>Please note that, in order to get the dependency injection context configured and initialized, it is required to instantiate the &#8220;Injector&#8221; interface by mean of the &#8220;GWT.create()&#8221; method as part of the application initialization. This is done in our case within the &#8220;initInjection&#8221; method in the &#8220;Simulator&#8221; main class.</p>
<h3>Conclusions</h3>
<p>If you have read the 3 articles of this series, maybe you can remember how our demo application looked like at the beginning. While the functionality and appearance has not changed at all, the intern structure of the application is completely different.</p>
<p>In my opinion, dependency injection allows a much cleaner structure, enables configuring the application in an elegant and easy way and, when used together with an event bus, produces low-coupled high-modular applications.</p>
<p>Of course, &#8220;there is no free lunch&#8221; and using GIN means also that the development team has to learn new concepts and introduce a new framework in the application. Anyway,  dependency injection is an already proven concept and GIN is being intensively used in most of the new GWT projects and GWT frameworks.</p>
<p>While some minimal application structure optimizations could still be applied to the application, the thing that I still find improvable in it is the verbosity of the GWT events definitions. This requires writing some boilerplate classes to ensure the type safety (event handlers), and also the definition of the own event classes is too verbose, being possible to generate them automatically in most of the cases by using either GWT&#8217;s deferred binding or a JDK 6 annotation processor. If you know how the events in CDI are defined, very probably you will agree with me that such an approach would be much more elegant and concise.</p>
<p>A solution for that, even when it requires dependency injection, is more related to other topics and therefore a subject for a different thread. If you got curious, stay tuned for a future post on code generation in GWT! <img src='http://www.canoo.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<p>The source code of the application can be downloaded <a href='http://www.canoo.com/blog/wp-content/uploads/2011/06/Part3.zip'>here</a>. To see the application working, unzip the file, change to the folder where the Maven pom file is stored and type the command: &#8220;mvn clean gwt:run&#8221;. After the GWT &#8220;Development mode&#8221; application starts, click on the &#8220;Launch Default Browser&#8221; button.</p>
<p>As always, I hope that you enjoyed reading this series of articles as much as I did writing it and hope to see you soon in a future post!</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><div style="float: left; width: 140px; height: 21px; overflow: hidden; position: relative; left: 8px;"><script>//<![CDATA[
reddit_url="http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii/";
//]]&gt;
</script><script language="javascript" src="http://reddit.com/button.js?t=1"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/06/20/gwt-dependency-injection-recipes-using-gin-iii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

