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

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

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

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

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

/**
 * Adds F3-specific routing headers to a message.
 *
 * @param message    the invocation message
 * @param jmsMessage the JMS message to be dispatched
 * @throws JMSException if an error occurs setting the headers
 * @throws IOException  if an error occurs serializing the routing information
 */
private void setRoutingHeaders(Message message, javax.jms.Message jmsMessage) throws JMSException, IOException {
  List<String> stack = message.getWorkContext().getCallbackReferences();
  if (stack == null || stack.isEmpty()) {
    return;
  }
  jmsMessage.setObjectProperty(JmsRuntimeConstants.CONTEXT_HEADER, CallbackReferenceSerializer.serializeToString(stack));
}

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

public Message invoke(Message msg) {
  byte[] body = (byte[]) msg.getBody();
  WorkContext workContext = msg.getWorkContext();
  byte[] value = sender.sendAndReply(body, index, workContext);
  msg.setBody(value);
  return msg;
}

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

public Message invoke(final Message msg) {
  WorkContext workContext = msg.getWorkContext();
  List<String> newStack = null;
  List<String> stack = workContext.getCallbackReferences();
  if (stack != null && !stack.isEmpty()) {
    // clone the callstack to avoid multiple threads seeing changes
    newStack = new ArrayList<>(stack);
  }
  Map<String, Object> newHeaders = null;
  Map<String, Object> headers = workContext.getHeaders();
  if (headers != null && !headers.isEmpty()) {
    // clone the headers to avoid multiple threads seeing changes
    newHeaders = new HashMap<>(headers);
  }
  SecuritySubject subject = workContext.getSubject();
  Object payload = msg.getBody();
  AsyncRequest request = new AsyncRequest(next, payload, subject, newStack, newHeaders, monitor);
  executorService.execute(request);
  return RESPONSE;
}

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

public boolean handleMessage(SOAPMessageContext smc) {
  Boolean outbound = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
  WorkContext workContext = WorkContextCache.getThreadWorkContext();
  workContext = (WorkContext) (workContext == null ? smc.get(MetroConstants.WORK_CONTEXT) : workContext);
  if (workContext == null) {
    throw new ServiceRuntimeException("Work context not set");
  }
  if (outbound) {
    // reference proxy outbound or service invocation return
    Message msg = MessageCache.getMessage();
    if (msg.getWorkContext() == null) {
      // service invocation return
      msg.setBody(smc.getMessage());
      msg.setWorkContext(workContext);
    }
    delegateHandler.handleOutbound(msg, smc.getMessage());
  } else {
    // reference proxy invocation return or service invocation
    Message msg = MessageCache.getMessage();
    if (msg.getWorkContext() == null) {
      // reference proxy return
      msg.setBody(smc.getMessage());
      msg.setWorkContext(workContext);
    }
    delegateHandler.handleInbound(smc.getMessage(), msg);
    msg.reset();
  }
  return true;
}

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

public boolean handleMessage(SOAPMessageContext smc) {
  Boolean outbound = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
  WorkContext workContext = WorkContextCache.getThreadWorkContext();
  workContext = (WorkContext) (workContext == null ? smc.get(MetroConstants.WORK_CONTEXT) : workContext);
  if (workContext == null) {
    throw new ServiceRuntimeException("Work context not set");
  }
  if (outbound) {
    // reference proxy outbound or service invocation return
    Message msg = MessageCache.getMessage();
    if (msg.getWorkContext() == null) {
      // service invocation return
      msg.setBody(smc.getMessage());
      msg.setWorkContext(workContext);
    }
    delegateHandler.handleOutbound(msg, smc.getMessage());
  } else {
    // reference proxy invocation return or service invocation
    Message msg = MessageCache.getMessage();
    if (msg.getWorkContext() == null) {
      // reference proxy return
      msg.setBody(smc.getMessage());
      msg.setWorkContext(workContext);
    }
    delegateHandler.handleInbound(smc.getMessage(), msg);
    msg.reset();
  }
  return true;
}

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

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

相关文章