コード例 #1
0
ファイル: JAXRSOutInterceptor.java プロジェクト: Evolveum/cxf
  private void processResponse(ServerProviderFactory providerFactory, Message message) {

    if (isResponseAlreadyHandled(message)) {
      return;
    }
    MessageContentsList objs = MessageContentsList.getContentsList(message);
    if (objs == null || objs.size() == 0) {
      return;
    }

    Object responseObj = objs.get(0);

    Response response = null;
    if (responseObj instanceof Response) {
      response = (Response) responseObj;
      if (response.getStatus() == 500
          && message.getExchange().get(JAXRSUtils.EXCEPTION_FROM_MAPPER) != null) {
        message.put(Message.RESPONSE_CODE, 500);
        return;
      }
    } else {
      int status = getStatus(message, responseObj != null ? 200 : 204);
      response = JAXRSUtils.toResponseBuilder(status).entity(responseObj).build();
    }

    Exchange exchange = message.getExchange();
    OperationResourceInfo ori =
        (OperationResourceInfo) exchange.get(OperationResourceInfo.class.getName());

    serializeMessage(providerFactory, message, response, ori, true);
  }
コード例 #2
0
ファイル: AbstractClient.java プロジェクト: Lxzw/cxf
    public void handleMessage(Message outMessage) throws Fault {

      MessageContentsList objs = MessageContentsList.getContentsList(outMessage);
      if (objs == null || objs.size() == 0) {
        return;
      }

      OutputStream os = outMessage.getContent(OutputStream.class);
      if (os == null) {
        XMLStreamWriter writer = outMessage.getContent(XMLStreamWriter.class);
        if (writer == null) {
          return;
        }
      }

      Object body = objs.get(0);
      Annotation[] customAnns = (Annotation[]) outMessage.get(Annotation.class.getName());
      Type t = outMessage.get(Type.class);
      doWriteBody(outMessage, body, t, customAnns, os);
    }