Dan L.
Dan L.

Reputation: 1747

GWT ServiceLocator with multi-module maven project

I've a multi-module GWT project and I'd like to use ServiceLocators. I have 3 modules:

I wrote the ServiceLocator like this:

public class TreeServiceLocator implements ServiceLocator {
    public Object getInstance(Class<?> clazz) {
        return new TreeService();
    }
}

and placed this class in the "shared" module because ServiceLocator has the package com.google.gwt.requestfactory.shared. However, when I compile this throws an error because TreeService is implemented in the "server" module since I need it to return beans from the server and interact with Spring, etc.

In which module should I implement the TreeServiceLocator? Also, maven will throw a circular dependency error if I try to include "server" from the "shared" module.

Thank you!

Upvotes: 2

Views: 535

Answers (1)

BobV
BobV

Reputation: 4173

Place the TreeServiceLocator in the server package, and use a @ServiceName annotation instead of @Service. These annotations have the same effect, but the former uses string literals instead of class literals. This will avoid problems with the GWT compile if the server types aren't available on the classpath of the GWT compiler.

Upvotes: 3

Related Questions