Search in sources :

Example 1 with ClientResponse

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);
}
Also used : RestfulClientResponse(com.weibo.api.motan.protocol.restful.support.RestfulClientResponse) ClientResponse(org.jboss.resteasy.client.jaxrs.internal.ClientResponse) ClientContext(org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.ClientContext) ClientInvocation(org.jboss.resteasy.client.jaxrs.internal.ClientInvocation)

Example 2 with ClientResponse

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;
}
Also used : ClientResponse(org.jboss.resteasy.client.jaxrs.internal.ClientResponse) Response(javax.ws.rs.core.Response) ClientResponse(org.jboss.resteasy.client.jaxrs.internal.ClientResponse) RestFailure(com.peterphi.std.guice.restclient.jaxb.RestFailure) WebApplicationException(javax.ws.rs.WebApplicationException) WebApplicationException(javax.ws.rs.WebApplicationException) ApplicationException(org.jboss.resteasy.spi.ApplicationException)

Example 3 with ClientResponse

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;
}
Also used : ClientResponse(org.jboss.resteasy.client.jaxrs.internal.ClientResponse) HttpURLConnection(java.net.HttpURLConnection) IOException(java.io.IOException) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

ClientResponse (org.jboss.resteasy.client.jaxrs.internal.ClientResponse)3 RestFailure (com.peterphi.std.guice.restclient.jaxb.RestFailure)1 RestfulClientResponse (com.weibo.api.motan.protocol.restful.support.RestfulClientResponse)1 IOException (java.io.IOException)1 HttpURLConnection (java.net.HttpURLConnection)1 ProcessingException (javax.ws.rs.ProcessingException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 ClientInvocation (org.jboss.resteasy.client.jaxrs.internal.ClientInvocation)1 ClientContext (org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.ClientContext)1 ApplicationException (org.jboss.resteasy.spi.ApplicationException)1