org.apache.cxf.jaxrs.client.AsyncInvokerImpl Maven / Gradle / Ivy
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.jaxrs.client;
import java.util.concurrent.Future;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.client.AsyncInvoker;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
public class AsyncInvokerImpl implements AsyncInvoker {
private WebClient wc;
public AsyncInvokerImpl(WebClient wc) {
this.wc = wc;
}
@Override
public Future get() {
return get(Response.class);
}
@Override
public Future get(Class responseType) {
return method(HttpMethod.GET, responseType);
}
@Override
public Future get(GenericType responseType) {
return method(HttpMethod.GET, responseType);
}
@Override
public Future get(InvocationCallback callback) {
return method(HttpMethod.GET, callback);
}
@Override
public Future put(Entity> entity) {
return put(entity, Response.class);
}
@Override
public Future put(Entity> entity, Class responseType) {
return method(HttpMethod.PUT, entity, responseType);
}
@Override
public Future put(Entity> entity, GenericType responseType) {
return method(HttpMethod.PUT, entity, responseType);
}
@Override
public Future put(Entity> entity, InvocationCallback callback) {
return method(HttpMethod.PUT, entity, callback);
}
@Override
public Future post(Entity> entity) {
return post(entity, Response.class);
}
@Override
public Future post(Entity> entity, Class responseType) {
return method(HttpMethod.POST, entity, responseType);
}
@Override
public Future post(Entity> entity, GenericType responseType) {
return method(HttpMethod.POST, entity, responseType);
}
@Override
public Future post(Entity> entity, InvocationCallback callback) {
return method(HttpMethod.POST, entity, callback);
}
@Override
public Future delete() {
return delete(Response.class);
}
@Override
public Future delete(Class responseType) {
return method(HttpMethod.DELETE, responseType);
}
@Override
public Future delete(GenericType responseType) {
return method(HttpMethod.DELETE, responseType);
}
@Override
public Future delete(InvocationCallback callback) {
return method(HttpMethod.DELETE, callback);
}
@Override
public Future head() {
return method(HttpMethod.HEAD);
}
@Override
public Future head(InvocationCallback callback) {
return method(HttpMethod.HEAD, callback);
}
@Override
public Future options() {
return options(Response.class);
}
@Override
public Future options(Class responseType) {
return method(HttpMethod.OPTIONS, responseType);
}
@Override
public Future options(GenericType responseType) {
return method(HttpMethod.OPTIONS, responseType);
}
@Override
public Future options(InvocationCallback callback) {
return method(HttpMethod.OPTIONS, callback);
}
@Override
public Future trace() {
return trace(Response.class);
}
@Override
public Future trace(Class responseType) {
return method("TRACE", responseType);
}
@Override
public Future trace(GenericType responseType) {
return method("TRACE", responseType);
}
@Override
public Future trace(InvocationCallback callback) {
return method("TRACE", callback);
}
@Override
public Future method(String name) {
return method(name, Response.class);
}
@Override
public Future method(String name, Class responseType) {
return wc.doInvokeAsync(name, null, null, null, responseType, responseType, null);
}
@Override
public Future method(String name, GenericType responseType) {
return wc.doInvokeAsync(name, null, null, null, responseType.getRawType(),
responseType.getType(), null);
}
@Override
public Future method(String name, InvocationCallback callback) {
return wc.doInvokeAsyncCallback(name, null, null, null, callback);
}
@Override
public Future method(String name, Entity> entity) {
return method(name, entity, Response.class);
}
@Override
public Future method(String name, Entity> entity, Class responseType) {
return wc.doInvokeAsync(name,
entity,
null,
null, responseType, responseType, null);
}
@Override
public Future method(String name, Entity> entity, GenericType responseType) {
return wc.doInvokeAsync(name,
entity,
null,
null, responseType.getRawType(), responseType.getType(), null);
}
@Override
public Future method(String name, Entity> entity, InvocationCallback callback) {
return wc.doInvokeAsyncCallback(name,
entity,
null,
null,
callback);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy