use of org.apache.cxf.jaxrs.impl.AsyncResponseImpl in project cxf by apache.
the class JAXRSUtils method processParameter.
private static Object processParameter(Class<?> parameterClass, Type parameterType, Annotation[] parameterAnns, Parameter parameter, MultivaluedMap<String, String> values, Message message, OperationResourceInfo ori) throws IOException, WebApplicationException {
InputStream is = message.getContent(InputStream.class);
if (is == null) {
Reader reader = message.getContent(Reader.class);
if (reader != null) {
is = new ReaderInputStream(reader);
}
}
if (parameter.getType() == ParameterType.REQUEST_BODY) {
if (parameterClass == AsyncResponse.class) {
return new AsyncResponseImpl(message);
}
String contentType = (String) message.get(Message.CONTENT_TYPE);
if (contentType == null) {
String defaultCt = (String) message.getContextualProperty(DEFAULT_CONTENT_TYPE);
contentType = defaultCt == null ? MediaType.APPLICATION_OCTET_STREAM : defaultCt;
}
return readFromMessageBody(parameterClass, parameterType, parameterAnns, is, toMediaType(contentType), ori, message);
} else if (parameter.getType() == ParameterType.CONTEXT) {
return createContextValue(message, parameterType, parameterClass);
} else if (parameter.getType() == ParameterType.BEAN) {
return createBeanParamValue(message, parameterClass, ori);
} else {
return createHttpParameterValue(parameter, parameterClass, parameterType, parameterAnns, message, values, ori);
}
}
use of org.apache.cxf.jaxrs.impl.AsyncResponseImpl in project cxf by apache.
the class JAXRSInvoker method checkFutureResponse.
protected AsyncResponseImpl checkFutureResponse(Message inMessage, Object result) {
if (result instanceof CompletionStage) {
final CompletionStage<?> stage = (CompletionStage<?>) result;
final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage);
stage.whenComplete((v, t) -> {
if (t instanceof CancellationException) {
asyncResponse.cancel();
} else {
asyncResponse.resume(v != null ? v : t);
}
});
return asyncResponse;
}
return null;
}
Aggregations