private void initXsrfProtection(final LoginWindow loginWindow) { XsrfTokenServiceAsync xsrf = (XsrfTokenServiceAsync)GWT.create(XsrfTokenService.class); ((ServiceDefTarget)xsrf).setServiceEntryPoint(GWT.getModuleBaseURL() + "xsrf"); xsrf.getNewXsrfToken(new AsyncCallback<XsrfToken>() { @Override public void onSuccess(XsrfToken token) { ServiceHelper.setXsrfToken(token); doGetLoggedInUser(loginWindow); } @Override public void onFailure(Throwable caught) { WebPasswordSafe.handleServerFailure(caught); } }); }
public void testRemoteService() { MyAppGinjector injector = GWT.create(MyAppGinjector.class); // A remote service proxy MyRemoteServiceAsync service = injector.getMyRemoteServiceAsync(); // Make sure that the returned object is a service proxy generated by GWT Object gwtCreatedService = GWT.create(MyRemoteService.class); assertEquals(gwtCreatedService.getClass(), service.getClass()); // Make sure that the @RemoteServiceRelativePath annotation worked assertEquals(GWT.getModuleBaseURL() + "myRemoteService", ((ServiceDefTarget) service).getServiceEntryPoint()); // Make sure that we always return the same instance assertSame(service, injector.getMyRemoteServiceAsync()); }
String[] getClassesToImport() { return new String[] { com.mvp4g.client.history.PlaceService.class.getName(), GWT.class.getName(), com.google.gwt.user.client.History.class.getName(), ServiceDefTarget.class.getName(), PresenterInterface.class.getName(), EventBus.class.getName(), Mvp4gException.class.getName(), HistoryConverter.class.getName(), Mvp4gEventPasser.class.getName(), Mvp4gModule.class.getName(), GinModules.class.getName(), Ginjector.class.getName(), BaseEventBus.class.getName(), EventFilter.class.getName(), EventHandlerInterface.class.getName(), List.class.getName(), NavigationEventCommand.class.getName(), NavigationConfirmationInterface.class.getName(), RunAsyncCallback.class.getName(), Mvp4gRunAsync.class.getName(), Command.class.getName(), HistoryProxyProvider.class.getName(), DefaultHistoryProxy.class.getName() }; }
public void testGetDomainTree() { // Create the service that we will test. AtomServiceAsync atomService = GWT.create(AtomService.class); ServiceDefTarget target = (ServiceDefTarget) atomService; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "ATOM/rpc"); // Since RPC calls are asynchronous, we will need to wait for a response // after this test method returns. This line tells the test runner to // wait // up to 10 seconds before timing out. delayTestFinish(Integer.MAX_VALUE); atomService.getDomainTree(authBackDoor, new AsyncCallback<DomainClass>() { public void onFailure(Throwable caught) { fail("Request failure: " + caught.getMessage()); } public void onSuccess(DomainClass result) { assertEquals(result.getName(), domainObjectClassName); finishTest(); } }); }
public CalendarProvider() { // Initialize the service. // calService = (SchoolCalendarServiceAsync) GWT.create(SchoolCalendarService.class); // By default, we assume we'll make RPCs to a servlet, but see // updateRowData(). There is special support for canned RPC responses. // (Which is a totally demo hack, by the way :-) // ServiceDefTarget target = (ServiceDefTarget) calService; // Use a module-relative URLs to ensure that this client code can find // its way home, even when the URL changes (as might happen when you // deploy this as a webapp under an external servlet container). String moduleRelativeURL = GWT.getModuleBaseURL() + "calendar"; target.setServiceEntryPoint(moduleRelativeURL); }
/** * This test will send a request to the server using the greetServer method in * GreetingService and verify the response. */ public void testGreetingService() { // Create the service that we will test. GreetingServiceAsync greetingService = GWT.create(GreetingService.class); ServiceDefTarget target = (ServiceDefTarget) greetingService; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "EssenceFrontEnd/greet"); // Since RPC calls are asynchronous, we will need to wait for a response // after this test method returns. This line tells the test runner to wait // up to 10 seconds before timing out. delayTestFinish(10000); // Send a request to the server. greetingService.greetServer("GWT User", new AsyncCallback<String>() { public void onFailure(Throwable caught) { // The request resulted in an unexpected error. fail("Request failure: " + caught.getMessage()); } public void onSuccess(String result) { // Verify that the response is correct. assertTrue(result.startsWith("Hello, GWT User!")); // Now that we have received a response, we need to tell the test runner // that the test is complete. You must call finishTest() after an // asynchronous test finishes successfully, or the test will time out. finishTest(); } }); }
public static RPCServiceAsync getRPCService() { RPCServiceAsync rpcService = (RPCServiceAsync) GWT.create(RPCService.class); ServiceDefTarget endpoint = (ServiceDefTarget) rpcService; ClientFactory clientFactory = GWT.create(ClientFactory.class); EventBus eventBus = clientFactory.getEventBus(); String rpcURL = ""; String base_path = URLUtil.getBaseURL(); rpcURL = base_path + "rpc"; endpoint.setServiceEntryPoint(rpcURL); return rpcService; }
public static Handler makeRemoteLogHandler(String remoteLoggingPath) { RemoteLoggingServiceAsync service = GWT.create(RemoteLoggingService.class); ((ServiceDefTarget) service).setServiceEntryPoint(remoteLoggingPath); Handler handler = GWT.create(XLoggerRemoteHandler.class); if (handler instanceof XLoggerRemoteHandler) { ((XLoggerRemoteHandler) handler).setService(service); } return handler; }
/** * Allows to allocate the remote service object * @param classObj the service class object for instantiation * @param URL_SUFFIX the url-suffix on the server t send the requests to * @return returns the remote service object */ public static <R> R getRemoteServieAsyncObject( R remoteService, final String URL_SUFFIX ) { ServiceDefTarget endpoint = (ServiceDefTarget) remoteService; String moduleRelativeURL = GWT.getModuleBaseURL() + URL_SUFFIX; endpoint.setServiceEntryPoint( moduleRelativeURL ); return remoteService; }
protected GreetingServiceAsync getAsyncService() { GreetingServiceAsync greetingService = GWT .create(GreetingService.class); ServiceDefTarget target = (ServiceDefTarget) greetingService; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "spawebtest/greet"); return greetingService; }
/** * Handles method invocations to the {@link ServiceDefTarget} interface * implemented by the service. */ protected Object handleServiceDefTarget(Object proxy, Method method, Object[] args) throws Throwable { if (ServiceDefTarget.class.getMethod("getSerializationPolicyName") .equals(method)) { return this.settings.getPolicyName(); } else if (ServiceDefTarget.class.getMethod("setServiceEntryPoint", String.class).equals(method)) { this.serviceEntryPoint = (String) args[0]; // Modify current base and relative Path to newly specific // serviceEntryPoint assuming that base path is part of // serviceEntryPoint // TODO May not be a valid assumption if (this.serviceEntryPoint.contains(this.settings .getModuleBaseUrl())) { this.settings .setRemoteServiceRelativePath(this.serviceEntryPoint .split(this.settings.getModuleBaseUrl())[1]); } else { this.logger.warning("Unable to determine base (orig: " + this.settings.getModuleBaseUrl() + ") against: " + this.serviceEntryPoint); throw new SyncProxyException( determineProxyServiceBaseInterface(proxy), InfoType.SERVICE_BASE_DELTA); } return null; } else if (ServiceDefTarget.class.getMethod("getServiceEntryPoint") .equals(method)) { return this.serviceEntryPoint; } // TODO handle all methods throw new MethodNotSupportedException("Method: " + method.getName() + " in class: " + method.getDeclaringClass().getName() + " not defined for class: " + proxy.getClass().getName()); }
/** * @deprecated since 0.5, {@link #createProxy(Class, ProxySettings)} with * {@link ProxySettings#setRemoteServiceRelativePath(String)}, * {@link ProxySettings#setCookieManager(CookieManager)}, * {@link ProxySettings#policyName}, and * {@link ProxySettings#setWaitForInvocation(boolean)} */ @Deprecated @SuppressWarnings("unchecked") public static <ServiceIntf> ServiceIntf newProxyInstance( Class<ServiceIntf> serviceIntf, String moduleBaseURL, String serverBaseUrl, String remoteServiceRelativePath, String policyName, CookieManager cookieManager, boolean waitForInvocation) { if (cookieManager == null) { cookieManager = DEFAULT_COOKIE_MANAGER; } if (policyName == null) { try { POLICY_MAP.putAll(RpcPolicyFinder .fetchSerializationPolicyName(moduleBaseURL)); policyName = POLICY_MAP.get(serviceIntf.getName()); } catch (IOException e) { throw new RuntimeException(e); } } ServiceIntf i = (ServiceIntf) Proxy.newProxyInstance(SyncProxy.class .getClassLoader(), new Class[] { serviceIntf, ServiceDefTarget.class, HasRpcToken.class, SerializationStreamFactory.class }, new RemoteServiceInvocationHandler(serverBaseUrl, remoteServiceRelativePath, policyName, cookieManager, waitForInvocation)); return i; }
private MapTestServiceAsync getServiceAsync() { if (customFieldSerializerTestService == null) { customFieldSerializerTestService = (MapTestServiceAsync) GWT.create(MapTestService.class); ((ServiceDefTarget) customFieldSerializerTestService) .setServiceEntryPoint(GWT.getModuleBaseURL() + "map"); } return customFieldSerializerTestService; }
private NestedListTestServiceAsync getServiceAsync() { if (customFieldSerializerTestService == null) { customFieldSerializerTestService = (NestedListTestServiceAsync) GWT.create(NestedListTestService.class); ((ServiceDefTarget) customFieldSerializerTestService) .setServiceEntryPoint(GWT.getModuleBaseURL() + "nested-list"); } return customFieldSerializerTestService; }
private StringListTestServiceAsync getServiceAsync() { if (customFieldSerializerTestService == null) { customFieldSerializerTestService = (StringListTestServiceAsync) GWT.create(StringListTestService.class); ((ServiceDefTarget) customFieldSerializerTestService) .setServiceEntryPoint(GWT.getModuleBaseURL() + "string-list"); } return customFieldSerializerTestService; }
private OptionalTestServiceAsync getServiceAsync() { if (customFieldSerializerTestService == null) { customFieldSerializerTestService = (OptionalTestServiceAsync) GWT.create(OptionalTestService.class); ((ServiceDefTarget) customFieldSerializerTestService) .setServiceEntryPoint(GWT.getModuleBaseURL() + "optional"); } return customFieldSerializerTestService; }
public static synchronized FontRendererServiceAsync getInstance() { if (ourInstance == null) { String endpoint = Chronoscope.getFontBookServiceEndpoint(); if (Util.isSameDomain(GWT.getHostPageBaseURL(), endpoint)) { ourInstance = (FontRendererServiceAsync) GWT .create(FontRendererService.class); ((ServiceDefTarget) ourInstance).setServiceEntryPoint(endpoint); } else { ourInstance = new FontRendererServiceAsyncJson(endpoint); } } return ourInstance; }
public static LoginServiceAsync getInstance() { if (instance == null) { instance = (LoginServiceAsync) GWT.create(LoginService.class); ServiceDefTarget target = (ServiceDefTarget) instance; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc/LoginService"); } return instance; }
public static UserServiceAsync getInstance() { if (instance == null) { instance = (UserServiceAsync) GWT.create(UserService.class); ServiceDefTarget target = (ServiceDefTarget) instance; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc/UserService"); } return instance; }
public static PasswordServiceAsync getInstance() { if (instance == null) { instance = (PasswordServiceAsync) GWT.create(PasswordService.class); ServiceDefTarget target = (ServiceDefTarget) instance; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc/PasswordService"); } return instance; }
private void init(RootPanel root) { ServiceDefTarget endpoint = (ServiceDefTarget)_service; endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "person-service"); Column[] columns = { new Column(0, false, "First Name", "50%"), new Column(1, false, "Last Name", "50%") }; Table table = new Table(new ColumnLayout(columns)); table.setSize("100%", "100%"); table.setContentProvider(new PersonContentProvider(table)); table.update(); root.add(table); }
public static IOneCMDBGWTServiceAsync getInstance() { if (service == null) { service = (IOneCMDBGWTServiceAsync) GWT.create(IOneCMDBGWTService.class); ServiceDefTarget target = (ServiceDefTarget) service; // Use a module-relative URLs to ensure that this client code can find // its way home, even when the URL changes (as might happen when you // deploy this as a webapp under an external servlet container). String moduleRelativeURL = GWT.getModuleBaseURL() + "onecmdb-gwt/wsdl"; target.setServiceEntryPoint(moduleRelativeURL); } return(service); }
public static IModelServiceAsync get() { if (service == null) { service = (IModelServiceAsync) GWT.create(IModelService.class); ServiceDefTarget target = (ServiceDefTarget) service; // Use a module-relative URLs to ensure that this client code can find // its way home, even when the URL changes (as might happen when you // deploy this as a webapp under an external servlet container). String moduleRelativeURL = GWT.getModuleBaseURL() + "/onecmdb-rpc/IModelService"; target.setServiceEntryPoint(moduleRelativeURL); } return(service); }
public static IContentServiceAsync get() { if (service == null) { service = (IContentServiceAsync) GWT.create(IContentService.class); ServiceDefTarget target = (ServiceDefTarget) service; // Use a module-relative URLs to ensure that this client code can find // its way home, even when the URL changes (as might happen when you // deploy this as a webapp under an external servlet container). String moduleRelativeURL = GWT.getModuleBaseURL() + "/onecmdb-rpc/IContentService"; target.setServiceEntryPoint(moduleRelativeURL); } return(service); }
public static IChangeServiceAsync get() { if (changeService == null) { changeService = (IChangeServiceAsync) GWT.create(IChangeService.class); ServiceDefTarget target = (ServiceDefTarget) changeService; // Use a module-relative URLs to ensure that this client code can find // its way home, even when the URL changes (as might happen when you // deploy this as a webapp under an external servlet container). String moduleRelativeURL = GWT.getModuleBaseURL() + "onecmdb-rpc/IChangeService"; target.setServiceEntryPoint(moduleRelativeURL); } return(changeService); }
public synchronized T getService() { if (service == null) { service = createService(); if (service instanceof ServiceDefTarget) { ServiceDefTarget sdt = (ServiceDefTarget) service; sdt.setServiceEntryPoint(WebUtil.encodeUrl(GWT.getModuleBaseURL() + location)); sdt.setRpcRequestBuilder(new CustomBuilder()); } } return service; }
public static RPCServiceAsync createService() { if (rpcService == null) { rpcService = (RPCServiceAsync) GWT.create(RPCService.class); ServiceDefTarget endpoint = (ServiceDefTarget) rpcService; String moduleRelativeURL = GWT.getModuleBaseURL() + "/rpc.service"; endpoint.setServiceEntryPoint(moduleRelativeURL); } return rpcService; }
final private static AsyncCallback<?> createCallBack(final String listenerType) { ServiceDefTarget endpoint = (ServiceDefTarget) service; String moduleRelativeURL = GWT.getModuleBaseURL() + "rpc.service"; endpoint.setServiceEntryPoint(moduleRelativeURL); if (callback == null){ callback = new AsyncCallback<Object>() { @Override public void onSuccess(Object result) { GDataObject data = (GDataObject) result; //this is to trigger handler registered to do on success of event body execution. ClientApplicationContext.getInstance().fireResult(data); /* Data is processed after the event firing is done. * This makes it possible to get handle to newly added rows on a datagrid when the add button event on datagrid tool bar is triggered. * Also enables to set a cell value when new row is added in the same event. */ processOutput(data); ClientApplicationContext.getInstance().setBusy(false); } @Override public void onFailure(Throwable caught) { ClientApplicationContext.getInstance().log("Event execution for " + listenerType + " failed", caught.getMessage(), true, false, caught); ClientApplicationContext.getInstance().setBusy(false); if (caught instanceof GWTServiceException) { GWTServiceException gWTServiceException = (GWTServiceException) caught; processOutput(gWTServiceException.getGDataObject()); } } }; } return callback; }
public RPCServiceAsync getRPCService() { if (rpcService == null) { rpcService = (RPCServiceAsync) GWT.create(RPCService.class); final ServiceDefTarget endpoint = (ServiceDefTarget) rpcService; final String moduleRelativeURL = GWT.getModuleBaseURL() + "rpc.service"; endpoint.setServiceEntryPoint(moduleRelativeURL); } return rpcService; }
public static RPCServiceAsync getRPCService() { if (rpcService == null) { rpcService = (RPCServiceAsync)GWT.create(RPCService.class); ServiceDefTarget endpoint = (ServiceDefTarget)rpcService; String moduleRelativeURL = GWT.getModuleBaseURL() + "/rpc.service"; endpoint.setServiceEntryPoint(moduleRelativeURL); } return rpcService; }
final private static AsyncCallback<?> createCallBack(final String listenerType) { ServiceDefTarget endpoint = (ServiceDefTarget) service; String moduleRelativeURL = GWT.getModuleBaseURL() + "rpc.service"; endpoint.setServiceEntryPoint(moduleRelativeURL); if (callback == null){ callback = new AsyncCallback<Object>() { public void onSuccess(Object result) { GDataObject data = (GDataObject) result; processOutput(data); //this is to trigger handler registered to do on success of event body execution. ClientApplicationContext.getInstance().fireResult(data); ClientApplicationContext.getInstance().setBusy(false); } public void onFailure(Throwable caught) { ClientApplicationContext.getInstance().log("Event execution for " + listenerType + " failed", caught.getMessage(), true, false, caught); ClientApplicationContext.getInstance().setBusy(false); if (caught instanceof GWTServiceException) { GWTServiceException gWTServiceException = (GWTServiceException) caught; processOutput(gWTServiceException.getGDataObject()); } } }; } return callback; }
TestServiceAsync getService() { TestServiceAsync service = (TestServiceAsync) GWT.create(TestService.class); ServiceDefTarget endpoint = (ServiceDefTarget) service; String moduleRelativeURL = GWT.getModuleBaseURL(); moduleRelativeURL += testUrls[testIndex]; endpoint.setServiceEntryPoint(moduleRelativeURL); return service; }
/** * Gets the instance. * * @return the instance */ public static ConfigurationRemoteAsync getInstance() { if (instance == null) { instance = (ConfigurationRemoteAsync) GWT.create(ConfigurationRemote.class); ServiceDefTarget target = (ServiceDefTarget) instance; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "ConfigurationRemote"); } return instance; }
/** * This test will send a request to the server using the greetServer method in * GreetingService and verify the response. */ public void testGreetingService() { // Create the service that we will test. AtomServiceAsync atomService = GWT.create(AtomService.class); ServiceDefTarget target = (ServiceDefTarget) atomService; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "ATOM/rpc"); // Since RPC calls are asynchronous, we will need to wait for a response // after this test method returns. This line tells the test runner to wait // up to 10 seconds before timing out. delayTestFinish(10000); // Send a request to the server. // atomService.greetServer("GWT User", new AsyncCallback<String>() { // public void onFailure(Throwable caught) { // // The request resulted in an unexpected error. // fail("Request failure: " + caught.getMessage()); // } // // public void onSuccess(String result) { // // Verify that the response is correct. // assertTrue(result.startsWith("Hello, GWT User!")); // // // Now that we have received a response, we need to tell the // // test runner // // that the test is complete. You must call finishTest() after // // an // // asynchronous test finishes successfully, or the test will // // time out. // finishTest(); // } // }); }
public void testGetListOfDomainObject() { // Create the service that we will test. AtomServiceAsync atomService = GWT.create(AtomService.class); ServiceDefTarget target = (ServiceDefTarget) atomService; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "ATOM/rpc"); delayTestFinish(Integer.MAX_VALUE); final int pageSize = 20; atomService.getListOfDomainObject(authBackDoor, domainObjectClassName, 0, pageSize, null, null, null, false, false, new AsyncCallback<DomainObjectList>() { public void onSuccess(DomainObjectList result) { assertNotNull(result); assertEquals(domainObjectClassName, result.getDomainClassName()); List<DomainObject> dos = result.getDomainObjects(); if (dos != null) { assertTrue(dos.size() <= pageSize); // assertTrue(dos.size() > 0); } finishTest(); } public void onFailure(Throwable caught) { fail("Request failure: " + caught.getMessage()); } }); }