Hi,
I am trying to implement a small utility class / library that should be useable on client side and on server side but has different implementation on client and server.
For example I have a utility method that should make a http REST call. On client side I should use RequestBuilder but on server side I have to use java.net.* classes. How would I do that?
I tried the factory approach in combination with GWT.isScript() but this didn't work because the GWT compiler still sees java.net.* classes and wants to translate them:
public class SharedUtils {
private static final SharedUtilsFactory FACTORY = GWT.isScript() ?
new SharedUtilsFactoryJS() : new SharedUtilsFactoryVM();
public static RequestUtils requestUtils() {
return FACTORY.requestUtils();
}
}
Shouldn't this somehow be possible?
Thanks for help,
-- J.