开发者

RequestFactory with service layer

I need to use GWT with a service-based domain layer - not beans with DAOs. Is the GWT 2.1 architecture with MVP and RequestFactory fitted for this? Or should I stay w开发者_开发知识库ith RPC?

Thanks


GWT 2.1.1 adds a Locator and ServiceLocator mechanism to allow you to control how the RequestFactory server code obtains references to entities and service object instances.

For example, you can declare code like

class MyService.class {
  // Note that this is not a static method
  public void doSomething() {....};
}

class MyServiceLocator implements ServiceLocator {
  public Object getInstance(Class<?> clazz) {
    // Or use Guice, Spring, whatever provides instances of MyService
    return new MyService();
  }
}    

interface MyRequestFactory extends RequestFactory {
  @Service(value=MyService.class, locator=MyServiceLocator.class)
  interface ServiceRequest extends RequestContext {
    Request<Void> doSomething();
  }
  ServiceRequest myService();
}

If you need even more control over how RequestFactory interacts with your server domain objects or service code, you can inject instances of ServiceLayerDecorator into the service layer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜