Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.19
-
Fix Version/s: 1.20
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Existing implementation:
/** * Utility class for getting an instance of the async interface for WelcomeService. */ public static class Util { /** * Get an instance of this async interface for WelcomeService. This method assumes the endpoint is * mounted at "http://localhost:8080/GWTpubSub/gwt/welcome". * * @return The async instance. */ public static WelcomeServiceAsync getInstance() { return getInstance("http://localhost:8080/GWTpubSub/gwt/welcome"); } /** * Get an instance of this async interface for WelcomeService. * * @param url The url where the remote endpoint is mounted. * @return The async instance. */ public static WelcomeServiceAsync getInstance(String url) { WelcomeServiceAsync asyncInstance = (WelcomeServiceAsync) com.google.gwt.core.client.GWT.create(WelcomeService.class); ((com.google.gwt.user.client.rpc.ServiceDefTarget) asyncInstance).setServiceEntryPoint(url); return asyncInstance; } }
potential change:
/** * Utility class for getting an instance of the async interface for WelcomeService. */ public static class Util { /** * Get an instance of this async interface for WelcomeService. This method assumes the endpoint is * mounted at "http://localhost:8080/GWTpubSub/gwt/welcome". * * @return The async instance. */ public static WelcomeServiceAsync getInstance() { /* ** Get URL for module */ String url = com.google.gwt.core.client.GWT.getModuleBaseURL(); /* ** Split off first part including server and port */ String urlSplit[] = url.split("http://\\w+:\\d+/"); /* ** Construct end point */ return getInstance(urlSplit[0]+"/GWTpubSub/gwt/welcome"); } /** * Get an instance of this async interface for WelcomeService. * * @param url The url where the remote endpoint is mounted. * @return The async instance. */ public static WelcomeServiceAsync getInstance(String url) { WelcomeServiceAsync asyncInstance = (WelcomeServiceAsync) com.google.gwt.core.client.GWT.create(WelcomeService.class); ((com.google.gwt.user.client.rpc.ServiceDefTarget) asyncInstance).setServiceEntryPoint(url); return asyncInstance; } }
Change was to provide another method, getInstanceRelativeToUrl, where the relative URL can be passed in. Let the developer decide whether relative to GWT.getModuleBaseURL()