GWT ServiceLocator with multi-module maven project
I've a multi-module GWT project and I'd like 开发者_Go百科to use ServiceLocators. I have 3 modules:
- "client" depends on shared
- "shared"
- "server" depends on shared
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!
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.
精彩评论