
<?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>pgt &#187; spring</title>
	<atom:link href="http://pgt.de/tag/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://pgt.de</link>
	<description>t3chnology scouting GmbH</description>
	<lastBuildDate>Wed, 09 May 2012 11:54:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>W-JAX 2009 Vorträge</title>
		<link>http://pgt.de/2009/09/22/w-jax09-events/</link>
		<comments>http://pgt.de/2009/09/22/w-jax09-events/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 09:54:21 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[cep]]></category>
		<category><![CDATA[esper]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=613</guid>
		<description><![CDATA[<p> W-JAX 2009</p> <p>Die Konferenz für Java, Enterprise Architekturen &#38; SOA</p> <p>Die W-JAX ist die Konferenz für ganzheitliches technisches Know-how im Enterprise- und Webumfeld. Hier kommen die besten Experten Europas zusammen, um ihr Wissen und ihre Erfahrung an die Teilnehmer weiterzugeben. Durch ihren einzigartigen Mix an Themen verleiht die W-JAX alljährlich der Java Enterprise [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-662" style="margin: 10px;" title="wjax09_button_speaker_de" src="http://pgt.de/wp-content/uploads/2009/09/wjax09_button_speaker_de.jpg" alt="wjax09_button_speaker_de" width="128" height="128" /><br />
<strong><em>W-JAX 2009</em></strong></p>
<p><em>Die Konferenz für Java, Enterprise Architekturen &amp; SOA</em></p>
<blockquote><p>Die W-JAX ist die Konferenz für ganzheitliches technisches Know-how im Enterprise- und Webumfeld. Hier kommen die besten Experten Europas zusammen, um ihr Wissen und ihre Erfahrung an die Teilnehmer weiterzugeben. Durch ihren einzigartigen Mix an Themen verleiht die W-JAX alljährlich der Java Enterprise Community die entscheidenden Impulse.</p></blockquote>
<p><strong>Google Web Toolkit &#8211; Making a Better Web 2.0</strong><br />
Speaker: Papick G. Taboada</p>
<blockquote><p>Mit Adwords und Google Wave sind die ersten großen GWT basierten Anwendungen von Google erschienen. Mit einem optimierenden Kompiler und pfiffige Codegeneratoren werden mit GWT maßgeschneiderte JavaScript Anwendungen erstellt, die Entwicklung findet allerdings in Java statt. In dem Vortrag werden Konzepte, Neuigkeiten aus 2.0 und die aus Adwords gewonnenen Architektur &#8220;Best Practices&#8221; vorgestellt.</p></blockquote>
<p><strong>SpringSource dm Server: Fitness für die Webanwendungen</strong><br />
Speaker: Agim Emruli, Papick G. Taboada</p>
<blockquote><p>Java-EE-Webanwendungen tragen Deployment-bedingt eine große Menge an Bibliotheken mit sich. Mit OSGi werden dank einem standardisierten Modularisierungskonzept neue Wege gegangen. Lernen Sie in der Session die Möglichkeiten der Modularisierung in Java-EE-Webanwendungen auf dem OSS SpringSource dm Server kennen, damit schwergewichtige und monolithische Deployments der Vergangenheit angehören.</p></blockquote>
<p><strong>EDA in der Businessintegration</strong><br />
Speaker: Christian Dedek, Papick G. Taboada</p>
<blockquote><p>Integrationsszenarien mit ereignisgesteuerten Architekturansätzen in Java umsetzen? Dieser Vortrag bietet Ihnen eine Einführung in EDA und Complex Event Processing (CEP) und stellt den Zusammenhang zwischen EDA und SOA her. Darüber hinaus veranschaulicht er die Architektur und den Aufbau von Esper und zeigt CEP-Einsatzszenarien.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/09/22/w-jax09-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best Practices For Architecting Your GWT App</title>
		<link>http://pgt.de/2009/09/18/best-practices-for-architecting-your-gwt-app/</link>
		<comments>http://pgt.de/2009/09/18/best-practices-for-architecting-your-gwt-app/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 08:24:10 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[gin]]></category>
		<category><![CDATA[guice]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[mvp-pattern]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=600</guid>
		<description><![CDATA[<p>Just in case you haven&#8217;t seen it yet: there is very interesting talk from Ray Ryan available online:</p> <p>Google Web Toolkit Architecture: Best Practices for Architecting your GWT App</p> <p>A common question people ask is how to architect a GWT app. Ray Ryan discusses real-world learnings and patterns from the Google AdWords team and [...]]]></description>
			<content:encoded><![CDATA[<p>Just in case you haven&#8217;t seen it yet: there is very interesting talk from Ray Ryan available online:</p>
<blockquote><p><a href="http://code.google.com/intl/de-DE/events/io/sessions/GoogleWebToolkitBestPractices.html" target="_blank"><strong>Google Web Toolkit Architecture: Best Practices for Architecting your GWT App</strong></a></p>
<p>A common question people ask is how to architect a GWT app. Ray Ryan discusses real-world learnings and patterns from the Google AdWords team and elsewhere which you can use in your apps.</p></blockquote>
<p>While dependency injection on the client side in general is nothing new, having it on a GWT application (I mean on the client) is something a little harder to setup. Since we don&#8217;t have reflection and dynamic proxies&#8230; But GWT provides an alternative called deferred binding, and there is a project called <a href="http://code.google.com/p/google-gin/" target="_blank">Gin</a> providing the <a href="http://code.google.com/p/google-guice/" target="_blank">Guice DI</a> approach for GWT apps.</p>
<p>There are some other projects like gwt-dispatch and gwt-presenter that where created inspired by Ray Ryans talk.</p>
<p>So if you are doing or planning GWT development, have a look at the video and the following projects:</p>
<ul>
<li><a href="http://code.google.com/p/gwt-dispatch/" target="_blank"><strong>gwt-dispatch</strong></a>: Inspired by Ray Ryan&#8217;s Best Practices For Architecting Your GWT App session at Google I/O 2009, this is an implementation of the &#8216;command pattern&#8217; discussed at the beginning of the video.</li>
<li><a href="http://code.google.com/p/gwt-presenter/" target="_blank"><strong>gwt-presenter</strong></a>: Inspired by Ray Ryan&#8217;s Best Practices For Architecting Your GWT App session at Google I/O 2009, this is an implementation of the &#8216;Presenter&#8217; part of the Model-View-Presenter (MVP) design pattern discussed in the video.</li>
<li><a href="http://code.google.com/p/google-gin/" target="_blank"><strong>google-gin</strong></a>: GIN (GWT INjection) brings automatic dependency injection to Google Web Toolkit client-side code. GIN is built on top of Guice and uses (a subset of) Guice&#8217;s binding language. By using GWT&#8217;s compile-time Generator support, GIN has little-to-no runtime overhead compared to manual DI.</li>
</ul>
<p>If you are looking for an easy approach to use Spring in the backend with the gwt-dispatch project have a look at this posting:</p>
<ul>
<li><a href="http://pgt.de/2009/09/16/use-spring-with-gwt-dispatch/"><strong>Use Spring with GWT dispatch </strong></a></li>
</ul>
<p>If you are looking for a simple and concise approach to use autowire your Gwt-RPC servlets with components from the Spring application context, have a look at this posting:</p>
<ul>
<li><a href="http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/" target="_blank"><strong>Non invasive GWT and Spring integration (reloaded)</strong></a></li>
</ul>
<p><strong>[update]</strong></p>
<ul>
<li><a href="http://code.google.com/p/mvp4g/" target="_blank"><strong>mvp4g</strong></a>: all-in-one approach providing annotation based Event Bus, Dependency Injection, Model View Presenter, Place Service</li>
</ul>
<p><strong>[/update]</strong></p>
<p><div style="padding: 50px 10px 50px 10px; text-align:center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-8682101792434953";
/* blogposts */
google_ad_slot = "3634251742";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/09/18/best-practices-for-architecting-your-gwt-app/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Use Spring with GWT dispatch</title>
		<link>http://pgt.de/2009/09/16/use-spring-with-gwt-dispatch/</link>
		<comments>http://pgt.de/2009/09/16/use-spring-with-gwt-dispatch/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 20:14:50 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[dispatch]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=594</guid>
		<description><![CDATA[<p>From the GWT dispatch site:</p> <p>Inspired by Ray Ryan&#8217;s Best Practices For Architecting Your GWT App session at Google I/O 2009, &#8220;gwt dispatch&#8221; is an implementation of the &#8216;command pattern&#8217; discussed at the beginning of the video. </p> <p>The project uses Gin in the frontend and Guice in the backend. Guice defines a very [...]]]></description>
			<content:encoded><![CDATA[<p>From the <a href="http://code.google.com/p/gwt-dispatch/">GWT dispatch site</a>:</p>
<blockquote><p>Inspired by <a href="http://code.google.com/events/io/sessions/GoogleWebToolkitBestPractices.html">Ray Ryan&#8217;s Best Practices For Architecting Your GWT App</a> session at Google I/O 2009, &#8220;gwt dispatch&#8221; is an implementation of the &#8216;command pattern&#8217; discussed at the beginning of the video.
</p></blockquote>
<p>The project uses Gin in the frontend and Guice in the backend. Guice defines a very nice dependency injection framework, and as such, competes partially with the Springframework. But the Springframework is by far more than dependency injection, and I don&#8217;t want to miss any of its features in the backend. </p>
<p>So I took a look at the gwt dispatch sources, and decided to use Spring to setup the server side of the dispatch service. GWT dispatch extensively uses constructor injection. This works perfectly with Spring, but not with plain servlets. So I needed to rewrite the DispatchServiceServlet a little&#8230;</p>
<p><span id="more-594"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StandardDispatchServiceServlet <span style="color: #000000; font-weight: bold;">extends</span> RemoteServiceServlet
		<span style="color: #000000; font-weight: bold;">implements</span> DispatchService <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Dispatch dispatch<span style="color: #339933;">;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span>ServletConfig config<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		WebApplicationContext ctx <span style="color: #339933;">=</span> WebApplicationContextUtils
				.<span style="color: #006633;">getRequiredWebApplicationContext</span><span style="color: #009900;">&#40;</span>config.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		AutowireCapableBeanFactory beanFactory <span style="color: #339933;">=</span> ctx
				.<span style="color: #006633;">getAutowireCapableBeanFactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		beanFactory.<span style="color: #006633;">autowireBean</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Result execute<span style="color: #009900;">&#40;</span>Action<span style="color: #339933;">&lt;?&gt;</span> action<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ActionException <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> dispatch.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>action<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">RuntimeException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			log<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Exception while executing &quot;</span> <span style="color: #339933;">+</span> action.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> e<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Autowired
	@Required
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setDispatch<span style="color: #009900;">&#40;</span>Dispatch dispatch<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">dispatch</span> <span style="color: #339933;">=</span> dispatch<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Instead of using constructor injection, I use setter injection. This way the servlet can be simply added to the web.xml. The servlet lifecycle initializes servlets before they are service-ready. I use the initialization callback method to autowire the servlet instance.</p>
<p>Here is my web.xml:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contextConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/spring-conf.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4jConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/log4j.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.web.util.Log4jConfigListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.web.context.ContextLoaderListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- Servlets --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>dispatchServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>x.y.gwt.hellospringdispatch.server.support.StandardDispatchServiceServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>dispatchServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/hellospringdispatch/dispatch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- Default page to serve --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HelloSpringDispatch.html<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p> I am using annotation based configuration in my project, so the spring configuration file is very concise:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:context</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/context&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">	     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</span>
<span style="color: #009900;">         http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd</span>
<span style="color: #009900;">    &quot;</span></span>
<span style="color: #009900;">	<span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:annotation-config</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;x.y.gwt.hellospringdispatch.server&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The component scan will add any properly annotated class to the spring application context. Obviously, the classes in the GWT dispatch project are not properly annotated. So I created the classes in my projects that are needed by the DispatchService implementation:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.server.ActionHandlerRegistry</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.server.DefaultDispatch</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Autowired</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.stereotype.Component</span><span style="color: #339933;">;</span>
&nbsp;
@<span style="color: #003399;">Component</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DispatchBean <span style="color: #000000; font-weight: bold;">extends</span> DefaultDispatch <span style="color: #009900;">&#123;</span>
&nbsp;
	@Autowired
	<span style="color: #000000; font-weight: bold;">public</span> DispatchBean<span style="color: #009900;">&#40;</span>ActionHandlerRegistry handlerRegistry<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>handlerRegistry<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.server.ActionHandler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.server.DefaultActionHandlerRegistry</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Autowired</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.stereotype.Component</span><span style="color: #339933;">;</span>
&nbsp;
@<span style="color: #003399;">Component</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ActionHandlerRegistryBean <span style="color: #000000; font-weight: bold;">extends</span> DefaultActionHandlerRegistry <span style="color: #009900;">&#123;</span>
&nbsp;
	@Autowired
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setHandlers<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>ActionHandler<span style="color: #339933;">&lt;?</span>, <span style="color: #339933;">?&gt;&gt;</span> handlers<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>ActionHandler<span style="color: #339933;">&lt;?</span>, <span style="color: #339933;">?&gt;</span> actionHandler <span style="color: #339933;">:</span> handlers<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			addHandler<span style="color: #009900;">&#40;</span>actionHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The action handler registry is the place where the ActionHandlers are kept. I used the collection autowire feature to get a list of all handlers registered in the Spring application context.</p>
<p>The last step is to add ActionHandlers to the Spring context. For obvious reasons I prefer to keep my action handlers &#8220;Spring free&#8221; &#8211; that&#8217;s why I created my own annotation to identify  action handlers:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.annotation.Retention</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.annotation.RetentionPolicy</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.stereotype.Component</span><span style="color: #339933;">;</span>
&nbsp;
@<span style="color: #003399;">Component</span>
@Retention<span style="color: #009900;">&#40;</span>RetentionPolicy.<span style="color: #006633;">RUNTIME</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> @<span style="color: #000000; font-weight: bold;">interface</span> ActionHandlerBean <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I am not sure if I need to setup the retention policy &#8211; I should have a look at that&#8230;</p>
<p>All I need to do now is to add handlers to any package below the server package. The Spring component scan will automatically find the handlers and add them to the Spring application context and further inject them to the handler registry.</p>
<p>Here is a simple ActionHandler:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.server.ActionHandler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.server.ExecutionContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.customware.gwt.dispatch.shared.ActionException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Autowired</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Required</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">x.y.gwt.hellospringdispatch.server.support.ActionHandlerBean</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">x.y.gwt.hellospringdispatch.shared.SendGreeting</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">x.y.gwt.hellospringdispatch.shared.SendGreetingResult</span><span style="color: #339933;">;</span>
&nbsp;
@ActionHandlerBean
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SendGreetingHandler <span style="color: #000000; font-weight: bold;">implements</span>
		ActionHandler<span style="color: #339933;">&lt;</span>SendGreeting, SendGreetingResult<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> SendGreetingHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> SendGreetingResult execute<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> SendGreeting action,
			<span style="color: #000000; font-weight: bold;">final</span> ExecutionContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ActionException <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> name <span style="color: #339933;">=</span> action.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> SendGreetingResult<span style="color: #009900;">&#40;</span>name, <span style="color: #0000ff;">&quot;Hello from the server&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> cause<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> ActionException<span style="color: #009900;">&#40;</span>cause<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> rollback<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> SendGreeting action,
			<span style="color: #000000; font-weight: bold;">final</span> SendGreetingResult result, <span style="color: #000000; font-weight: bold;">final</span> ExecutionContext context<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> ActionException <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Nothing to do here</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Class<span style="color: #339933;">&lt;</span>SendGreeting<span style="color: #339933;">&gt;</span> getActionType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> SendGreeting.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//	</span>
<span style="color: #666666; font-style: italic;">//	@Autowired</span>
<span style="color: #666666; font-style: italic;">//	@Required</span>
<span style="color: #666666; font-style: italic;">//	public void setCustomerService(CustomerService gibher) {</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//	}</span>
<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I am very happy with this approach as it allows me to add new action (command) handlers without any configuration overhead. Simply dropping the implementation somewhere in the server package will do all the magic.</p>
<p><div style="padding: 50px 10px 50px 10px; text-align:center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-8682101792434953";
/* blogposts */
google_ad_slot = "3634251742";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/09/16/use-spring-with-gwt-dispatch/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Non invasive GWT and Spring integration (reloaded)</title>
		<link>http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/</link>
		<comments>http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 20:14:22 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=431</guid>
		<description><![CDATA[<p class="wp-caption-text">New project layout</p> <p>Here is my overdue update to my Non invasive GWT and Spring integration blog post from early 2008. Since then we have had the GWT 1.6 and GWT 1.7 releases: One of the biggest changes to GWT 1.6 is a new project structure. The old output format has been replaced [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_454" class="wp-caption alignright" style="width: 219px"><a href="http://pgt.de/wp-content/uploads/2009/07/Bild-14.png"><img src="http://pgt.de/wp-content/uploads/2009/07/Bild-14-209x300.png" alt="New project layout" title="Project layout" width="209" height="300" class="size-medium wp-image-454" /></a><p class="wp-caption-text">New project layout</p></div>


<p>Here is my overdue update to my <a href="http://pgt.de/2008/02/14/non-invasive-gwt-and-spring-integration/" target="_blank">Non invasive GWT and Spring integration</a> blog post from early 2008. Since then we have had the <a href="http://code.google.com/intl/de-DE/webtoolkit/doc/1.6/ReleaseNotes_1_6.html" target="_blank">GWT 1.6</a> and <a href="http://code.google.com/intl/de-DE/webtoolkit/doc/1.7/ReleaseNotes_1_7.html" target="_blank">GWT 1.7</a> releases:

<blockquote>One of the biggest changes to GWT 1.6 is a new project structure. The old output format has been replaced by the standard Java web app "expanded war" format, and the actual directory name does default to "/war". Note that the war directory is not only for compiler output; it is also intended to contain handwritten static resources that you want to be included in your webapp alongside GWT modules (that is, things you'd want to version control).</blockquote>

<p>As a matter of fact, now we finally can (must) manage the web.xml file ourselves:


<blockquote>Projects with server-side code (GWT RPC) must configure a web.xml file at /war/WEB-INF/web.xml. This web.xml file must define and publish any servlets associated with the web application.
</blockquote>

<p> This is a little pain for really much gain, and that's why I am writing this post after all...

<span id="more-431"></span>

<p>

<p>Starting a Springframework ApplicationContext in a Java EE compiient web-application is well known and documented <a href="http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-other-web-configuration" target="_blank">in the Springframework reference</a>:


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE web-app</span>
<span style="color: #00bbdd;">    PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot;</span>
<span style="color: #00bbdd;">    &quot;http://java.sun.com/dtd/web-app_2_3.dtd&quot;&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contextConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/spring-conf.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4jConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/log4j.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.web.util.Log4jConfigListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.web.context.ContextLoaderListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- Servlets... --&gt;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- Default page to serve.. --&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>




<p>There aren't many beans in my spring configuration files as I am using annotation based configuration in my apps. Here a sample spring confuguration taken from one of my sample projects:


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:context</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/context&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">	     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</span>
<span style="color: #009900;">         http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd</span>
<span style="color: #009900;">    &quot;</span></span>
<span style="color: #009900;">	<span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:annotation-config</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;x.y.gwt.hellospring.server&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;basicTextEncryptor&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jasypt.encryption.pbe.StandardPBEStringEncryptor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;algorithm&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;PBEWithMD5AndDES&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;keyObtentionIterations&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;1000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;s0990w8eh0c8hf08aefh8hGf9egf9aefea8f&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>




<p>So this is (despite of the missing log4j.xml config) the configuration setup I am using on GWT 1.6 and GWT 1.7 projects in order to bootstrap an application context.

<p>The next step is to implement the dependency injection of spring managed beans into my GWT RPC serverside implementation. I will be using the annotation based config provided by the Springframework. 

<p>This is how the dependency injection in my GWT RPC services looks like:


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * The server side implementation of the RPC service.
 */</span>
@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;serial&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EncodingServiceImpl 
<span style="color: #000000; font-weight: bold;">extends</span> AutoinjectingRemoteServiceServlet
<span style="color: #000000; font-weight: bold;">implements</span> EncodingService <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> IEncodingService encodingService<span style="color: #339933;">;</span>
&nbsp;
	@Autowired
	@Required
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEncodingService<span style="color: #009900;">&#40;</span>IEncodingService encodingService<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">encodingService</span> <span style="color: #339933;">=</span> encodingService<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Service implementation ommited here...</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>




<p>EncodingServiceImpl is the server side GWt RPC implementation, while EncodingService is the GWT service I am setting up. The managed bean in my spring configuration implements IEncodingService (and uses the great <a href="http://www.jasypt.org/"  target="_blank">jasypt</a> lib). I am using the annotations to configure the dependency injection.

<p>All I have to do now, is "autowire" my RPC servlet during initialization. Since this is not going to be the only GWT RPC service needing dependency injection I introduced the AutoinjectingRemoteServiceServlet class:


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AutoinjectingRemoteServiceServlet <span style="color: #000000; font-weight: bold;">extends</span> RemoteServiceServlet <span style="color: #009900;">&#123;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span>ServletConfig config<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		WebApplicationContext ctx <span style="color: #339933;">=</span> WebApplicationContextUtils
				.<span style="color: #006633;">getRequiredWebApplicationContext</span><span style="color: #009900;">&#40;</span>config.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		AutowireCapableBeanFactory beanFactory <span style="color: #339933;">=</span> ctx
				.<span style="color: #006633;">getAutowireCapableBeanFactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		beanFactory.<span style="color: #006633;">autowireBean</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>




<p> There is not much to say about this class. During the initializiation of the RPC Servlet (remember: GWT uses servlets as the foundation technology on the server side implementation of GWT RPC. Being so, the GWT RPC service implementation "lives" in the same lifecycle as any other servlet. I am using the initialization step to get a reference to the ApplicationContext. After that I use the autowire bean method to autowire the servlet automatically.

<p>If you prefer to directly expose spring beans, you should have a look at <a href="http://code.google.com/p/spring4gwt/"  target="_blank">http://code.google.com/p/spring4gwt/</a>.



 ]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Multichannel communication and social networking</title>
		<link>http://pgt.de/2009/05/12/multichannel-communication-and-social-networking/</link>
		<comments>http://pgt.de/2009/05/12/multichannel-communication-and-social-networking/#comments</comments>
		<pubDate>Tue, 12 May 2009 13:17:35 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[From nerds to nerds]]></category>
		<category><![CDATA[people and business]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=344</guid>
		<description><![CDATA[Multi channel communication and social networking with twitter, blogs and skype. [...]]]></description>
			<content:encoded><![CDATA[<p>networking #rulez</p>
<p>es ging bei Skype los:</p>
<blockquote><p>[12.05.09 12:19:46] Falk Sippach: hast du eine idee, wie ich die komplette springide als zip runterladen kann<br />
[12.05.09 12:20:07] Falk Sippach: ich finde nur den link auf die update-site</p></blockquote>
<p>Ich Google mich also auf folgenden Blog-Posting:</p>
<blockquote><p><a href="http://blog.springsource.com/2009/05/07/springsource-tool-suite-now-free/" target="_blank">http://blog.springsource.com/2009/05/07/springsource-tool-suite-now-free/</a></p></blockquote>
<p>wo ich folgende Stelle finde:</p>
<blockquote><p>Speaking about interaction with the team, I’d like to encourage every Spring developer and Tomcat user out there to download STS, give it a try and get involved in the community through our forums, JIRA, <a href="http://twitter.com/cdupuis">Twitter</a> (<a href="http://twitter.com/#search?q=%23STS" target="_blank">#STS</a>) and email (sts AT springsource DOT com). As a user you can now actively influence where STS is heading and what would be of value to you. Furthermore you don&#8217;t need to spend time figuring where to get certain tooling features or what the differences between Spring IDE and STS are.</p></blockquote>
<p>Da ich Christian Dupuis ja nur &#8220;ein bisschen&#8221; kenne (#speakerslounge #jax09), habe ich keinen #Skype Kontakt von ihm.</p>
<p>Tja, aber Christian ist ja auf dem Weg zu Juergen Hoeller</p>
<blockquote><p><a href="https://twitter.com/cdupuis/status/1770496144 " target="_blank">https://twitter.com/cdupuis/status/1770496144 </a></p></blockquote>
<p>Juergen habe ich in meiner Kontaktliste in Skype, ist aber leider offline, social-network-Sackgasse&#8230;</p>
<p>Also habe ich ihn @cdupius &#8220;angeTwittert&#8221;:</p>
<blockquote><p><a href="https://twitter.com/pgtaboada/statuses/1772196266" target="_blank">https://twitter.com/pgtaboada/statuses/1772196266</a></p></blockquote>
<p>woraufhin ich auch prompt eine Antwort bekommen habe:</p>
<blockquote><p><a href="https://twitter.com/cdupuis/statuses/1772514228" target="_blank">https://twitter.com/cdupuis/statuses/1772514228</a></p></blockquote>
<p>Natürlich habe ich mich gleich bedankt und dabei auch Jürgen gegrüsst #networking</p>
<blockquote><p><a href="http://twitter.com/pgtaboada/status/1772918127" target="_blank">http://twitter.com/pgtaboada/status/1772918127</a></p></blockquote>
<p>Und die wertvolle Info gleich per Skype an Falk weitergegeben:</p>
<blockquote><p>[12.05.09 14:42:51] Papick G. Taboada: https://twitter.com/cdupuis/statuses/1772514228<br />
[12.05.09 14:42:53] Papick G. Taboada: here we go<br />
[12.05.09 14:42:54] Papick G. Taboada: :-)<br />
[12.05.09 14:43:16] Falk Sippach: danke<br />
[12.05.09 14:43:23] Falk Sippach: habs bereits runtergeladen<br />
[12.05.09 14:43:36] Papick G. Taboada: :-)</p></blockquote>
<p>Ist nicht nur ein Spielzeug&#8230;</p>
<p>:-)</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/05/12/multichannel-communication-and-social-networking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SpringSource Produktivitätsoffensive</title>
		<link>http://pgt.de/2009/05/09/springsource-produktivitatsoffensive/</link>
		<comments>http://pgt.de/2009/05/09/springsource-produktivitatsoffensive/#comments</comments>
		<pubDate>Sat, 09 May 2009 09:11:19 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[people and business]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=327</guid>
		<description><![CDATA[SpringSource, Spring Roo, SpringSource Tool Suite [...]]]></description>
			<content:encoded><![CDATA[<p>Diese Woche haben wir zwei großartige Nachrichten aus der SpringSource Ecke bekommen:</p>
<ul>
<li><a href="http://www.springsource.org/roo">Spring Roo</a></li>
<li><a href="http://www.springsource.org/node/1394">SpringSource Tool Suite is Now Free!</a></li>
</ul>
<p><div id="attachment_328" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-328" title="STS" src="http://pgt.de/wp-content/uploads/2009/05/stsscreenshot03-300x210.jpg" alt="stsscreenshot03" width="300" height="210" /><p class="wp-caption-text">STS</p></div></p>
<p>Bei <em>STS</em> handelt es sich um eine Eclipse-basierte IDE, die bisher nur den &#8220;Enterprise- Kunden&#8221; vorbehalten war. Es ist die Zusammenstellung von Spring IDE und andere Plugins aus der SpringSource Softwareschmiede:</p>
<blockquote><p>Key Highlights von der <a href="http://www.springsource.com/products/sts">Produktseite</a>:</p>
<ul>
<li> <strong>Greater Productivity</strong></li>
<li><strong>OSGi Made Easy</strong></li>
<li><strong>Developer Onramp to Virtualization</strong></li>
<li><strong>Task Focused Development</strong></li>
<li><strong>Guided Learning</strong></li>
</ul>
</blockquote>
<p>Bei <em>Spring Roo</em> handelt es sich letztendlich um die Umsetzung von Rod Johnsons Aussage:</p>
<blockquote><p>&#8220;<em>We (the Java EE Community) are not picking the low hanging fruits</em>&#8220;</p></blockquote>
<p>Und damit hat er recht: wir haben mit <em>Java EE</em> sehr mächtige Frameworks, scheitern aber kläglich daran, daraus ordentliche &#8220;<em>full stack application frameworks</em>&#8221; zu bauen. Die Quittung haben wir mit &#8220;<em>Ruby on Rails</em>&#8221; und Konsorten bekommen: erst haben wir sie belächelt, dann diese für Prototypen eingesetzt. Jetzt  lautet es &#8220;success stories&#8221; aus allen Ecken. Mit <em>Spring Roo</em> bekommen wir ein &#8220;<em>full stack application framework</em>&#8220;, das diesmal aber in Java mit Java Tools und Technologien umgesetzt wurde (Maven2, JPA, JUnit, Spring MVC, Spring Security, u.s.w.).</p>
<blockquote><p>&#8220;Roo delivers productivity without compromise. Spring Roo melds the development advantages that have emerged in dynamic frameworks with the robustness, reliability, performance and familiarity of enterprise Java. Roo is designed for developers that want to build Java applications faster than ever without having to learn a new language or syntax. Roo is designed to be incorporated into the majority of development environments including visual development tools and utilizes the widely understood implementations of relevant standards.&#8221; (Quelle: <a href="http://www.springsource.org/roo" target="_blank">http://www.springsource.org/roo</a>)</p></blockquote>
<p>Die <em>Spring Roo</em> Seite verrät zur Zeit sehr wenig &#8211; nicht einmal, wie man <em>Spring Roo</em> aktuell <a title="Download Roo 1.0.0.A1" href="http://dist.springframework.org/milestone/ROO/spring-roo-1.0.0.A1.zip" target="_blank">runterladen kann</a>. Hier muss man die Blogosphäre aus dem Umfeld im Radar haben:</p>
<ul>
<li><a href="http://blog.springsource.com/2009/05/01/roo-part-1/">Jump into Roo for extreme Java productivity</a></li>
<li><a href="http://stsmedia.net/introducing-spring-roo/">Introducing Spring ROO: Part 1</a></li>
<li><a href="http://www.theserverside.com/news/thread.tss?thread_id=54496" target="_blank">Getting Code Generation Right for Java and Spring</a></li>
</ul>
<p>Ich habe das Gefühl, dass die Java-Gemeinde endlich aufatmen kann, denn jetzt hat man eine Alternative zu <em>Ruby on Rails</em>, <em>Grails</em> und Co. Es wird sich zeigen, wie tief <em>Spring Roo</em> in den Kinderschuhen steckt, und ob SpringSource &#8220;den Kampf&#8221; an einer weitere Front aufnehmen kann. SpringSource scheint wieder die OSS Community entdeckt zu haben (die Community darf sogar  bei der <a href="http://cloud.springsource.com/vote/" target="_blank">Namensfindung</a> mithelfen), und spielt zu meiner Freude die Karte gross aus.</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/05/09/springsource-produktivitatsoffensive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to use the SimpleHttpInvokerServiceExporter</title>
		<link>http://pgt.de/2009/02/26/how-to-use-the-simplehttpinvokerserviceexporter/</link>
		<comments>http://pgt.de/2009/02/26/how-to-use-the-simplehttpinvokerserviceexporter/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 12:15:04 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=275</guid>
		<description><![CDATA[How to use the SimpleHttpInvokerServiceExporter (JRE 1.6 HttpServer and spring remoting) [...]]]></description>
			<content:encoded><![CDATA[<p>The JRE 1.6 ships with small HTTP-Server implementation. <a title="HTTP Server Javadocs" href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/overview-summary.html" target="_blank">The Javadocs can be found here</a>.</p>
<p>Spring has provides many different ways of configuring remote access to beans (aka spring remoting), but the <a href="http://static.springframework.org/spring/docs/2.5.x/reference/remoting.html" target="_blank">remoting documentation</a> fails when it comes to the usage of the HTTP Service exporter that works with the new JRE 1.6 HttpServer.</p>
<p>So here is a small example on how wire up the embedded JDK <a title="JDK 1.6 HttpServer Javadoc" href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html" target="_blank">HttpServer</a> and spring remoting.</p>
<p><span id="more-275"></span></p>
<p>First we need some service that we would like to expose as a remote service. For this short example I am using an very simple &#8220;EchoService&#8221; as follows:</p>
<p>The interface:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">x.y</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> EchoService <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #003399;">String</span> echo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and some implementation:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">x.y</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.slf4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.slf4j.LoggerFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.stereotype.Service</span><span style="color: #339933;">;</span>
&nbsp;
@Service<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;echoServiceLocalImpl&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EchoServiceImpl <span style="color: #000000; font-weight: bold;">implements</span> EchoService <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger log <span style="color: #339933;">=</span> LoggerFactory
			.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>EchoServiceImpl.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> echo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		log.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Echoing: &quot;</span> <span style="color: #339933;">+</span> message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> message.<span style="color: #006633;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you can see in the implementation, I am using annotation based configuration in this example.</p>
<p>That is pretty much all implementation I need to provide the services. Now I have to setup the HttpServer and configure the service exporting. The HttpServer implementation provided by the JRE uses factory methods for the setup. It is a pain to configure beans using factory-methods in the spring xml, and that&#8217;s why we usually create a <a title="FactoryBean interface javadoc" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/FactoryBean.html" target="_blank">FactoryBean</a> to wrap up the ugly initialization of a bean. Fortunately we do not have to do this ourselves, the Springframework already provides (since version 2.5.1) <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/remoting/support/SimpleHttpServerFactoryBean.html" target="_blank">such a factory bean</a>.</p>
<p>So here is the context xml configuration file I am using to start the server and to export the services:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</span>
<span style="color: #009900;">		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd</span>
<span style="color: #009900;">		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:context</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/context&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:util</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/util&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:annotation-config</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;x.y&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;httpServer&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.remoting.support.SimpleHttpServerFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;contexts&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;util:map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;/echoService&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.remoting.httpinvoker.SimpleHttpInvokerServiceExporter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;serviceInterface&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;x.y.EchoService&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;service&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;echoServiceLocalImpl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/util:map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;port&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;2345&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;remotedEchoService&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;qualifier</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;remoted&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;serviceUrl&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://localhost:2345/echoService&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;serviceInterface&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;x.y.EchoService&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>As you can see I also added the xml snippet required for the clients that will be using the remoted service. The qualifier will help me to get the remoted instance and not the local one, hence both instances are kept in my application context in this sample. A simple testcase would look this way:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">x.y</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertTrue</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.runner.RunWith</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Autowired</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Qualifier</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.test.context.ContextConfiguration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.test.context.junit4.SpringJUnit4ClassRunner</span><span style="color: #339933;">;</span>
&nbsp;
@RunWith<span style="color: #009900;">&#40;</span>SpringJUnit4ClassRunner.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
@ContextConfiguration<span style="color: #009900;">&#40;</span>inheritLocations <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>, locations <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;classpath:/META-INF/beans.xml&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestRemoting <span style="color: #000000; font-weight: bold;">extends</span> AbstractJUnit4SpringContextTests <span style="color: #009900;">&#123;</span>
&nbsp;
	@Autowired<span style="color: #009900;">&#40;</span>required <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
	@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;remoted&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">private</span> EchoService echoService<span style="color: #339933;">;</span>
&nbsp;
	@Test
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> echoTestUsingConfiguredClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> echo <span style="color: #339933;">=</span> echoService.<span style="color: #006633;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Echoed correctly&quot;</span>, <span style="color: #0000ff;">&quot;TEST&quot;</span>, echo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		assertTrue<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Should not be the implementation&quot;</span>, <span style="color: #339933;">!</span>echoService.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
				.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>EchoServiceImpl.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Test
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> echoTestManually<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		HttpInvokerProxyFactoryBean proxy <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpInvokerProxyFactoryBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		proxy.<span style="color: #006633;">setServiceInterface</span><span style="color: #009900;">&#40;</span>EchoService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		proxy.<span style="color: #006633;">setServiceUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://localhost:2345/echoService&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		proxy.<span style="color: #006633;">afterPropertiesSet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		EchoService echoService <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EchoService<span style="color: #009900;">&#41;</span> proxy.<span style="color: #006633;">getObject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> echo <span style="color: #339933;">=</span> echoService.<span style="color: #006633;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Echoed correctly&quot;</span>, <span style="color: #0000ff;">&quot;TEST&quot;</span>, echo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		assertTrue<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Should not be the implementation&quot;</span>, <span style="color: #339933;">!</span>echoService.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
				.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>EchoServiceImpl.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The first test method <strong>echoTestUsingConfiguredClient</strong> does use the bean in the spring context (autowired, using the qualifier to get the right instance), the second method <strong>echoTestManually</strong> creates a proxy bean manually.</p>
<p>Both of them use the remoted proxy and not the local service implementation during the test.</p>
<p>I used maven to setup the eclipse project and to manage my project dependencies.<br />
The project can be downloaded <a href="http://pgt.de/wp-content/uploads/2009/02/simpleexporter.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2009/02/26/how-to-use-the-simplehttpinvokerserviceexporter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Stop this “my support is better than yours” discussion!</title>
		<link>http://pgt.de/2008/08/30/stop-this-my-support-is-better-than-yours-discussion/</link>
		<comments>http://pgt.de/2008/08/30/stop-this-my-support-is-better-than-yours-discussion/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 10:46:07 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=204</guid>
		<description><![CDATA[<p>Ok, someone is making money with support. Ok, someone is not contributing to OSS. But wait &#8211; is offering support not exactly that? Contributing to OSS by doing the dirty work no one wants to do?</p> <p>That’s why I do not agree entirely with the label “parasites”. It is not easy to offer support, [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Ok, someone is making money with support.<br />
Ok, someone is not contributing to OSS.<br />
But wait &#8211; is offering support not exactly that? Contributing to OSS by doing the dirty work no one wants to do?</p></blockquote>
<p>That’s why I do not <a href="http://blog.springsource.com/main/2008/08/22/who-is-the-chief-of-the-apache-projects/" target="_blank">agree entirely with the label “parasites”</a>. It is not easy to offer support, IMHO it is a Job that no one likes to do. I don’t know if it is true for everyone &#8211; but I am very happy to be a developer and not to be a support guy.</p>
<p><span id="more-204"></span></p>
<p>It just happens that it is exactly this job is actually needed, and hence, can be monetized.</p>
<ul>
<li>Don’t tell me that those few developers really contributing to an OSS project have time to provide support as it is required today.</li>
<li>Don’t tell me that somebody not contributing is not capable to offer support. If you really believe that, you don’t understand what it means to offer support.</li>
<li>Don’t tell me that developers can offer better support.</li>
</ul>
<p>So even if all OSS developers start working 24h a day (I am sure many already do) &#8211; would they be supply enough service to cover the demand? How many people do need support, now many contributors do we have?</p>
<p>I remember reading somewhere on a OSS page:  “great support by the community”. What does this mean? Easy to tell: <strong>we can’t or we won’t offer support.</strong></p>
<p>I believe that neither Spring nor any other OSS product would have come that far without the many consultants and supporters we have working very hard today. So someone is monetizing support? Fine! It will open the doors for enterprise OSS acceptance. Is someone offering training for OSS technologies? GREAT!</p>
<p>Does it feel like it is stealing work? No it is not.</p>
<p>Sure &#8211; we live in interesting times. Don’t have a working business plan for your successfull OSS product? I tell you what: go offer support for it. But be warned: it is hard work, it is mostly badly payed, it does not scale, and you will stop working with computers and start working with people.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2008/08/30/stop-this-my-support-is-better-than-yours-discussion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SpringSource announces an application plattform</title>
		<link>http://pgt.de/2008/05/05/springsource-announces-an-application-plattform/</link>
		<comments>http://pgt.de/2008/05/05/springsource-announces-an-application-plattform/#comments</comments>
		<pubDate>Mon, 05 May 2008 07:51:54 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[gpl]]></category>
		<category><![CDATA[java ee]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=124</guid>
		<description><![CDATA[ <p>SpringSource recently announced the Spring Aplication Platform, and this announcement is generating a lot of fuss. Google has recently launched the Google App Engine. From an Java enterprise developers point of view it is shamelessly easy to use, deploy, etc. Well, unfortunately it only takes Python apps for now, but it is stated [...]]]></description>
			<content:encoded><![CDATA[<div class="entry-content">
<p>SpringSource recently announced the <a href="http://feeds.feedburner.com/%7Er/Interface21TeamBlog/%7E3/280954280/" target="_blank">Spring Aplication Platform</a>, and this announcement is generating a lot of fuss. Google has recently launched the <a href="http://code.google.com/appengine/" target="_blank">Google App Engine</a>. From an Java enterprise developers point of view it is shamelessly easy to use, deploy, etc. Well, unfortunately it only takes Python apps for now, but it is stated that there will be more languages supported in the future. But it’s Google again putting its finger into the Java EE wound (first GWT with webapps, then Android shaking the Java ME world, and now App Engine showing how runtimes should look like).</p>
<p>Looking at Googles App Engine I thought how nice it would be to have the deployment, packaging and runtime of Java EE applications redesigned.  Those deployment descriptors really suck. As it seems (heard it at the Jax from speakers “off the record”) Java Dynamic Modules and Java Superpackages aren’t going to make it into the next Java relase &#8211; Java 7.</p>
<p>From this point of view, the Spring Application Platform is bringing fresh air into the Java EE development. The Java EE dream of a runtime didn’t come through. Modularization got lost somewhere in the way. Packaging and deployment is a nightmare, and tools didn’t solve the problem. Since Java EE 5 is being adopted very slowly and Java EE 6 is really far away, this is surely the best time to drop in an alternative. Well done. Though beeing an alternative, there seems to be <a href="http://www.theserverside.com/news/thread.tss?thread_id=49243#251548" target="_blank">some level of commitment regarding Java EE deployment support</a>.</p>
<p>IMHO the real shock came with the change in licensing terms. We are used to SpringSource licensing their products under the Apache 2 license. The license is clear and accepted by most companies. The Spring Application Platform is licensed under the GPL. GPL is, IMHO, the most misunderstood license we have in the OSS. I do not have nothing against the GPL, I only have a problem with the different interpretations. And if a license can be misunderstood, how can we rely on it? I won’t start another blog about how GPL works &#8211; please go read the GPL and the GPL FAQ, it’s worth it. A nice reply from Will Hartung about GPL on the TSS thread <a href="http://www.theserverside.com/news/thread.tss?thread_id=49243#251572" target="_blank">can be found here</a>.</p>
<blockquote><p>Does nobody actually, you know, READ these licenses?<br />
Users who change GPL code have absolutely no, zero, zippo, big bagel, goose egg obligation to give back to “the community”.<br />
I can take this code, make all the changes I want, sell it to my customers, and you can come knock on my door saying “I want the code, it’s GPL! Give me the code!” and I can nod and smile knowingly and tell you to pound sand. “Give me $100K and I’ll give you the software.</p></blockquote>
<p>Thanks Will. It’s beautiful.</p>
<p>Rod argues that if someone takes the code, makes changes and starts selling it, this someone will, sooner or later, have to provide the source code to a major number of customers and hence the changes will be available for the community, especially for SpringSource. Rod, I hope I did quote you right, sorry if I didn’t.</p>
<p>Another great statement from Will comes a <a href="http://www.theserverside.com/news/thread.tss?thread_id=49243#251590" target="_blank">few postings later</a>:</p>
<blockquote><p>But you certainly aren’t going to take back contributions that don’t have at least shared copyright, because as soon as that happens you can’t relicense the whole under something other than GPL. So, there’s not a whole lot of value to the community there.</p></blockquote>
<p>Later Rod <a href="http://www.theserverside.com/news/thread.tss?thread_id=49243#251853" target="_blank">makes a nice statement</a> about what’s ok:</p>
<blockquote><p>1. Using the platform to run closed source applications is OK. This immediately covers the vast majority of companies and developers who are end users. This would cover for example, software use by companies like Google, banks, media companies etc.<br />
2. Modifying and extending the platform and “hiding” (closing) it is OK, <em>unless you redistribute</em>. So if you modify it in your own company, or you modify it and distribute your modifications in GPL open source, that’s OK. If you modify it and distribute a closed source product including those modifications, that is not OK. This would exclude Oracle, for example, from modifying the server and redistributing it as a closed source product. We believe this is a Good Thing.<br />
3. It is fine to run closed source applications on the platform. Whether you can redistribute them as one closed product (bundling the platform) would depend if they constituted a derivative work.</p></blockquote>
<p>I liked <a href="http://www.theserverside.com/news/thread.tss?thread_id=49243#251858" target="_blank">this one too</a>:</p>
<blockquote><p>Wow, 174 replies and counting, mostly about GPL, hmm, i knew I should have done law!!! ha ha<br />
Lets stay technical please, even though it clearly doesn’t pay !!!</p></blockquote>
<p>This is perfectly showing how GPL, although commonly used in OSS projects, is really badly misunderstood by people.</p>
<p>IMHO GPL licensing was a bad idea. SpringSource targets the enterprise, the enterprise dislikes GPL, that’s a fact. Linux seems to be the exception to the rule. It’ nice to see how SpringSource understands GPL &#8211; but this understanding is not binding. What if someone wakes up next week and says &#8211; “oh sorry, I think we have to rethink our GPL understanding….”</p></div>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2008/05/05/springsource-announces-an-application-plattform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Anforderungen 2.0: Gruppen, Rollen, Flexibilität</title>
		<link>http://pgt.de/2008/04/28/security-anforderungen-20-gruppen-rollen-flexibilitat/</link>
		<comments>http://pgt.de/2008/04/28/security-anforderungen-20-gruppen-rollen-flexibilitat/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 09:00:04 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[jira]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=158</guid>
		<description><![CDATA[<p>Was habe ich mich gefreut, als Jira das Sicherheitskonzept um Rollen (Projekt-Rollen) erweitert hat. Statt Rechtekonfigurationen an Benutzergruppen zu binden, hat man jetzt die Möglichkeit Rechte an bestimmte Rollen zu binden. Für jedes Projekt folgt dann die Benutzer/ Rolle Zuweisung: dadurch ergibt sich letztlich, welche Rechte ein Benutzer für ein bestimmtes Projekt haben wird.</p> [...]]]></description>
			<content:encoded><![CDATA[<p>Was habe ich mich gefreut, als Jira das Sicherheitskonzept um Rollen (Projekt-Rollen) erweitert hat. Statt Rechtekonfigurationen an Benutzergruppen zu binden, hat man jetzt die Möglichkeit <a href="http://www.atlassian.com/software/jira/docs/latest/project_role_management.html" target="_blank">Rechte an bestimmte Rollen zu binden</a>. Für jedes Projekt folgt dann die Benutzer/ Rolle Zuweisung: dadurch ergibt sich letztlich, welche Rechte ein Benutzer für ein bestimmtes Projekt haben wird.</p>
<p>Gerade in kleine, agil arbeitende Teams ist das wesentlich effizienter: in einem Projekt ist man der Projektleiter, bei einem anderem lediglich ein Entwickler. So flexibel wie Entwickler heute die Rollen wechseln müssen, so flexibel konfigurierbar muss heute auch unternehmenskritische Software sein. In der Vergangenheit musste man in Jira für jede mögliche Kombination der Rollen in einem Projekt entsprechende Benutzergruppen einführen. Benutzergruppen sind aber statisch/ global und nehmen keine Rücksicht auf besondere Projektgegebenheiten. Am Ende bekommt jedes Projekt eigene Benutzergruppen.</p>
<p>Die Einführung von Projektrollen und Sicherheitskonfigurationen für Projektrollen im Allgemeinen reduziert die Konfiguration drastisch. Danke Atlassian!</p>
<p>Ein Rollenmodell ist nicht mit den heute üblichen deklarativen Mitteln konfigurierbar. Wir scheitern an der instanzbasierten Sicherheit. Je nach Projekt hat der Benutzer andere Rollen. Um so wichtiger ist es, ein Security Framework zu wählen, mit dem man die nötige Flexibilität und die Möglichkeit bekommt, eigene Anforderungen umzusetzen.</p>
<p>Auch wenn <a href="http://java.sun.com/javase/6/docs/technotes/guides/security/jaas/JAASRefGuide.html" target="_blank">JAAS</a> ein beeindruckendes Werk ist, mangelt es meiner Meinung nach an Flexibilität. Anpassungen sind sehr schnell nicht mehr portabel, eine Bindung zu der Laufzeitumgebung und oder Infrastruktur ist das Ergebenis. <a href="http://static.springframework.org/spring-security/site/index.html" target="_blank">Spring Security</a> (formerly known as Acegi) ist hingegen sehr flexibel. Security wird dadurch nicht trivial, aber besondere Anforderungen und entsprechende Lösungsansätze scheitern nicht mehr an dem Framework.</p>
<p>Schade dass in der <a href="http://static.springframework.org/spring-security/site/reference/html/springsecurity.html" target="_blank">Spring Security Dokumentation</a> zu diesem Thema nichts zu finden ist. Eine Interessante Ausarbeitung zum Thema Gruppen und Rollen auf Konzeptebene <a href="http://www.mwiesner.com/index.php/2008/03/28/rollen-sind-keine-gruppen/" target="_blank">ist hier zu finden</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2008/04/28/security-anforderungen-20-gruppen-rollen-flexibilitat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analysing trends</title>
		<link>http://pgt.de/2008/04/22/analysing-trends/</link>
		<comments>http://pgt.de/2008/04/22/analysing-trends/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 10:22:31 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[From nerds to nerds]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=193</guid>
		<description><![CDATA[<p>After Rod Johnson demonstrated “Job Trends” with indeed.com, here some nice tools…</p> <p>GWT and JSF….</p> <p>http://www.indeed.com/jobtrends?q=gwt%2C+jsf&#38;l=</p> <p>http://www.google.com/trends?q=GWT%2C+JSF&#38;ctab=0&#38;geo=all&#38;date=all&#38;sort=0</p> <p>http://markmail.org/</p> <p>Unfortunately markmail does not support comparison, you will have to do it by hand.</p> ]]></description>
			<content:encoded><![CDATA[<p>After Rod Johnson demonstrated “Job Trends” with indeed.com, here some nice tools…</p>
<p>GWT and JSF….</p>
<blockquote><p><a href="http://www.indeed.com/jobtrends?q=gwt%2C+jsf&amp;l=" target="_blank">http://www.indeed.com/jobtrends?q=gwt%2C+jsf&amp;l=</a></p>
<p><a href="http://www.google.com/trends?q=GWT%2C+JSF&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0" target="_blank">http://www.google.com/trends?q=GWT%2C+JSF&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0</a></p>
<p><a href="http://markmail.org/" target="_blank">http://markmail.org/</a></p>
<p>Unfortunately markmail does not support comparison, you will have to do it by hand.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2008/04/22/analysing-trends/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Non invasive GWT and Spring integration</title>
		<link>http://pgt.de/2008/02/14/non-invasive-gwt-and-spring-integration/</link>
		<comments>http://pgt.de/2008/02/14/non-invasive-gwt-and-spring-integration/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 08:44:20 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=151</guid>
		<description><![CDATA[<p>[update] If you are working with GWT 1.6, you probably would like to have a look at this here: http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/ [update]</p> <p>Obviously I am not the only one looking for a way to integrate my Spring backend into some GWiT application. After searching for a while I didn’t find any suiting solution. There are [...]]]></description>
			<content:encoded><![CDATA[<p>[update]<br />
If you are working with GWT 1.6, you probably would like to have a look at this here:<br />
<a href="http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/">http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/</a><br />
[update]</p>
<p>Obviously I am not the only one looking for a way to integrate my Spring backend into some GWiT application. After searching for a while I didn’t find any suiting solution. There are some interesting approaches (like <a href="http://gwt-widget.sourceforge.net/" target="_blank">GWT Widget Library</a> SL and using the maven plugin), but being new to GWiT I did not want to give up the GWiT Development Shell neither the embeded Tomcat. I wanted the integration to be less invasive as possible.</p>
<p>So here is what I did…</p>
<p>First problem I had to solve was how to get my configuration elements into the tomcat configuration. I needed to add some listeners to the web.xml (e.g. to start the Spring container and Acegi security):</p>
<p>Here is a snippet from my web.xml showing how to use the listeners provided by the Spring Framework to start an application context and to configure log4j properly:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">(...)
...)
&nbsp;
log4jConfigLocation
/WEB-INF/log4j.xml
&nbsp;
contextConfigLocation
classpath:/META-INF/spring-conf.xml
&nbsp;
			org.springframework.web.util.Log4jConfigListener
&nbsp;
			org.springframework.web.context.ContextLoaderListener
&nbsp;
			org.springframework.web.context.request.RequestContextListener
&nbsp;
(...)</pre></div></div>

<p>GWiT does not provide any extension point for custom configuration, so I had to add the configuration elements directly to the provided Tomcat web.xml. I cannot make changes to the web.xml in the ROOT web application, since this web.xml is re-generated by GWiT every time the Development Shell is started. Fortunately, the default web.xml stored in the “conf” directory of the embedded Tomcat is generated only one. So I found some place to add my configuration elements. Unfortunately the configuration there is not reusable, so I am having double configuration here: configuration for the development and configuration for the deployment.</p>
<p>Next, I wanted to easily have access to my Spring beans. JSF developers have a variable resolver and have access to their Spring beans for free. I wanted that too. Again, being new to GWiT, I didn’t want to loose the features provided by the IDE (Eclipse + GWT-Designer in this case). It is nice to simply say “add new remote service” in the IDE and get everything wired out of the box. For different reasons I do want to expose my Spring beans automatically to the GWiT application. JSF developers have the services for free at the SERVER SIDE: the services do not get exposed via RPC automatically. I wanted something similar: my GWiT remote service implementation should have access to the Spring backend for free without exposing anything automatically.</p>
<p><div style="padding: 50px 10px 50px 10px; text-align:center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-8682101792434953";
/* blogposts */
google_ad_slot = "3634251742";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>I wanted some sort of dependency injection. Since the servlets are managed by the servlet container and the servlet container does not know anything about dependeny injection of Spring beans into servlets I had to do it myself.</p>
<p>First, I needed some sort of markup to identify what to inject. I was using JDK 5 syntax on none client sources, so I used an annotation. I could also have used some marker interface for my services, but I found this to be to invasive, I did not touch my backend files.</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.annotation.ElementType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.annotation.Retention</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.annotation.RetentionPolicy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.annotation.Target</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Annotation used to flag auto injection.
 */</span>
@<span style="color: #003399; font-weight: bold;">Retention</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">RetentionPolicy</span>.<span style="color: #006633;">RUNTIME</span><span style="color: #009900;">&#41;</span>
@<span style="color: #003399; font-weight: bold;">Target</span><span style="color: #009900;">&#40;</span>value = <span style="color: #003399; font-weight: bold;">ElementType</span>.<span style="color: #006633;">METHOD</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> @<span style="color: #000000; font-weight: bold;">interface</span> AutoInject <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>All I wanted to do is to add this annotation to my setter methods in my GWiT remote service implementations. So I extended the RemoteServiceServlet provided by GWiT and implemented the auto injection.</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.Method</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.slf4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.slf4j.LoggerFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.context.WebApplicationContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.context.support.WebApplicationContextUtils</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.server.rpc.RemoteServiceServlet</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Provides automatic injection into GWT services. Only setter methods with exactly one parameter and
 * annotated with AutoInject will be considered for auto injection.
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> AutoInjectingRemoteServiceServlet <span style="color: #000000; font-weight: bold;">extends</span> RemoteServiceServlet <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Logger.
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399; font-weight: bold;">Logger</span> LOG = LoggerFactory.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>AutoInjectingRemoteServiceServlet.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/** Reference for the WebApplicationContext. */</span>
    <span style="color: #000000; font-weight: bold;">private</span> WebApplicationContext ctx<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * {@inheritDoc}
     */</span>
    @<span style="color: #003399; font-weight: bold;">Override</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #009900;">&#123;</span>
        LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Initializing servlet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Get reference to the Spring Application Context&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ctx = WebApplicationContextUtils.<span style="color: #006633;">getWebApplicationContext</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399; font-weight: bold;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>ctx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Spring ctx with: {} beans.&quot;</span>, ctx.<span style="color: #006633;">getBeanDefinitionCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">populateVariables</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Performs auto injection on this servlet instance.
     */</span>
    @<span style="color: #003399; font-weight: bold;">SuppressWarnings</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> populateVariables<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Start servlet auto injection&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399; font-weight: bold;">Method</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> methods = <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getMethods</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000;  font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> i = <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> methods.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i++<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399; font-weight: bold;">Method</span> method = methods<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>method.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;set&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> method.<span style="color: #006633;">isAnnotationPresent</span><span style="color: #009900;">&#40;</span>AutoInject.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> method.<span style="color: #006633;">getParameterTypes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span> == <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399; font-weight: bold;">Class</span> type = method.<span style="color: #006633;">getParameterTypes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Looking for: {}&quot;</span>, type<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> beanNamesForType = ctx.<span style="color: #006633;">getBeanNamesForType</span><span style="color: #009900;">&#40;</span>type, <span style="color: #006600; font-weight: bold;">false</span>, <span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Got {} with {} elements&quot;</span>, beanNamesForType, beanNamesForType.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>beanNamesForType.<span style="color: #006633;">length</span> <span style="color: #339933;">!</span>= <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    LOG.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;There is no bean of type {} for autoinjection&quot;</span>, type.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000;  font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                        method.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, ctx.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span>beanNamesForType<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        LOG.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Injected bean: {} on field {} &quot;</span>, beanNamesForType<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Throwable</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        LOG.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error: could not inject into &quot;</span> + <span style="color: #0000ff;">&quot;protected variable {}, cause: {}&quot;</span>, method.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, e
                                .<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>LOG.<span style="color: #006633;">isDebugEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In short: in the initialization of the servlet I pickup the Spring application context and do the injection for all setter methods annotated.</p>
<p>In the following GWiT remote service implementation I use this injection to get access to my Spring login service (that itself uses acegi, the user DAO and a session scoped bean):</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GwtLoginServiceImpl <span style="color: #000000; font-weight: bold;">extends</span> AutoInjectingRemoteServiceServlet <span style="color: #000000; font-weight: bold;">implements</span> GwtLoginService <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> ILoginService loginService<span style="color: #339933;">;</span>
&nbsp;
	@AutoInject
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setLogService<span style="color: #009900;">&#40;</span>ILoginService loginService<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">loginService</span> = loginService<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@<span style="color: #003399; font-weight: bold;">Override</span>
	<span style="color: #000000; font-weight: bold;">public</span> LoginResult doLogin<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> username, <span style="color: #003399; font-weight: bold;">String</span> password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		LoginResult result = <span style="color: #000000; font-weight: bold;">new</span> LoginResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			result.<span style="color: #006633;">loggedInUser</span> = loginService.<span style="color: #006633;">doLogin</span><span style="color: #009900;">&#40;</span>username, password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			result.<span style="color: #006633;">successFull</span> = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>BadCredentialsException bce<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			result.<span style="color: #006633;">successFull</span> = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			result.<span style="color: #006633;">errorMessage</span> = <span style="color: #0000ff;">&quot;Bad credentials.&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Throwable</span> t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			result.<span style="color: #006633;">successFull</span> = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			result.<span style="color: #006633;">errorMessage</span> = <span style="color: #0000ff;">&quot;Server error.&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@<span style="color: #003399; font-weight: bold;">Override</span>
	<span style="color: #000000; font-weight: bold;">public</span> UserDTO isLoggedIn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> loginService.<span style="color: #006633;">isLoggedIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@<span style="color: #003399; font-weight: bold;">Override</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> doLogout<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		loginService.<span style="color: #006633;">doLogout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>While this leads to a lot of delegation code, I am still happy with the layer separation and the easy usage.</p>
<p>When playing with GWiT 1.5 (build from the trunk) a few weeks ago, I noticed that GWiT started overriding the web.xml in the embeded Tomcat configuration directory. I just thought “oh no!”, but next thing I noticed was that it stopped overriding the application web.xml in the ROOT webapps folder. Let’s see if it stays this way…</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2008/02/14/non-invasive-gwt-and-spring-integration/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using Acegi to secure a GWT application</title>
		<link>http://pgt.de/2008/01/23/using-acegi-to-secure-a-gwt-application/</link>
		<comments>http://pgt.de/2008/01/23/using-acegi-to-secure-a-gwt-application/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 09:34:36 +0000</pubDate>
		<dc:creator>P.G.Taboada</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java & Co.]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[securiy]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://pgt.de/?p=161</guid>
		<description><![CDATA[<p>I am on the train to Munique on my way to the OOP 2008. Today I spent some time refactoring a GWT application (we are moving to GWT 1.5 built from the svn trunk) and thought I could use the travel time to post about GWT and Acegi.</p> <p>GWT changes the way we develop [...]]]></description>
			<content:encoded><![CDATA[<p>I am on the train to Munique on my way to the OOP 2008. Today I spent some time refactoring a GWT application (we are moving to GWT 1.5 built from the svn trunk) and thought I could use the travel time to post about GWT and Acegi.</p>
<p>GWT changes the way we develop internet applications. The web application is not only rich, but it also runs standalone in the client browser. Shortly spoken, a GWT application is a statically loaded set of html, css and javascript files. No serverside web technology gets touched in this process. The webserver delivering the files does not count here… Once the application starts running on the browser, it will start loading data from the server using http requests. This data will further on be displayed in the browser by the GWT application. An application delivered in Javascript is a security nightmare, since the code on the client side is readable and can be easily manipulated.</p>
<p>There are mainly two aspects in a GWT application scenario that might be secured:</p>
<p>- the GWT application<br />
- the RPC services offered by the server</p>
<p>Securing the GWT application is an impossible task. It is possibe to only give access to the Javascript application after the user has identified itself, but once the Javascript code gets transfered to the client there is nothing that can be done to avoid manipulation.</p>
<p><div style="padding: 50px 10px 50px 10px; text-align:center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-8682101792434953";
/* blogposts */
google_ad_slot = "3634251742";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>Securing the RPC services offerend by the server is by far much more easier. Assuming the server is written in Java, there are many ways to secure the services offered: services in the GWT are RPC are implemented by Servlets. Restricting access to the servlets would do the job quite efficiently.</p>
<p>The approach described here does not try to hide the GWT application from the world. The application cannot be secured in the browser and, in many cases, it is the data and the serverside actions that must be secured. A GWT application that cannot connect to its RPC services because of bad credentials is useless. If the application algorithm is worth securing, then hiding the application is the best option available. Unfortunately, this cannot be done with GWT, it would be like a dog trying to bite it’s own tail. After all, the user must identify itself before, and then the application can be dowloaded to the browser. GWT does not known anything about lazy loading parts of an application at runtime. A simple way to implement hiding the application is to host the application in a JSP page ahd have this page secured. Not only the JSP must be secured, but also all static files composing the GWT application. Only after authentication succeeds, the JSP page can be accessed, bootstraping the Javascript application. The JSP should create a server session with the provided credentials, the GWT application would use RPC to gain access to this information and to know who has logged in. This is a server side approach, and here is where I tend to use Acegi.</p>
<p>Acegi is a very interesting Java security framework. It is often used with Spring and with web applications, but it also can be used standalone (without Spring) and to secure any kind of Java application. With AOP techniques its usage can be non invasive to the application code.</p>
<p>In our project we did not hide the GWT application. First, it is an intranet application. Second, the application is useless without the RPC services and the provided data.</p>
<p>The idea on our approach is to download the GWT application to the browser and let the application display a modal login dialog box. The information provided by the user will then be sent to a unsecured login service on the server. The server performs the authentication through acegi, creates a server side session with the appropriate credentials.</p>
<p>Een if some user hacks the Javascript to bypass the login dialog, nothing will happen. The navigation tree is populated by RPC: each user has a different navigation tree, depending on user preferences, stored searches and security roles.</p>
<p>The login RPC call returns the login information required by the GWT application to know that a successful or unsuccessful login has occured. On a successful login, the GWT application starts loading the data needed through the secured services in the server. The server allows this services to be called because the client has created a valid server side session with apropriate credentials. Acegi will secures the services based on this information.</p>
<p>Finally, our GWT application checks regularly if the session has not been invalidated (or if the server is respoding at all) and performs a client-side logout if needed.</p>
<p>Feedback is welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://pgt.de/2008/01/23/using-acegi-to-secure-a-gwt-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

