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

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

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

Message.isFault介绍

[英]Determines if the message represents a fault/exception
[中]确定消息是否表示故障/异常

代码示例

代码示例来源: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-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-http-runtime

  1. private Message invokeResponse(Message msg) throws IOException {
  2. HTTPContext context = msg.getBindingContext();
  3. HttpServletResponse servletResponse = context.getHttpResponse();
  4. servletResponse.setContentType("text/xml");
  5. Object o = msg.getBody();
  6. if (msg.isFault()) {
  7. String xml = domHelper.saveAsString((Node)((FaultException)o).getFaultInfo());
  8. servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, xml);
  9. } else {
  10. String xml = "";
  11. if (o instanceof Element) {
  12. xml = domHelper.saveAsString((Node)o);
  13. } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof Node) {
  14. xml = domHelper.saveAsString((Node)((Object[])o)[0]);
  15. } else if (o != null) {
  16. throw new IllegalStateException("expecting Node payload: " + o);
  17. }
  18. servletResponse.getOutputStream().println(xml);
  19. }
  20. return msg;
  21. }

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

  1. @Override
  2. protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  3. // Authenticate the user
  4. String user = processAuthorizationHeader(request);
  5. if (user == null) {
  6. unauthorized(response);
  7. return;
  8. }
  9. // Get the request path
  10. String path = URLDecoder.decode(HTTPUtils.getRequestPath(request), "UTF-8");
  11. String id;
  12. if (path != null && path.startsWith("/")) {
  13. id = path.substring(1);
  14. } else {
  15. id = "";
  16. }
  17. // Delete a specific entry from the collection
  18. Message requestMessage = messageFactory.createMessage();
  19. requestMessage.setBody(new Object[] {id});
  20. Message responseMessage = deleteInvoker.invoke(requestMessage);
  21. if (responseMessage.isFault()) {
  22. Object body = responseMessage.getBody();
  23. if (body.getClass().getName().endsWith(".NotFoundException")) {
  24. response.sendError(HttpServletResponse.SC_NOT_FOUND);
  25. } else {
  26. throw new ServletException((Throwable)responseMessage.getBody());
  27. }
  28. }
  29. }

代码示例来源: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. if (resultMsg.isFault()) {
  2. Object transformedFault = null;
  3. if ((result instanceof Exception) && !(result instanceof RuntimeException)) {

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

  1. if (resultMsg.isFault()) {
  2. Object transformedFault = null;
  3. if ((result instanceof Exception) && !(result instanceof RuntimeException)) {

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

  1. requestMessage.setBody(new Object[]{request, response});
  2. Message responseMessage = serviceInvoker.invoke(requestMessage);
  3. if (responseMessage.isFault()) {

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

  1. public void run() {
  2. Message context = ThreadMessageContext.setMessageContext(msg);
  3. try {
  4. Message response = null;
  5. Throwable ex = null;
  6. try {
  7. response = next.invoke(msg);
  8. } catch (Throwable t) {
  9. ex = t;
  10. }
  11. // Tuscany-2225 - Did the @OneWay method complete successfully?
  12. // (i.e. no exceptions)
  13. if (response != null && response.isFault()) {
  14. // The @OneWay method threw an Exception. Lets log it and
  15. // then pass it on to the WorkScheduler so it can notify any
  16. // listeners
  17. ex = (Throwable)response.getBody();
  18. }
  19. if (ex != null) {
  20. LOGGER.log(Level.SEVERE, "Exception from @OneWay invocation", ex);
  21. throw new ServiceRuntimeException("Exception from @OneWay invocation", ex);
  22. }
  23. } finally {
  24. ThreadMessageContext.setMessageContext(context);
  25. }
  26. }
  27. });

代码示例来源: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/tuscany-base-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/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-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-ws-runtime-axis2

  1. MessageContext responseMC = bindingContext.getAxisOutMessageContext();
  2. if(!response.isFault()) {
  3. OMElement responseOM = response.getBody();

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

  1. public Message invokeResponse(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. // The Binding Context may be null on an asynchronous response - in which case, create a new one
  5. if(context == null) {
  6. context = createBindingContext();
  7. msg.setBindingContext(context);
  8. }
  9. Session session = context.getJmsResponseSession();
  10. javax.jms.Message responseJMSMsg;
  11. if (msg.isFault()) {
  12. responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
  13. } else {
  14. Object response = msg.getBody();
  15. responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
  16. }
  17. msg.setBody(responseJMSMsg);
  18. return msg;
  19. }

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

  1. public Message invokeResponse(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. // The Binding Context may be null on an asynchronous response - in which case, create a new one
  5. if(context == null) {
  6. context = createBindingContext();
  7. msg.setBindingContext(context);
  8. }
  9. Session session = context.getJmsResponseSession();
  10. javax.jms.Message responseJMSMsg;
  11. if (msg.isFault()) {
  12. responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
  13. } else {
  14. responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
  15. }
  16. msg.setBody(responseJMSMsg);
  17. return msg;
  18. }

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

  1. public Message invokeResponse(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. // The Binding Context may be null on an asynchronous response - in which case, create a new one
  5. if(context == null) {
  6. context = createBindingContext();
  7. msg.setBindingContext(context);
  8. }
  9. Session session = context.getJmsResponseSession();
  10. javax.jms.Message responseJMSMsg = null;
  11. if (msg.isFault()) {
  12. responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
  13. } else {
  14. responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
  15. }
  16. msg.setBody(responseJMSMsg);
  17. return msg;
  18. }

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

  1. public Message invokeResponse(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. // The Binding Context may be null on an asynchronous response - in which case, create a new one
  5. if(context == null) {
  6. context = createBindingContext();
  7. msg.setBindingContext(context);
  8. }
  9. Session session = context.getJmsResponseSession();
  10. javax.jms.Message responseJMSMsg;
  11. if (msg.isFault()) {
  12. responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
  13. } else {
  14. Object response = msg.getBody();
  15. responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
  16. }
  17. msg.setBody(responseJMSMsg);
  18. return msg;
  19. }

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

  1. public Message invokeResponse(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. // The Binding Context may be null on an asynchronous response - in which case, create a new one
  5. if(context == null) {
  6. context = createBindingContext();
  7. msg.setBindingContext(context);
  8. }
  9. Session session = context.getJmsResponseSession();
  10. javax.jms.Message responseJMSMsg;
  11. if (msg.isFault()) {
  12. responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
  13. } else {
  14. Object response = msg.getBody();
  15. responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
  16. }
  17. msg.setBody(responseJMSMsg);
  18. return msg;
  19. }

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

  1. if (msg.isFault()) {
  2. if (respondBytesMessage == true) {
  3. responseJMSMsg = requestMessageProcessor.createFaultJMSBytesMessage(session, (Throwable) msg.getBody());

相关文章