本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.rx()
方法的一些代码示例,展示了WebClient.rx()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.rx()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:rx
暂无
代码示例来源:origin: apache/cxf
@SuppressWarnings("rawtypes")
public <T extends RxInvoker> T rx(Class<T> rxCls) {
return rx(rxCls, (ExecutorService)null);
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client
@SuppressWarnings("rawtypes")
public <T extends RxInvoker> T rx(Class<T> rxCls) {
return rx(rxCls, (ExecutorService)null);
}
代码示例来源:origin: apache/cxf
@SuppressWarnings("rawtypes")
@Override
public <T extends RxInvoker> T rx(Class<T> rxCls) {
return webClient.rx(rxCls, getConfiguredExecutorService());
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client
@SuppressWarnings("rawtypes")
@Override
public <T extends RxInvoker> T rx(Class<T> rxCls) {
return webClient.rx(rxCls, getConfiguredExecutorService());
}
代码示例来源:origin: apache/cxf
@Override
public CompletionStageRxInvoker rx() {
return webClient.rx(getConfiguredExecutorService());
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client
@Override
public CompletionStageRxInvoker rx() {
return webClient.rx(getConfiguredExecutorService());
}
代码示例来源:origin: apache/cxf
public CompletionStageRxInvoker rx() {
return rx(lookUpExecutorService());
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client
public CompletionStageRxInvoker rx() {
return rx(lookUpExecutorService());
}
代码示例来源:origin: apache/cxf
@SuppressWarnings({
"rawtypes", "unchecked"
})
public <T extends RxInvoker> T rx(Class<T> rxCls, ExecutorService executorService) {
if (CompletionStageRxInvoker.class.isAssignableFrom(rxCls)) {
return (T)rx(executorService);
}
ClientProviderFactory pf =
ClientProviderFactory.getInstance(WebClient.getConfig(this).getEndpoint());
RxInvokerProvider rxProvider = pf.getRxInvokerProvider();
if (rxProvider != null && rxProvider.isProviderFor(rxCls)) {
return (T)rxProvider.getRxInvoker(sync(), executorService);
}
throw new IllegalStateException("Provider for " + rxCls.getName() + " is not available");
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client
@SuppressWarnings({
"rawtypes", "unchecked"
})
public <T extends RxInvoker> T rx(Class<T> rxCls, ExecutorService executorService) {
if (CompletionStageRxInvoker.class.isAssignableFrom(rxCls)) {
return (T)rx(executorService);
}
ClientProviderFactory pf =
ClientProviderFactory.getInstance(WebClient.getConfig(this).getEndpoint());
RxInvokerProvider rxProvider = pf.getRxInvokerProvider();
if (rxProvider != null && rxProvider.isProviderFor(rxCls)) {
return (T)rxProvider.getRxInvoker(sync(), executorService);
}
throw new IllegalStateException("Provider for " + rxCls.getName() + " is not available");
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookAsyncStage404() throws Exception {
String address = "http://localhost:" + PORT + "/completable/books";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("124").rx().get(Book.class);
try {
stage.toCompletableFuture().get();
fail("Exception expected");
} catch (ExecutionException ex) {
assertTrue(ex.getCause() instanceof NotFoundException);
}
}
private WebClient createWebClient(String address) {
代码示例来源:origin: apache/cxf
@Test
public void testGetBookAsyncStage() throws Exception {
String address = "http://localhost:" + PORT + "/completable/books";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
Book book = stage.toCompletableFuture().join();
assertEquals(123L, book.getId());
}
@Test
代码示例来源:origin: apache/cxf
@Test
public void testGetBookAsyncStageAsyncResponse() throws Exception {
String address = "http://localhost:" + PORT + "/completable/booksAsync";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
Book book = stage.toCompletableFuture().join();
assertEquals(123L, book.getId());
}
@Test
代码示例来源:origin: apache/cxf
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/observable/textJson";
List<Object> providers = new LinkedList<>();
providers.add(new JacksonJsonProvider());
providers.add(new ObservableRxInvokerProvider());
WebClient wc = WebClient.create(address, providers);
Observable<HelloWorldBean> obs = wc.accept("application/json")
.rx(ObservableRxInvoker.class)
.get(HelloWorldBean.class);
Holder<HelloWorldBean> holder = new Holder<>();
Disposable d = obs.subscribe(v -> {
holder.value = v;
});
if (d == null) {
throw new IllegalStateException("Subscribe did not return a Disposable");
}
Thread.sleep(2000);
assertEquals("Hello", holder.value.getGreeting());
assertEquals("World", holder.value.getAudience());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/flowable/textJson";
List<Object> providers = new LinkedList<>();
providers.add(new JacksonJsonProvider());
providers.add(new FlowableRxInvokerProvider());
WebClient wc = WebClient.create(address, providers);
Flowable<HelloWorldBean> obs = wc.accept("application/json")
.rx(FlowableRxInvoker.class)
.get(HelloWorldBean.class);
final TestSubscriber<HelloWorldBean> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertResult(new HelloWorldBean("Hello", "World"));
}
代码示例来源:origin: apache/cxf
@Test
public void testGetHelloWorldAsyncObservable() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/flowable/textAsync";
WebClient wc = WebClient.create(address,
Collections.singletonList(new FlowableRxInvokerProvider()));
Flowable<String> obs = wc.accept("text/plain")
.rx(FlowableRxInvoker.class)
.get(String.class);
final TestSubscriber<String> subscriber = new TestSubscriber<>();
obs.map(s -> s + s).subscribe(subscriber);
subscriber.await(2, TimeUnit.SECONDS);
subscriber.assertResult("Hello, world!Hello, world!");
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookAsyncStageThenAcceptAsync() throws Exception {
String address = "http://localhost:" + PORT + "/completable/books";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
Holder<Book> holder = new Holder<>();
stage.thenApply(v -> {
v.setId(v.getId() * 2);
return v;
}).thenAcceptAsync(v -> {
holder.value = v;
});
Thread.sleep(3000);
assertEquals(246L, holder.value.getId());
}
内容来源于网络,如有侵权,请联系作者删除!