Integrating Spring and GWT
I just completed my first shot at integrating Spring with GWT. You can check it out here
Here’s what you do to expose a simple service.
1) Write the remote service, note that the service no longer extends RemoteServiceServlet however HelloService should still implement RemoteService
public class HelloServiceImpl implements HelloService {
public String sayHello(String name) {
return "hello " + name;
}
}
2) Define this service in your application context
<bean id=”helloService” class=”nl.jteam.hello.server.HelloServiceImpl”/>
3) expose the bean as a gwt service
<bean id=”defaultHandlerMapping” class=”org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping”/>
<bean name=”/helloService” class=”nl.jteam.gwt.exporter.GwtInvokerServiceExporter”>
<property name=”service” ref=”helloService”/>
<property name=”serviceInterface” value=”nl.jteam.hello.client.HelloService”/>
</bean>
4) Change the clientcode to point to your Spring service. be sure to use an absolute url while running in hosted mode or it will complain
helloService = (HelloServiceAsync) GWT.create(HelloService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) helloService;
endpoint.setServiceEntryPoint("http://localhost:8080/helloservice");
Feedback is appreciated