org.apache.tuscany.sca.invocation.Message.getBody()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.apache.tuscany.sca.invocation.Message.getBody()方法的一些代码示例,展示了Message.getBody()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getBody()方法的具体详情如下:
包路径:org.apache.tuscany.sca.invocation.Message
类名称:Message
方法名:getBody

Message.getBody介绍

[英]Returns the body of the message, which will be the payload or parameters associated with the wire
[中]返回消息的正文,它将是与导线相关联的有效载荷或参数

代码示例

代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-osgi-runtime

protected Object invokeMethod(Object instance, Method m, Message msg) throws InvocationTargetException {
  try {
    Object payload = msg.getBody();
    if (payload != null && !payload.getClass().isArray()) {
      return m.invoke(instance, payload);
    } else {
      return m.invoke(instance, (Object[])payload);
    }
  } catch (InvocationTargetException e) {
    throw e;
  } catch (Exception e) {
    throw new InvocationTargetException(e);
  }
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

public Message processRequest(Message msg) {
  Map<String, Object> metadata = new HashMap<String, Object>();
  metadata.put(Invocable.class.getName(), invocable);
  Object input = mediator.mediateInput(msg.getBody(), sourceOperation, targetOperation, metadata);
  msg.setBody(input);
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-core-databinding

public Message processRequest(Message msg) {
  Map<String, Object> metadata = new HashMap<String, Object>();
  metadata.put(Invocable.class.getName(), invocable);
  Object input = mediator.mediateInput(msg.getBody(), sourceOperation, targetOperation, metadata);
  msg.setBody(input);
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime

private Message invokeResponse(Message msg) throws IOException {
  HTTPContext context = msg.getBindingContext();
  HttpServletRequest servletRequest = context.getHttpRequest();
  HttpServletResponse servletResponse = context.getHttpResponse();
  
  if (msg.isFault()) {            
    servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, String.valueOf(msg.getBody()));
  } else {
    String response = getResponseAsString(servletRequest, servletResponse, msg.getBody());
    servletResponse.getOutputStream().println(response);
  }
  
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

public Message invokeResponse(Message msg) {
  if (msg.getBody() != null){
    Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody());
    
    if (response instanceof InvocationTargetException) {
      msg.setFaultBody(((InvocationTargetException) response).getCause());
    } else {
      if (response != null){
        msg.setBody(response);
      } else {
        msg.setBody(null);
      }
    }
  }
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

public Message invokeRequest(Message tuscanyMsg) {
  
  try {
  
    javax.jms.Message jmsMsg = tuscanyMsg.getBody();
    
    // Handle MESSAGE_ID field of the JMS message, which is used to correlate async callbacks
    String msgID = (String)jmsMsg.getObjectProperty("MESSAGE_ID");
    if( msgID != null ) {
      tuscanyMsg.getHeaders().put("MESSAGE_ID", msgID);
    } // end if 
    //
  
  } catch (JMSException e) {
    throw new JMSBindingException(e);
  } // end try
  
  return tuscanyMsg;
} // end method invokeRequest

代码示例来源:origin: com.jns.apps/scallop-binding-rmi-runtime

public Message invoke(Message msg) {
  try {
    Object[] args = msg.getBody();
    Object resp = invokeTarget(args);
    msg.setBody(resp);
  } catch (InvocationTargetException e) {
    msg.setFaultBody(e.getCause());
  } catch (Exception e) {
    msg.setFaultBody(e);
  }
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-sca-runtime

/**
 * Regular (sync) processing of response message
 */
public Message processResponse(Message msg){
  if (passByValue) {
    // Note source and target operation swapped so result is in source class loader
    if (msg.isFault()) {
      Object transformedFault = bindingSCATransformer.transformFault(msg.getBody());
      msg.setFaultBody(transformedFault);
    } else {
      Object transformedOutput = bindingSCATransformer.transformOutput(msg.getBody()); 
      msg.setBody(transformedOutput);
    } // end if
  } // end if
  return msg;
} // end method processResponse

代码示例来源:origin: org.apache.tuscany.sca.aggregation/tuscany-binding-rmi-runtime-aggregation

public Message invoke(Message msg) {
  try {
    Object[] args = msg.getBody();
    Object resp = invokeTarget(args);
    msg.setBody(resp);
  } catch (InvocationTargetException e) {
    msg.setFaultBody(e.getCause());
  } catch (Throwable e) {
    msg.setFaultBody(e);
  }
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

public Message invoke(Message msg) {
    // get the jms context
    JMSBindingContext context = msg.getBindingContext();
    javax.jms.Message jmsMsg = msg.getBody();

    // JMS header attrs set on MessageProducer via interceptors.
          
    return getNext().invoke(msg);
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
  Message msg = messageFactory.createMessage();
  msg.setBody(args);
  Message resp = invoke(operation, msg);
  Object body = resp.getBody();
  if (resp.isFault()) {
    throw new InvocationTargetException((Throwable)body);
  }
  return body;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-rmi-runtime

public Message invoke(Message msg) {
  try {
    Object[] args = msg.getBody();
    Object resp = invokeTarget(args);
    msg.setBody(resp);
  } catch (InvocationTargetException e) {
    msg.setFaultBody(e.getCause());
  } catch (Throwable e) {
    msg.setFaultBody(e);
  }
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-bpel-runtime

public Message invoke(Message msg) {
  try {
    if( isCallback ) {
      // Extract the callback endpoint metadata
      callbackEPR = msg.getFrom();
    } // end if
    Object[] args = msg.getBody();
    Object resp = doTheWork(args);
    msg.setBody(resp);
  } catch (InvocationTargetException e) {
    msg.setFaultBody(e.getCause());
  }
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-core-databinding

public Message invoke(Message msg) {
  if (chain.allowsPassByReference()) {
    return nextInvoker.invoke(msg);
  }
  msg.setBody(mediator.copyInput(msg.getBody(), operation));
  Message resultMsg = nextInvoker.invoke(msg);
  if (!resultMsg.isFault() && operation.getOutputType() != null) {
    resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
  }
  if (resultMsg.isFault()) {
    resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
  }
  return resultMsg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime

@Override
  protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HTTPContext bindingContext = new HTTPContext();
    bindingContext.setHttpRequest(request);
    bindingContext.setHttpResponse(response);
    Message msg = messageFactory.createMessage();
    msg.setBindingContext(bindingContext);
    Message responseMessage = wire.invoke(msg);
    // return response to client
    if (responseMessage.isFault()) {
      // Turn a fault into an exception
      Throwable e = (Throwable)responseMessage.getBody();
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
    } 
  }    
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

public Message invoke(Message msg) {
  if (chain.allowsPassByReference()) {
    return nextInvoker.invoke(msg);
  }
  msg.setBody(mediator.copyInput(msg.getBody(), operation));
  Message resultMsg = nextInvoker.invoke(msg);
  if (!resultMsg.isFault() && operation.getOutputType() != null) {
    resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
  }
  if (resultMsg.isFault()) {
    resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
  }
  return resultMsg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jsonp-runtime

public Message doInvoke(Message msg) throws JsonGenerationException, JsonMappingException, IOException, EncoderException {
  String uri = endpoint.getDeployedURI() + "/" + operation.getName();
  //String[] jsonArgs = objectsToJSON((Object[])msg.getBody());
  String[] jsonArgs = objectsToJSONStrings((Object[])msg.getBody());
  String responseJSON = invokeHTTPRequest(uri, jsonArgs);
  //Object response = jsonToObjects(responseJSON)[0];
  msg.setBody(responseJSON);
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-script-runtime

public Message invoke(Message msg) {
  try {
    Object resp = doInvoke((Object[])msg.getBody(), msg.getOperation());
    msg.setBody(resp);
  } catch (ScriptException e) {
    msg.setFaultBody(e.getCause());
  }
  return msg;
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

public Message invokeRequest(Message msg) {
  try {
    // get the jms context
    JMSBindingContext context = msg.getBindingContext();
    Session session = context.getJmsSession();
    
    javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
    msg.setBody(requestMsg);
    
    requestMsg.setJMSReplyTo(context.getReplyToDestination());
    
    return msg;
  } catch (JMSException e) {
    throw new JMSBindingException(e);
  } 
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

public Message invokeRequest(Message msg) {
  try {
    // get the jms context
    JMSBindingContext context = msg.getBindingContext();
    Session session = context.getJmsSession();
    
    javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
    
    msg.setBody(requestMsg);
    
    requestMsg.setJMSReplyTo(context.getReplyToDestination());
    
    return msg;
  } catch (JMSException e) {
    throw new JMSBindingException(e);
  } 
}

相关文章