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

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

本文整理了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

  1. protected Object invokeMethod(Object instance, Method m, Message msg) throws InvocationTargetException {
  2. try {
  3. Object payload = msg.getBody();
  4. if (payload != null && !payload.getClass().isArray()) {
  5. return m.invoke(instance, payload);
  6. } else {
  7. return m.invoke(instance, (Object[])payload);
  8. }
  9. } catch (InvocationTargetException e) {
  10. throw e;
  11. } catch (Exception e) {
  12. throw new InvocationTargetException(e);
  13. }
  14. }

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

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

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

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

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

  1. private Message invokeResponse(Message msg) throws IOException {
  2. HTTPContext context = msg.getBindingContext();
  3. HttpServletRequest servletRequest = context.getHttpRequest();
  4. HttpServletResponse servletResponse = context.getHttpResponse();
  5. if (msg.isFault()) {
  6. servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, String.valueOf(msg.getBody()));
  7. } else {
  8. String response = getResponseAsString(servletRequest, servletResponse, msg.getBody());
  9. servletResponse.getOutputStream().println(response);
  10. }
  11. return msg;
  12. }

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

  1. public Message invokeResponse(Message msg) {
  2. if (msg.getBody() != null){
  3. Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody());
  4. if (response instanceof InvocationTargetException) {
  5. msg.setFaultBody(((InvocationTargetException) response).getCause());
  6. } else {
  7. if (response != null){
  8. msg.setBody(response);
  9. } else {
  10. msg.setBody(null);
  11. }
  12. }
  13. }
  14. return msg;
  15. }

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

  1. public Message invokeRequest(Message tuscanyMsg) {
  2. try {
  3. javax.jms.Message jmsMsg = tuscanyMsg.getBody();
  4. // Handle MESSAGE_ID field of the JMS message, which is used to correlate async callbacks
  5. String msgID = (String)jmsMsg.getObjectProperty("MESSAGE_ID");
  6. if( msgID != null ) {
  7. tuscanyMsg.getHeaders().put("MESSAGE_ID", msgID);
  8. } // end if
  9. //
  10. } catch (JMSException e) {
  11. throw new JMSBindingException(e);
  12. } // end try
  13. return tuscanyMsg;
  14. } // end method invokeRequest

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

  1. public Message invoke(Message msg) {
  2. try {
  3. Object[] args = msg.getBody();
  4. Object resp = invokeTarget(args);
  5. msg.setBody(resp);
  6. } catch (InvocationTargetException e) {
  7. msg.setFaultBody(e.getCause());
  8. } catch (Exception e) {
  9. msg.setFaultBody(e);
  10. }
  11. return msg;
  12. }

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

  1. /**
  2. * Regular (sync) processing of response message
  3. */
  4. public Message processResponse(Message msg){
  5. if (passByValue) {
  6. // Note source and target operation swapped so result is in source class loader
  7. if (msg.isFault()) {
  8. Object transformedFault = bindingSCATransformer.transformFault(msg.getBody());
  9. msg.setFaultBody(transformedFault);
  10. } else {
  11. Object transformedOutput = bindingSCATransformer.transformOutput(msg.getBody());
  12. msg.setBody(transformedOutput);
  13. } // end if
  14. } // end if
  15. return msg;
  16. } // end method processResponse

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

  1. public Message invoke(Message msg) {
  2. try {
  3. Object[] args = msg.getBody();
  4. Object resp = invokeTarget(args);
  5. msg.setBody(resp);
  6. } catch (InvocationTargetException e) {
  7. msg.setFaultBody(e.getCause());
  8. } catch (Throwable e) {
  9. msg.setFaultBody(e);
  10. }
  11. return msg;
  12. }

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

  1. public Message invoke(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. javax.jms.Message jmsMsg = msg.getBody();
  5. // JMS header attrs set on MessageProducer via interceptors.
  6. return getNext().invoke(msg);
  7. }

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

  1. public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
  2. Message msg = messageFactory.createMessage();
  3. msg.setBody(args);
  4. Message resp = invoke(operation, msg);
  5. Object body = resp.getBody();
  6. if (resp.isFault()) {
  7. throw new InvocationTargetException((Throwable)body);
  8. }
  9. return body;
  10. }

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

  1. public Message invoke(Message msg) {
  2. try {
  3. Object[] args = msg.getBody();
  4. Object resp = invokeTarget(args);
  5. msg.setBody(resp);
  6. } catch (InvocationTargetException e) {
  7. msg.setFaultBody(e.getCause());
  8. } catch (Throwable e) {
  9. msg.setFaultBody(e);
  10. }
  11. return msg;
  12. }

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

  1. public Message invoke(Message msg) {
  2. try {
  3. if( isCallback ) {
  4. // Extract the callback endpoint metadata
  5. callbackEPR = msg.getFrom();
  6. } // end if
  7. Object[] args = msg.getBody();
  8. Object resp = doTheWork(args);
  9. msg.setBody(resp);
  10. } catch (InvocationTargetException e) {
  11. msg.setFaultBody(e.getCause());
  12. }
  13. return msg;
  14. }

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

  1. public Message invoke(Message msg) {
  2. if (chain.allowsPassByReference()) {
  3. return nextInvoker.invoke(msg);
  4. }
  5. msg.setBody(mediator.copyInput(msg.getBody(), operation));
  6. Message resultMsg = nextInvoker.invoke(msg);
  7. if (!resultMsg.isFault() && operation.getOutputType() != null) {
  8. resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
  9. }
  10. if (resultMsg.isFault()) {
  11. resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
  12. }
  13. return resultMsg;
  14. }

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

  1. @Override
  2. protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  3. HTTPContext bindingContext = new HTTPContext();
  4. bindingContext.setHttpRequest(request);
  5. bindingContext.setHttpResponse(response);
  6. Message msg = messageFactory.createMessage();
  7. msg.setBindingContext(bindingContext);
  8. Message responseMessage = wire.invoke(msg);
  9. // return response to client
  10. if (responseMessage.isFault()) {
  11. // Turn a fault into an exception
  12. Throwable e = (Throwable)responseMessage.getBody();
  13. response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
  14. }
  15. }
  16. }

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

  1. public Message invoke(Message msg) {
  2. if (chain.allowsPassByReference()) {
  3. return nextInvoker.invoke(msg);
  4. }
  5. msg.setBody(mediator.copyInput(msg.getBody(), operation));
  6. Message resultMsg = nextInvoker.invoke(msg);
  7. if (!resultMsg.isFault() && operation.getOutputType() != null) {
  8. resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
  9. }
  10. if (resultMsg.isFault()) {
  11. resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
  12. }
  13. return resultMsg;
  14. }

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

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

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

  1. public Message invoke(Message msg) {
  2. try {
  3. Object resp = doInvoke((Object[])msg.getBody(), msg.getOperation());
  4. msg.setBody(resp);
  5. } catch (ScriptException e) {
  6. msg.setFaultBody(e.getCause());
  7. }
  8. return msg;
  9. }

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

  1. public Message invokeRequest(Message msg) {
  2. try {
  3. // get the jms context
  4. JMSBindingContext context = msg.getBindingContext();
  5. Session session = context.getJmsSession();
  6. javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
  7. msg.setBody(requestMsg);
  8. requestMsg.setJMSReplyTo(context.getReplyToDestination());
  9. return msg;
  10. } catch (JMSException e) {
  11. throw new JMSBindingException(e);
  12. }
  13. }

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

  1. public Message invokeRequest(Message msg) {
  2. try {
  3. // get the jms context
  4. JMSBindingContext context = msg.getBindingContext();
  5. Session session = context.getJmsSession();
  6. javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
  7. msg.setBody(requestMsg);
  8. requestMsg.setJMSReplyTo(context.getReplyToDestination());
  9. return msg;
  10. } catch (JMSException e) {
  11. throw new JMSBindingException(e);
  12. }
  13. }

相关文章