use of org.jboss.resteasy.client.jaxrs.internal.ClientResponse in project motan by weibocom.
the class RestfulClientInvoker method invoke.
public Object invoke(Object[] args, Request req, RestfulClientResponse resp) {
ClientInvocation request = createRequest(args, req);
ClientResponse response = (ClientResponse) request.invoke();
resp.setAttachments(RestfulUtil.decodeAttachments(response.getStringHeaders()));
resp.setHttpResponse(response);
ClientContext context = new ClientContext(request, response, entityExtractorFactory);
return extractor.extractEntity(context);
}
use of org.jboss.resteasy.client.jaxrs.internal.ClientResponse in project stdlib by petergeneric.
the class JAXRSExceptionMapper method getResponse.
public Response getResponse(Throwable exception) {
// Response will result in the code to render the Response hanging.
if (exception instanceof WebApplicationException) {
final WebApplicationException webappException = (WebApplicationException) exception;
// Ignore null responses or exceptions whose Response object is actually a client response (a failure in a remote service call)
if (webappException.getResponse() != null && !(webappException.getResponse() instanceof ClientResponse)) {
return webappException.getResponse();
}
}
// Represent the exception as a RestFailure object
final RestFailure failure = marshaller.renderFailure(exception);
// Log the failure
log.error(failure.id + " " + HttpCallContext.get().getRequestInfo() + " threw exception:", exception);
Response response = null;
// Try to use the custom renderer (if present)
if (renderer != null) {
try {
response = renderer.render(failure);
} catch (Exception e) {
log.warn("Exception rendering RestFailure", e);
}
}
// Give the HTML render an opportunity to run
if (response == null)
response = htmlRenderer.render(failure);
// Use the XML renderer if no other renderer has wanted to build the response
if (response == null)
// Fall back on the XML renderer
return xmlRenderer.render(failure);
else
return response;
}
use of org.jboss.resteasy.client.jaxrs.internal.ClientResponse in project java by wavefrontHQ.
the class JavaNetConnectionEngine method invoke.
public ClientResponse invoke(ClientInvocation request) {
final HttpURLConnection connection;
int status;
try {
connection = this.createConnection(request);
this.executeRequest(request, connection);
status = connection.getResponseCode();
} catch (IOException ex) {
throw new ProcessingException(Messages.MESSAGES.unableToInvokeRequest(), ex);
}
ClientResponse response = new JavaNetConnectionClientResponse(request, connection);
response.setStatus(status);
response.setHeaders(this.getHeaders(connection));
return response;
}
Aggregations