<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3472995619865460458</id><updated>2011-04-21T16:40:24.486-07:00</updated><title type='text'>Discover the magic world of software development</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://software-wonders.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3472995619865460458/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://software-wonders.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Gabi S</name><uri>http://www.blogger.com/profile/14433107359640966786</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://static.howstuffworks.com/gif/bytes-ch.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3472995619865460458.post-7198749898168953733</id><published>2007-02-20T07:23:00.000-08:00</published><updated>2007-03-16T07:14:44.075-07:00</updated><title type='text'>GWT-Spring Integration Demystified</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;It is not a mistery that Google Web Toolkit (GWT) began to gain a lot of teritory in its battle with other similar frameworks. Google Web Toolkit (GWT) is an open source Java development framework that makes the writing of AJAX applications quite a pleasure and fun . When you deploy your application to production, the&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt; GWT compiler translates your Java application to browser-compliant JavaScript and HTML.What makes GWT a great tool to use ? This is not at all a tricky question. The answer is extremly simple: GWT is light, easy,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt; browser compatible, has a simple RPC mechanism, Junit integration, dynamic, reusable UI components, you can use your favourite Java IDE to develop your application and use any GWT library you n&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;eed and of course you can contribute to the improvement of GWT at any time as it is completely open-source.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;What makes GWT more interesting is that it can be integrated with technologies like Struts, Spring, Hibernate, Ant, Maven etc and this is quite a wonde&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;r considering the speed of entreprise applications development.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;When I first started this investigation I didn't find very many resources on how these technologies can be integrated and this is how I decided to help the community of those willing to make a step towards this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt; integration. The purpose of this blog is to explain as simple as possible how GWT and Spring can be brought together and make the the most of your entreprise application.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;Let's get to the real stuff ;-)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;First thing to consider is the directories structure. Pay an extra attention to this step as you will face some difficulties in compiling the files if the sources are not in the right packages.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/MyApplication.gwt.xml&lt;br /&gt;./src/com/public/MyAplication.htm&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/client/MyApplication.java&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/client/MyService.java&lt;br /&gt;./src/com/client/MyServiceAsync.java&lt;br /&gt;./src/com/server/MyServiceImpl.java&lt;br /&gt;./src/com/server/ServletWrappingController.java&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/spring-servlet.xml&lt;br /&gt;./src/web.xml&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./WEB-INF/lib/spring.jar&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./WEB-INF/lib/gwt-user.jar&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./WEB-INF/lib/gwt-dev-windows.jar&lt;br /&gt;./WEB-INF/lib/gwt-servlet.jar&lt;br /&gt;./WEB-INF/spring-servlet.xml&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./WEB-INF/web.xml&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;The application we are going to develop is a simple interaction with the server across a network (that is making a remote procedure call). The client will send a request to the server and the server will response to the client.A &lt;i&gt;sevice &lt;/i&gt;&lt;span style="FONT-STYLE: normal"&gt;is &lt;/span&gt;the server-side code that gets invoked from the client.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;Our application can be run either in hosted-mode or we can be compil&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;ed into JavaScript and HTML to run it in the web-mode. If you use Eclipse IDE to develop your application simply generate an Eclipse project using the projectCreator script from your gwt installation directory:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;em&gt;projectCreator -eclipse SpringGwtIntegration&lt;/em&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;and then generate your GWT application using the applicationCreator shell:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre style="MARGIN-BOTTOM: 0.5cm; FONT-STYLE: italic"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;applicationCreator -eclipse SpringGwtIntegration com.client.MyApplication&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;MyApplication.gwt.xml file is the GWT configuration file that specifies the location of the core web toolkit material and the entry point for the application.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/MyApplication.gwt.xml&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre style="MARGIN-BOTTOM: 0.5cm"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_BEGgu3ObpRk/RdsTCyQ6ynI/AAAAAAAAABM/0R5T1de4iBo/s1600-h/gwtxml_file.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5033637947090061938" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_BEGgu3ObpRk/RdsTCyQ6ynI/AAAAAAAAABM/0R5T1de4iBo/s400/gwtxml_file.JPG" border="0" /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;Notice the defined &lt;strong&gt;&lt;span style="color:#663333;"&gt;servlet&lt;servlet&gt;&lt;servlet&gt;&lt;servlet&gt;&lt;span style="COLOR: rgb(184,0,71)"&gt;&lt;servlet&gt;&lt;/servlet&gt;&lt;/span&gt;,&lt;/span&gt;&lt;/strong&gt; which is the server-side class for our RPC service.&lt;br /&gt;In the public folder there is the HTML used primarily to test the application in the hosted mode:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm; COLOR: rgb(0,0,0)" align="left"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;color:#000000;"&gt;./src/com/public/MyAplication.htm&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0cm; COLOR: rgb(0,0,0)" align="left"&gt;&lt;span style="font-family:Times New Roman;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5033654375339969202" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_BEGgu3ObpRk/Rdsh_CQ6yrI/AAAAAAAAAB8/gU3lZ59ILYQ/s400/myApp_html.JPG" border="0" /&gt; &lt;p align="justify"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;In the “client” package we have the class that is our “main” application, and other two interfaces to the remote code. The MyService interface is implemented by the server-side code, in this case the MyServiceImpl class.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/client/MyService.java&lt;br /&gt;package com.client;&lt;br /&gt;import com.google.gwt.user.client.rpc.RemoteService;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;public interface MyService extends RemoteService&lt;br /&gt;{&lt;br /&gt;public abstract String myMethod(String s);&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;The second one is used for the client-side code. The name of the interface MUST be the same as the server-side interface with "Async" appended. It must implement all of the methods in the server-side interface, but all of the methods MUST also take an additional parameter, which is an AsyncCallback object.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/client/MyServiceAsync.java&lt;br /&gt;package com.client;&lt;br /&gt;import com.google.gwt.user.client.rpc.AsyncCallback;&lt;br /&gt;public interface MyServiceAsync&lt;br /&gt;{&lt;br /&gt;public abstract void myMethod(String s, AsyncCallback asynccallback);&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;The two "myMethod" methods differ by the additional AsyncCallback asynccallback parameter and the return type.&lt;br /&gt;From the client application first you create an AsyncCallback object by using the GWT.create() method that takes the server-side interface as an argument and returns an object that uses the client-side interface.&lt;br /&gt;We create an object instance that implements the AsyncCallback interface. Here we create an anonymous class for this. The server-side code is called asyncronously (the code won't wait for a response). That is why we need to create this object. This object will handle the result when it makes it's way back to the browser. We need to write code to handle both success and error conditions.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/client/MyApplication.java&lt;br /&gt;package com.client;&lt;br /&gt;import com.google.gwt.core.client.EntryPoint;&lt;br /&gt;import com.google.gwt.core.client.GWT;&lt;br /&gt;import com.google.gwt.user.client.rpc.AsyncCallback;&lt;br /&gt;import com.google.gwt.user.client.rpc.ServiceDefTarget;&lt;br /&gt;import com.google.gwt.user.client.ui.*;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;// Referenced classes of package csw.client MyService, MyServiceAsync&lt;br /&gt;public class MyApplication implements EntryPoint {&lt;br /&gt;public MyApplication() {&lt;br /&gt;}&lt;br /&gt;public void onModuleLoad() {&lt;br /&gt;final Label label = new Label();&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;final MyServiceAsync svc = (MyServiceAsync) GWT.create(com.client.MyService.class);&lt;br /&gt;ServiceDefTarget endpoint = (ServiceDefTarget) svc;&lt;br /&gt;endpoint.setServiceEntryPoint("services/myService");&lt;br /&gt;final AsyncCallback callback = new AsyncCallback() {&lt;br /&gt;public void onSuccess(Object result) {&lt;br /&gt;label.setText(result.toString());&lt;br /&gt;}&lt;br /&gt;public void onFailure(Throwable ex) {&lt;br /&gt;label.setText(ex.toString());&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;Button button = new Button("Click ME");&lt;br /&gt;button.addClickListener(new ClickListener() {&lt;br /&gt;public void onClick(Widget w) {&lt;br /&gt;svc.myMethod("Do Something", callback);&lt;br /&gt;}&lt;br /&gt;});&lt;br /&gt;RootPanel.get("testing").add(button);&lt;br /&gt;RootPanel.get("testing2").add(label);&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;The server-side code:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;./src/com/server/MyServiceImpl.java&lt;br /&gt;package com.server;&lt;br /&gt;import com.google.gwt.user.server.rpc.RemoteServiceServlet;&lt;br /&gt;import com.client.MyService;&lt;br /&gt;public class MyServiceImpl extends RemoteServiceServlet&lt;br /&gt;implements MyService&lt;br /&gt;{&lt;br /&gt;private static final long serialVersionUID = 1L;&lt;br /&gt;public MyServiceImpl()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;public String myMethod(String s)&lt;br /&gt;{&lt;br /&gt;return (new StringBuilder("You submitted: '")).append(s).append("'").toString();&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;To integrate this with Spring we only have to register our GWT servlet in our web.xml so we can simply use Spring's &lt;b&gt;ServletForwardingController&lt;/b&gt; to call services by name.&lt;br /&gt;We also have to modify a bit our GWT client to reflect a path change we have to do. We add to the web.xml file the Spring's &lt;b&gt;DispatcherServlet&lt;/b&gt; mappings:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;The web.xml will look like:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0);font-family:times new roman;" &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="TEXT-ALIGN: justify" align="justify"&gt;&lt;pre style="MARGIN-BOTTOM: 0.5cm"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_BEGgu3ObpRk/RdsVJCQ6ypI/AAAAAAAAABc/sy1oUo0iqQ8/s1600-h/web_xml.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5033640253487499922" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_BEGgu3ObpRk/RdsVJCQ6ypI/AAAAAAAAABc/sy1oUo0iqQ8/s400/web_xml.JPG" border="0" /&gt;&lt;/a&gt;&lt;span style="font-family:times new roman;font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;The last thing to do is to create a new configuration file called spring-servlet.xml where we put the real configuration of&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;our GWT's service controller.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;pre style="MARGIN-BOTTOM: 0.5cm"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_BEGgu3ObpRk/RdsV3CQ6yqI/AAAAAAAAABk/X_c0IzqSKIg/s1600-h/spring_servlet.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5033641043761482402" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_BEGgu3ObpRk/RdsV3CQ6yqI/AAAAAAAAABk/X_c0IzqSKIg/s400/spring_servlet.JPG" border="0" /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;beans&gt;&lt;/beans&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" id="urlMapping"&gt;&lt;/bean&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="justify"&gt;&lt;span style="font-family:times new roman;font-size:100%;color:#000000;"&gt;The ServletWrappingController controls the RemoteServiceServlet's lifecycle completely, emulating the servlet-container.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:times new roman;font-size:100%;color:#000000;"&gt;package com.server;&lt;br /&gt;import java.util.Enumeration;&lt;br /&gt;import java.util.Properties;&lt;br /&gt;import javax.servlet.Servlet;&lt;br /&gt;import javax.servlet.ServletConfig;&lt;br /&gt;import javax.servlet.ServletContext;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;import org.springframework.beans.factory.BeanNameAware;&lt;br /&gt;import org.springframework.beans.factory.DisposableBean;&lt;br /&gt;import org.springframework.beans.factory.InitializingBean;&lt;br /&gt;import org.springframework.web.servlet.ModelAndView;&lt;br /&gt;import org.springframework.web.servlet.mvc.AbstractController;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:times new roman;font-size:100%;color:#000000;"&gt;/**&lt;br /&gt;* Spring Controller implementation that mimics standard ServletWrappingController behaviour&lt;br /&gt;* (see its documentation), but with the important difference that it doesn't instantiate the&lt;br /&gt;* Servlet instance directly but delegate for this the BeanContext, so that we can also use IoC.*&lt;br /&gt;*/&lt;br /&gt;public class ServletWrappingController extends AbstractController&lt;br /&gt;implements BeanNameAware, InitializingBean, DisposableBean {&lt;br /&gt;private Class servletClass;&lt;br /&gt;private String servletName;&lt;br /&gt;private Properties initParameters = new Properties();&lt;br /&gt;private String beanName;&lt;br /&gt;private Servlet servletInstance;&lt;br /&gt;public void setServletClass(Class servletClass) {&lt;br /&gt;System.out.print("setServletClass : "+servletClass);&lt;br /&gt;this.servletClass = servletClass;&lt;br /&gt;}&lt;br /&gt;public void setServletName(String servletName) {&lt;br /&gt;System.out.print("setServletName : "+servletName);&lt;br /&gt;this.servletName = servletName;&lt;br /&gt;}&lt;br /&gt;public void setInitParameters(Properties initParameters) {&lt;br /&gt;System.out.print("setInitParameters : "+initParameters);&lt;br /&gt;this.initParameters = initParameters;&lt;br /&gt;}&lt;br /&gt;public void setBeanName(String name) {&lt;br /&gt;System.out.print("setBeanName : "+name);&lt;br /&gt;this.beanName = name;&lt;br /&gt;}&lt;br /&gt;public void setServletInstance(Servlet servletInstance) {&lt;br /&gt;System.out.print("setServletInstance : "+servletInstance);&lt;br /&gt;this.servletInstance = servletInstance;&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:times new roman;font-size:100%;color:#000000;"&gt;public void afterPropertiesSet() throws Exception {&lt;br /&gt;System.out.print("afterPropertiesSet");&lt;br /&gt;if (this.servletInstance == null) {&lt;br /&gt;throw new IllegalArgumentException("servletInstance is required");&lt;br /&gt;}&lt;br /&gt;if (!Servlet.class.isAssignableFrom(servletInstance.getClass())) {&lt;br /&gt;throw new IllegalArgumentException("servletInstance [" + this.servletClass.getName() +&lt;br /&gt;"] needs to implement interface [javax.servlet.Servlet]");&lt;br /&gt;}&lt;br /&gt;if (this.servletName == null) {&lt;br /&gt;this.servletName = this.beanName;&lt;br /&gt;}&lt;br /&gt;this.servletInstance.init(new DelegatingServletConfig());&lt;br /&gt;}&lt;br /&gt;protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;throws Exception {&lt;br /&gt;System.out.print("handleRequestInternal");&lt;br /&gt;this.servletInstance.service(request, response);&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;public void destroy() {&lt;br /&gt;System.out.print("destroy");&lt;br /&gt;this.servletInstance.destroy();&lt;br /&gt;}&lt;br /&gt;private class DelegatingServletConfig implements ServletConfig {&lt;br /&gt;public String getServletName() {&lt;br /&gt;return servletName;&lt;br /&gt;}&lt;br /&gt;public ServletContext getServletContext() {&lt;br /&gt;return getWebApplicationContext().getServletContext();&lt;br /&gt;}&lt;br /&gt;public String getInitParameter(String paramName) {&lt;br /&gt;return initParameters.getProperty(paramName);&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm" align="left"&gt;&lt;span style="font-family:times new roman;font-size:100%;color:#000000;"&gt;}&lt;br /&gt;public Enumeration getInitParameterNames() {&lt;br /&gt;return initParameters.keys();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="COLOR: rgb(128,0,0)"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm; COLOR: rgb(0,0,0)" align="justify"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;Well, that was all folks. We only have to run the MyApplication-shell to run the application in the hosted-mode or compile the packages with the MyApplication-compile shell, add the generated output of the www directory to a SpringGwtIntegration war archive, add the necessary configuration files (web.xml, spring-servlet.xml, the bin and lib directories) and copy it in the server\default\deploy folder of your Jboss version.&lt;br /&gt;&lt;span style="FONT-STYLE: italic"&gt;Note:&lt;/span&gt; this application is deployed with the jboss-4.0.5.GA and jboss-3.2.8.SP1 versions of Jboss.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm; COLOR: rgb(0,0,0)" align="left"&gt;&lt;span style="font-family:Times New Roman,serif;"&gt;&lt;span style="font-size:100%;"&gt;Any comment or suggestion is welcome.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="MARGIN-BOTTOM: 0cm; COLOR: rgb(0,0,0)" align="left"&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3472995619865460458-7198749898168953733?l=software-wonders.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://software-wonders.blogspot.com/feeds/7198749898168953733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3472995619865460458&amp;postID=7198749898168953733' title='17 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3472995619865460458/posts/default/7198749898168953733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3472995619865460458/posts/default/7198749898168953733'/><link rel='alternate' type='text/html' href='http://software-wonders.blogspot.com/2007/02/it-is-not-mistery-that-google-web.html' title='GWT-Spring Integration Demystified'/><author><name>Gabi S</name><uri>http://www.blogger.com/profile/14433107359640966786</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://static.howstuffworks.com/gif/bytes-ch.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_BEGgu3ObpRk/RdsTCyQ6ynI/AAAAAAAAABM/0R5T1de4iBo/s72-c/gwtxml_file.JPG' height='72' width='72'/><thr:total>17</thr:total></entry></feed>
