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

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

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

Message.getWorkContext介绍

[英]Returns the context associated with this invocation.
[中]返回与此调用关联的上下文。

代码示例

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

  1. public Message invoke(Message msg) {
  2. byte[] body = (byte[]) msg.getBody();
  3. WorkContext workContext = msg.getWorkContext();
  4. sender.send(body, index, workContext);
  5. return ONE_WAY_RESPONSE;
  6. }

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

  1. /**
  2. * Adds F3-specific routing headers to a message.
  3. *
  4. * @param message the invocation message
  5. * @param jmsMessage the JMS message to be dispatched
  6. * @throws JMSException if an error occurs setting the headers
  7. * @throws IOException if an error occurs serializing the routing information
  8. */
  9. private void setRoutingHeaders(Message message, javax.jms.Message jmsMessage) throws JMSException, IOException {
  10. List<String> stack = message.getWorkContext().getCallbackReferences();
  11. if (stack == null || stack.isEmpty()) {
  12. return;
  13. }
  14. jmsMessage.setObjectProperty(JmsRuntimeConstants.CONTEXT_HEADER, CallbackReferenceSerializer.serializeToString(stack));
  15. }

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

  1. public Message invoke(Message msg) {
  2. byte[] body = (byte[]) msg.getBody();
  3. WorkContext workContext = msg.getWorkContext();
  4. byte[] value = sender.sendAndReply(body, index, workContext);
  5. msg.setBody(value);
  6. return msg;
  7. }

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

  1. public Message invoke(final Message msg) {
  2. WorkContext workContext = msg.getWorkContext();
  3. List<String> newStack = null;
  4. List<String> stack = workContext.getCallbackReferences();
  5. if (stack != null && !stack.isEmpty()) {
  6. // clone the callstack to avoid multiple threads seeing changes
  7. newStack = new ArrayList<>(stack);
  8. }
  9. Map<String, Object> newHeaders = null;
  10. Map<String, Object> headers = workContext.getHeaders();
  11. if (headers != null && !headers.isEmpty()) {
  12. // clone the headers to avoid multiple threads seeing changes
  13. newHeaders = new HashMap<>(headers);
  14. }
  15. SecuritySubject subject = workContext.getSubject();
  16. Object payload = msg.getBody();
  17. AsyncRequest request = new AsyncRequest(next, payload, subject, newStack, newHeaders, monitor);
  18. executorService.execute(request);
  19. return RESPONSE;
  20. }

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

  1. public boolean handleMessage(SOAPMessageContext smc) {
  2. Boolean outbound = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
  3. WorkContext workContext = WorkContextCache.getThreadWorkContext();
  4. workContext = (WorkContext) (workContext == null ? smc.get(MetroConstants.WORK_CONTEXT) : workContext);
  5. if (workContext == null) {
  6. throw new ServiceRuntimeException("Work context not set");
  7. }
  8. if (outbound) {
  9. // reference proxy outbound or service invocation return
  10. Message msg = MessageCache.getMessage();
  11. if (msg.getWorkContext() == null) {
  12. // service invocation return
  13. msg.setBody(smc.getMessage());
  14. msg.setWorkContext(workContext);
  15. }
  16. delegateHandler.handleOutbound(msg, smc.getMessage());
  17. } else {
  18. // reference proxy invocation return or service invocation
  19. Message msg = MessageCache.getMessage();
  20. if (msg.getWorkContext() == null) {
  21. // reference proxy return
  22. msg.setBody(smc.getMessage());
  23. msg.setWorkContext(workContext);
  24. }
  25. delegateHandler.handleInbound(smc.getMessage(), msg);
  26. msg.reset();
  27. }
  28. return true;
  29. }

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

  1. public boolean handleMessage(SOAPMessageContext smc) {
  2. Boolean outbound = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
  3. WorkContext workContext = WorkContextCache.getThreadWorkContext();
  4. workContext = (WorkContext) (workContext == null ? smc.get(MetroConstants.WORK_CONTEXT) : workContext);
  5. if (workContext == null) {
  6. throw new ServiceRuntimeException("Work context not set");
  7. }
  8. if (outbound) {
  9. // reference proxy outbound or service invocation return
  10. Message msg = MessageCache.getMessage();
  11. if (msg.getWorkContext() == null) {
  12. // service invocation return
  13. msg.setBody(smc.getMessage());
  14. msg.setWorkContext(workContext);
  15. }
  16. delegateHandler.handleOutbound(msg, smc.getMessage());
  17. } else {
  18. // reference proxy invocation return or service invocation
  19. Message msg = MessageCache.getMessage();
  20. if (msg.getWorkContext() == null) {
  21. // reference proxy return
  22. msg.setBody(smc.getMessage());
  23. msg.setWorkContext(workContext);
  24. }
  25. delegateHandler.handleInbound(smc.getMessage(), msg);
  26. msg.reset();
  27. }
  28. return true;
  29. }

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

  1. ftpClient.connect(hostAddress, port);
  2. monitor.onResponse(ftpClient.getReplyString());
  3. String type = msg.getWorkContext().getHeader(String.class, FtpConstants.HEADER_CONTENT_TYPE);
  4. if (type != null && type.equalsIgnoreCase(FtpConstants.BINARY_TYPE)) {
  5. monitor.onCommand("TYPE I");

相关文章