/** * Execute the request asynchronously, and return an object of type {@link Response}. * * @param invocation the request invocation object * @return the future of response */ public Future<Response> queue(final Invocation invocation) { return invocation.submit(callbackHandler); }
public <T> Future<T> submit(InvocationCallback<T> callback) { // TODO: implement wrapping return delegate.submit(callback); }
public <T> Future<T> submit(Class<T> responseType) { // TODO: implement wrapping return delegate.submit(responseType); }
public <T> Future<T> submit(GenericType<T> responseType) { // TODO: implement wrapping return delegate.submit(responseType); }
public Future<Response> submit() { return delegate.submit(); }
/** * Execute the request asynchronously, and return an object of custom type, provided by the clazz parameter. * * @param invocation the request invocation object * @param clazz the class object representing the type to which the response body should be converted * @param <T> the expected type of the response body * @return the future of the given type */ public <T> Future<T> queue(final Invocation invocation, final Class<T> clazz) { final Future<Response> result = invocation.submit(callbackHandler); return new FutureAdapter<T, Response>(result) { @Override protected T adapt(final Response response) { try { return handleUnmarshallingError(response::readEntity, clazz); } finally { // in case of InputStream response.close(); } } }; }
/** * Execute the request asynchronously, and return an object of custom type, provided by the gt parameter. * * @param invocation the request invocation object * @param gt {@link GenericType} object representing the type to which the response body should be converted * @param <T> the expected type of the response body * @return the future of the given type */ public <T> Future<T> queue(final Invocation invocation, final GenericType<T> gt) { final Future<Response> result = invocation.submit(callbackHandler); return new FutureAdapter<T, Response>(result) { @Override protected T adapt(final Response response) { try { return handleUnmarshallingError(response::readEntity, gt); } finally { // in case of InputStream response.close(); } } }; }
public void delete(WebTarget target, InvocationCallback<Response> callback) { target.path("_search/scroll").path(scrollId).request().header(CONTENT_TYPE, APPLICATION_JSON).buildDelete().submit(callback); } }
@Test public void testNonExistentJaxrs20WithPost() throws Exception { Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://168.168.168.168/"); Invocation.Builder builder = target.request(); Entity<String> entity = Entity.entity("entity", MediaType.WILDCARD_TYPE); Invocation invocation = builder.buildPost(entity); Future<String> future = invocation.submit( new GenericType<String>() { } ); try { future.get(); } catch (Exception ex) { Throwable cause = ex.getCause(); assertTrue(cause instanceof ProcessingException); } }