org.apache.cxf.jaxrs.client.WebClient.async()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.async()方法的一些代码示例,展示了WebClient.async()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.async()方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:async

WebClient.async介绍

暂无

代码示例

代码示例来源:origin: apache/cxf

@Override
public AsyncInvoker async() {
  return webClient.async();
}

代码示例来源:origin: apache/cxf

@Override
public <T> Observable<T> method(String name, Entity<?> entity, GenericType<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, entity, responseType));
  }
  return Observable.from(wc.async().method(name, entity, responseType), sc);
}

代码示例来源:origin: apache/cxf

@Override
public <T> Observable<T> method(String name, GenericType<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, responseType));
  }
  return Observable.from(wc.async().method(name, responseType), sc);
}

代码示例来源:origin: apache/cxf

@Override
public <T> Observable<T> method(String name, Entity<?> entity, Class<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, entity, responseType));
  }
  return Observable.from(wc.async().method(name, entity, responseType), sc);
}

代码示例来源:origin: apache/cxf

@Override
public <T> Observable<T> method(String name, Class<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, responseType));
  }
  return Observable.from(wc.async().method(name, responseType), sc);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-rx

@Override
public <T> Observable<T> method(String name, Class<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, responseType));
  }
  return Observable.from(wc.async().method(name, responseType), sc);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-rx

@Override
public <T> Observable<T> method(String name, Entity<?> entity, GenericType<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, entity, responseType));
  }
  return Observable.from(wc.async().method(name, entity, responseType), sc);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-rx

@Override
public <T> Observable<T> method(String name, GenericType<T> responseType) {
  if (sc == null) {
    return Observable.from(wc.async().method(name, responseType));
  }
  return Observable.from(wc.async().method(name, responseType), sc);
}

代码示例来源:origin: apache/cxf

@Override
public <R> Mono<R> method(String name, Entity<?> entity, Class<R> responseType) {
  return mono(webClient.async().method(name, entity, responseType));
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-reactor

@Override
public <R> Mono<R> method(String name, Entity<?> entity, GenericType<R> genericType) {
  return mono(webClient.async().method(name, entity, genericType));
}

代码示例来源:origin: apache/cxf

@Override
public <T> Flux<T> flux(String name, Class<T> responseType) {
  Future<Response> futureResponse = webClient.async().method(name);
  return Flux.fromIterable(toIterable(futureResponse, responseType));
}

代码示例来源:origin: apache/cxf

@Override
public <T> Flux<T> flux(String name, Entity<?> entity, Class<T> responseType) {
  Future<Response> futureResponse = webClient.async().method(name, entity);
  return Flux.fromIterable(toIterable(futureResponse, responseType));
}

代码示例来源:origin: apache/cxf

@Test
public void testThatNewSpanIsCreatedWhenNotProvidedUsingAsyncClient() throws Exception {
  final WebClient client = createWebClient("/bookstore/books", openTracingClientProvider);
  final Future<Response> f = client.async().get();
  final Response r = f.get(1, TimeUnit.SECONDS);
  assertEquals(Status.OK.getStatusCode(), r.getStatus());
  assertThat(TestSender.getAllSpans().size(), equalTo(3));
  assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
  assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("GET /bookstore/books"));
  assertThat(TestSender.getAllSpans().get(2).getOperationName(), equalTo("GET " + client.getCurrentURI()));
}

代码示例来源:origin: apache/cxf

@Test
public void testThatNewSpanIsCreatedWhenNotProvidedUsingAsyncClient() throws Exception {
  final WebClient client = createWebClient("/bookstore/books", braveClientProvider);
  final Future<Response> f = client.async().get();
  final Response r = f.get(1, TimeUnit.SECONDS);
  assertEquals(Status.OK.getStatusCode(), r.getStatus());
  assertThat(TestSpanReporter.getAllSpans().size(), equalTo(3));
  assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get books"));
  assertThat(TestSpanReporter.getAllSpans().get(1).name(), equalTo("get /bookstore/books"));
  assertThat(TestSpanReporter.getAllSpans().get(2).name(), equalTo("get " + client.getCurrentURI()));
  assertThatTraceHeadersArePresent(r, false);
}

代码示例来源:origin: apache/cxf

@Test
public void testGetBookAsyncResponse404() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
  WebClient wc = createWebClient(address);
  Future<Response> future = wc.async().get(Response.class);
  assertEquals(404, future.get().getStatus());
  wc.close();
}

代码示例来源:origin: apache/cxf

@Test
public void testGetBookAsync404() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
  WebClient wc = createWebClient(address);
  Future<Book> future = wc.async().get(Book.class);
  try {
    future.get();
    fail("Exception expected");
  } catch (ExecutionException ex) {
    assertTrue(ex.getCause() instanceof NotFoundException);
  }
  wc.close();
}

代码示例来源:origin: apache/cxf

@Test
public void testGetBookAsyncNoCallback() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
  WebClient wc = createWebClient(address);
  Future<Book> future = wc.async().get(Book.class);
  Book book = future.get();
  assertEquals(124L, book.getId());
  validateResponse(wc);
}

代码示例来源:origin: apache/cxf

@Test
public void testPostBookAsync() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple/async";
  WebClient wc = createWebClientPost(address);
  Future<Book> future = wc.async().post(Entity.xml(new Book("Book", 126L)), Book.class);
  assertEquals(124L, future.get().getId());
  validatePostResponse(wc, true, false);
}

代码示例来源:origin: apache/cxf

private void doTestGetBookAsync(String address, boolean asyncInvoker)
  throws InterruptedException, ExecutionException {
  WebClient wc = createWebClient(address);
  final Holder<Book> holder = new Holder<>();
  InvocationCallback<Book> callback = createCallback(holder);
  Future<Book> future = asyncInvoker ? wc.async().get(callback) : wc.get(callback);
  Book book = future.get();
  assertSame(book, holder.value);
  assertEquals(124L, book.getId());
  validateResponse(wc);
}

代码示例来源:origin: apache/cxf

@Test
public void testRetrieveBookCustomMethodAsync() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/retrieve";
  WebClient wc = WebClient.create(address);
  wc.accept("application/xml");
  Future<Book> book = wc.async().method("RETRIEVE", Entity.xml(new Book("Retrieve", 123L)),
                     Book.class);
  assertEquals("Retrieve", book.get().getName());
  wc.close();
}

相关文章

WebClient类方法