gwt api
public class SpringServiceLocator implements ServiceLocator {
public Object getInstance(Class clazz) {
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(
RequestFactoryServlet.getThreadLocalServletContext());
return context.getBean(clazz);
}
}
第二步是像这样在web.xml上声明您的RequestFactory servlet,(我假设您已经进行了弹簧设置):
<servlet>
<servlet-name>requestFactoryServlet</servlet-name>
<servlet-class>org.gxpenses.util.SpringRequestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>requestFactoryServlet</servlet-name>
<url-pattern>/gwtRequest</url-pattern>
</servlet-mapping>
和GWT一样,您必须配置代理(因为使用服务样式后端,因此必须使用ValueProxy而不是EntityProxy)和作为服务远程接口的请求:
//Note that I inherit from the ValueProxy object
@ProxyFor(Account.class)
public interface AccountProxy extends ValueProxy {
public String getId();
public void setId(String id);
public String getName();
public void setName(String name);
public Double getBalance();
public void setBalance(Double balance);
public String getType();
public void setType(String type);
}
//You have to provide you service Impl class, and the ServiceLocator you created
//Note that Account is automatically to AccountProxy on the client
@Service(value=AccountsServiceImpl.class, locator=SpringServiceLocator.class)
public interface AccountRequest extends RequestContext {
abstract Request<Void> createNewAccount(AccountProxy account);
abstract Request<Void> updateAccountBalance(String accountId, Double transactionAmount, String type);
abstract Request<Double> totalAmountByAccountAndPeriodeAndType(String accountId, Date start, Date end, String type);
}
集成就是这样,有关如何使用RequestFactory API的更多信息,请参见: RequestFactory API
参考: Fancy UI博客中的JCG合作伙伴 Idriss Mrabti 使用RequestFactory API进行的Spring GWT集成 。
相关文章 :
- GWT 2 Spring 3 JPA 2 Hibernate 3.5教程– Eclipse和Maven 2展示
- GWT 2 Spring 3 JPA 2 Hibernate 3.5教程
- 建立自己的GWT Spring Maven原型
- 使用Spring 3.1和基于Java的配置引导Web应用程序,第1部分
- GWT Spring和Hibernate进入数据网格世界
- 使用Selenium或WebDriver测试GWT应用
- GWT,GWT-Ext(SmartGWT),GXT(Ext GWT)常见任务
- GWT EJB3 Maven JBoss 5.1集成教程
- SmartGWT入门,提供出色的GWT界面
翻译自: https://www.javacodegeeks.com/2011/12/spring-gwt-integration-using.html
gwt api