Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.jboss.resteasy.client.jaxrs.internal.PublisherRxInvokerImpl Maven / Gradle / Ivy
package org.jboss.resteasy.client.jaxrs.internal;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import jakarta.ws.rs.HttpMethod;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.client.jaxrs.PublisherRxInvoker;
import org.reactivestreams.Publisher;
@SuppressWarnings("unchecked")
public abstract class PublisherRxInvokerImpl implements PublisherRxInvoker {
private final ClientInvocationBuilder builder;
public PublisherRxInvokerImpl(final ClientInvocationBuilder builder) {
this.builder = builder;
}
protected abstract Publisher toPublisher(CompletionStage completable);
private Publisher mkPublisher(
final String method,
final Entity> entity,
final Function> mkPublisher) {
ClientInvocation invocation = builder.createClientInvocation(builder.invocation);
invocation.setMethod(method);
invocation.setEntity(entity);
return mkPublisher.apply(invocation);
}
private Publisher mkPublisher(final String method, final Entity> entity) {
return mkPublisher(method, entity, invocation -> invocation.reactive()
.map(ClientInvocation.ReactiveInvocation::submit)
.orElseGet(() -> toPublisher(invocation.submitCF())));
}
private Publisher mkPublisher(final String method, final Entity> entity, final Class responseType) {
return mkPublisher(method, entity, invocation -> invocation.reactive()
.map(r -> r.submit(responseType))
.orElseGet(() -> toPublisher(invocation.submitCF(responseType))));
}
private Publisher mkPublisher(final String method, final Entity> entity, final GenericType responseType) {
return mkPublisher(method, entity, invocation -> invocation.reactive()
.map(r -> r.submit(responseType))
.orElseGet(() -> toPublisher(invocation.submitCF(responseType))));
}
@Override
public Publisher get() {
return mkPublisher(HttpMethod.GET, null);
}
@Override
public Publisher get(final Class responseType) {
return mkPublisher(HttpMethod.GET, null, responseType);
}
@Override
public Publisher get(final GenericType responseType) {
return mkPublisher(HttpMethod.GET, null, responseType);
}
@Override
public Publisher put(final Entity> entity) {
return mkPublisher(HttpMethod.PUT, entity);
}
@Override
public Publisher put(final Entity> entity, final Class clazz) {
return mkPublisher(HttpMethod.PUT, entity, clazz);
}
@Override
public Publisher put(final Entity> entity, final GenericType type) {
return mkPublisher(HttpMethod.PUT, entity, type);
}
@Override
public Publisher post(final Entity> entity) {
return mkPublisher(HttpMethod.POST, entity);
}
@Override
public Publisher post(final Entity> entity, final Class clazz) {
return mkPublisher(HttpMethod.POST, entity, clazz);
}
@Override
public Publisher post(final Entity> entity, final GenericType type) {
return mkPublisher(HttpMethod.POST, entity, type);
}
@Override
public Publisher delete() {
return mkPublisher(HttpMethod.DELETE, null);
}
@Override
public Publisher delete(final Class responseType) {
return mkPublisher(HttpMethod.DELETE, null, responseType);
}
@Override
public Publisher delete(final GenericType responseType) {
return mkPublisher(HttpMethod.DELETE, null, responseType);
}
@Override
public Publisher head() {
return mkPublisher(HttpMethod.HEAD, null);
}
@Override
public Publisher options() {
return mkPublisher(HttpMethod.OPTIONS, null);
}
@Override
public Publisher options(final Class responseType) {
return mkPublisher(HttpMethod.OPTIONS, null, responseType);
}
@Override
public Publisher options(final GenericType responseType) {
return mkPublisher(HttpMethod.OPTIONS, null, responseType);
}
@Override
public Publisher trace() {
return method("TRACE");
}
@Override
public Publisher trace(final Class responseType) {
return method("TRACE", responseType);
}
@Override
public Publisher trace(final GenericType responseType) {
return method("TRACE", responseType);
}
@Override
public Publisher method(final String name) {
return mkPublisher(name, null);
}
@Override
public Publisher method(final String name, final Class responseType) {
return mkPublisher(name, null, responseType);
}
@Override
public Publisher method(final String name, final GenericType responseType) {
return mkPublisher(name, null, responseType);
}
@Override
public Publisher method(final String name, final Entity> entity) {
return mkPublisher(name, entity);
}
@Override
public Publisher method(final String name, final Entity> entity, final Class responseType) {
return mkPublisher(name, entity, responseType);
}
@Override
public Publisher method(final String name, final Entity> entity, final GenericType responseType) {
return mkPublisher(name, entity, responseType);
}
}