I found a solution myself, by extending RequestFactoryServelt and passing a
ServiceLayerDecorator. Note that it's possible to
implement functionality of ServiceLocator  as a decorator here too.

Hope it will help someone else.

public class SpringRequestFactoryServelet extends RequestFactoryServlet {
  private static final long serialVersionUID = 1L;

  public static class SpringLocatorDecorator extends ServiceLayerDecorator {
    private final ApplicationContext ctx;

    public SpringLocatorDecorator(ApplicationContext ctx) {
      super();

      this.ctx = ctx;
    }

    @Override
    public <T extends Locator<?, ?>> T createLocator(Class<T> clazz) {
      return ctx.getBean(clazz);
    }
  }

  public SpringRequestFactoryServelet() {
    super(
        new DefaultExceptionHandler(),
        new SpringLocatorDecorator(

WebApplicationContextUtils.getWebApplicationContext(getThreadLocalServletContext())));
  }
}




On Sun, Apr 1, 2012 at 6:42 PM, Yucong Sun (叶雨飞) <[email protected]>wrote:

> Hi,
>
> I've been trying to get RequstFactoryServelt to construct my entity
> locator from spring, because my entity locator needs to implement this
> findbyId() function which requires DB operations which I have some DAO
> implemented and I want to inject them into the entity locator.
>
> However, EntityLocator is created directly, so my injection never worked,
> I have two questions:
>
> 1) It seems I would need  a ServiceLocator equivalent for my entity
> locator.
> 2) Why does gwt needs discticnt between entity service and entity locator?
> It's probabaly okay if entitylocator don't have to implement this
> findById() function, because it can be implement locally (no db operation
> needed). But now i am stuck with both Locator and Service, and they both
> need to talk to storage.
>
> Cheers..
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to