org.fabric3.spi.container.invocation.Message.setBodyWithFault()方法的使用及代码示例

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

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

Message.setBodyWithFault介绍

[英]Set the message body with a fault object. After this method is called, isFault() returns true.
[中]将消息正文设置为故障对象。调用此方法后,isFault()返回true。

代码示例

代码示例来源:origin: com.carecon.fabric3/fabric3-pojo

  1. /**
  2. * Performs the invocation on the target component instance. If a target classloader is configured for the interceptor, it will be set as the TCCL.
  3. *
  4. * @param msg the messaging containing the invocation data
  5. * @param instance the target component instance
  6. * @return the response message
  7. */
  8. private Message invoke(Message msg, Object instance) {
  9. try {
  10. Object body = msg.getBody();
  11. if (targetTCCLClassLoader == null) {
  12. msg.setBody(invoker.invoke(instance, body));
  13. } else {
  14. ClassLoader old = Thread.currentThread().getContextClassLoader();
  15. try {
  16. Thread.currentThread().setContextClassLoader(targetTCCLClassLoader);
  17. msg.setBody(invoker.invoke(instance, body));
  18. } finally {
  19. Thread.currentThread().setContextClassLoader(old);
  20. }
  21. }
  22. } catch (InvocationTargetException e) {
  23. msg.setBodyWithFault(e.getCause());
  24. } catch (IllegalAccessException e) {
  25. throw new InvocationRuntimeException(e);
  26. }
  27. return msg;
  28. }

代码示例来源:origin: com.carecon.fabric3/fabric3-spring

  1. msg.setBodyWithFault(cause);
  2. } catch (IllegalAccessException e) {
  3. throw new InvocationRuntimeException(e);

代码示例来源:origin: org.fabric3/fabric3-spring

  1. msg.setBodyWithFault(cause);
  2. } catch (IllegalAccessException e) {
  3. throw new InvocationRuntimeException(e);

代码示例来源:origin: org.fabric3/fabric3-pojo

  1. /**
  2. * Performs the invocation on the target component instance. If a target classloader is configured for the interceptor, it will be set as the TCCL.
  3. *
  4. * @param msg the messaging containing the invocation data
  5. * @param instance the target component instance
  6. * @return the response message
  7. */
  8. private Message invoke(Message msg, Object instance) {
  9. try {
  10. Object body = msg.getBody();
  11. if (targetTCCLClassLoader == null) {
  12. msg.setBody(invoker.invoke(instance, body));
  13. } else {
  14. ClassLoader old = Thread.currentThread().getContextClassLoader();
  15. try {
  16. Thread.currentThread().setContextClassLoader(targetTCCLClassLoader);
  17. msg.setBody(invoker.invoke(instance, body));
  18. } finally {
  19. Thread.currentThread().setContextClassLoader(old);
  20. }
  21. }
  22. } catch (InvocationTargetException e) {
  23. msg.setBodyWithFault(e.getCause());
  24. } catch (IllegalAccessException e) {
  25. throw new InvocationRuntimeException(e);
  26. }
  27. return msg;
  28. }

代码示例来源:origin: com.carecon.fabric3/fabric3-binding-jms

  1. if (resultMessage.getBooleanProperty(JmsRuntimeConstants.FAULT_HEADER)) {
  2. Object payload = MessageHelper.getPayload(resultMessage, payloadTypes.getFaultType());
  3. message.setBodyWithFault(payload);
  4. } else {
  5. Object payload = MessageHelper.getPayload(resultMessage, payloadTypes.getOutputType());

代码示例来源:origin: com.carecon.fabric3/fabric3-system

  1. public Message invoke(Message msg) {
  2. Object body = msg.getBody();
  3. Object instance;
  4. try {
  5. instance = component.getInstance();
  6. } catch (Fabric3Exception e) {
  7. throw new InvocationRuntimeException(e);
  8. }
  9. try {
  10. msg.setBody(operation.invoke(instance, (Object[]) body));
  11. } catch (InvocationTargetException e) {
  12. msg.setBodyWithFault(e.getCause());
  13. } catch (IllegalAccessException e) {
  14. throw new InvocationRuntimeException(e);
  15. } finally {
  16. try {
  17. component.releaseInstance(instance);
  18. } catch (Fabric3Exception e) {
  19. throw new InvocationRuntimeException(e);
  20. }
  21. }
  22. return msg;
  23. }
  24. }

代码示例来源:origin: com.carecon.fabric3/fabric3-binding-ws

  1. msg.setBodyWithFault(e.getTargetException());
  2. return msg;

代码示例来源:origin: org.fabric3/fabric3-binding-ws-metro

  1. msg.setBodyWithFault(e.getTargetException());
  2. return msg;

代码示例来源:origin: org.fabric3/fabric3-fabric

  1. private Message transformOutput(Message ret) {
  2. // FIXME For exception transformation, if it is checked convert as application fault
  3. Object body = ret.getBody();
  4. // TODO handle null types
  5. if (body != null) {
  6. try {
  7. Object transformed = outTransformer.transform(body, outLoader);
  8. if (ret.isFault()) {
  9. ret.setBodyWithFault(transformed);
  10. } else {
  11. ret.setBody(transformed);
  12. }
  13. } catch (ClassCastException e) {
  14. // an unexpected type was returned by the target service or an interceptor later in the chain. This is an error in the extension or
  15. // interceptor and not user code since errors should be trapped and returned in the format expected by the transformer
  16. if (body instanceof Throwable) {
  17. throw new ServiceRuntimeException("Unexpected exception returned", (Throwable) body);
  18. } else {
  19. throw new ServiceRuntimeException("Unexpected type returned: " + body.getClass());
  20. }
  21. } catch (Fabric3Exception e) {
  22. throw new ServiceRuntimeException(e);
  23. }
  24. }
  25. return ret;
  26. }

代码示例来源:origin: com.carecon.fabric3/fabric3-fabric

  1. private Message transformOutput(Message ret) {
  2. // FIXME For exception transformation, if it is checked convert as application fault
  3. Object body = ret.getBody();
  4. // TODO handle null types
  5. if (body != null) {
  6. try {
  7. Object transformed = outTransformer.transform(body, outLoader);
  8. if (ret.isFault()) {
  9. ret.setBodyWithFault(transformed);
  10. } else {
  11. ret.setBody(transformed);
  12. }
  13. } catch (ClassCastException e) {
  14. // an unexpected type was returned by the target service or an interceptor later in the chain. This is an error in the extension or
  15. // interceptor and not user code since errors should be trapped and returned in the format expected by the transformer
  16. if (body instanceof Throwable) {
  17. throw new ServiceRuntimeException("Unexpected exception returned", (Throwable) body);
  18. } else {
  19. throw new ServiceRuntimeException("Unexpected type returned: " + body.getClass());
  20. }
  21. } catch (Fabric3Exception e) {
  22. throw new ServiceRuntimeException(e);
  23. }
  24. }
  25. return ret;
  26. }

相关文章