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

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

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

Message.reset介绍

[英]Resets the message making it available for reuse.
[中]重置消息,使其可重复使用。

代码示例

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

/**
   * Resets and returns the Message for the current thread.
   *
   * @return the Message for the current thread
   */
  public static Message getAndResetMessage() {
    Message message = getMessage();
    message.reset();
    return message;
  }
}

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

public Message invoke(Message message) {
  Object[] args = (Object[]) message.getBody();
  ClassLoader old = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    Object body = response.build(args);
    message.reset();
    message.setBody(body);
  } catch (RuntimeException e) {
    throw new ServiceRuntimeException(e);
  } finally {
    Thread.currentThread().setContextClassLoader(old);
  }
  return message;
}

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

public Message invoke(Message message) {
  Object[] args = (Object[]) message.getBody();
  ClassLoader old = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    Object body = response.build(args);
    message.reset();
    message.setBody(body);
  } catch (RuntimeException e) {
    throw new ServiceRuntimeException(e);
  } finally {
    Thread.currentThread().setContextClassLoader(old);
  }
  return message;
}

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

public void run() {
    Message request = MessageCache.getAndResetMessage();
    try {
      request.setBody(frames[0]);
      int methodIndex = ByteBuffer.wrap(frames[1]).getInt();
      WorkContext context = setWorkContext(frames[2]);
      request.setWorkContext(context);
      Interceptor interceptor = interceptors[methodIndex];
      interceptor.invoke(request);
    } finally {
      request.reset();
    }
  }
});

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

public Object invoke(Packet packet, Method method, Object... args) throws InvocationTargetException {
  // the work context is populated by the current tubeline
  WorkContext workContext = (WorkContext) packet.invocationProperties.get(MetroConstants.WORK_CONTEXT);
  if (workContext == null) {
    // programming error
    throw new AssertionError("Work context not set");
  }
  Message input = MessageCache.getAndResetMessage();
  try {
    input.setWorkContext(workContext);
    input.setBody(args);
    Interceptor head = chains.get(method.getName()).getHeadInterceptor();
    Message ret = head.invoke(input);
    if (!ret.isFault()) {
      return ret.getBody();
    } else {
      Throwable th = (Throwable) ret.getBody();
      throw new InvocationTargetException(th);
    }
  } finally {
    input.reset();
  }
}

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

public Object invoke(Packet packet, Method method, Object... args) throws InvocationTargetException {
  // the work context is populated by the current tubeline
  WorkContext workContext = (WorkContext) packet.invocationProperties.get(MetroConstants.WORK_CONTEXT);
  if (workContext == null) {
    // programming error
    throw new AssertionError("Work context not set");
  }
  Message input = MessageCache.getAndResetMessage();
  try {
    input.setWorkContext(workContext);
    input.setBody(args);
    Interceptor head = chains.get(method.getName()).getHeadInterceptor();
    Message ret = head.invoke(input);
    if (!ret.isFault()) {
      return ret.getBody();
    } else {
      Throwable th = (Throwable) ret.getBody();
      throw new InvocationTargetException(th);
    }
  } finally {
    input.reset();
  }
}

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

public void run() {
    Message request = MessageCache.getAndResetMessage();
    try {
      request.setBody(frames[0]);
      int methodIndex = ByteBuffer.wrap(frames[1]).getInt();
      WorkContext context = setWorkContext(frames[2]);
      request.setWorkContext(context);
      Interceptor interceptor = interceptors[methodIndex];
      // invoke the service
      Message response = interceptor.invoke(request);
      Object responseBody = response.getBody();
      if (!(responseBody instanceof byte[])) {
        throw new ServiceRuntimeException("Return value not serialized");
      }
      // queue the response
      try {
        queue.put(new Response(clientId, (byte[]) responseBody));
      } catch (InterruptedException e) {
        Thread.interrupted();
      }
    } finally {
      request.reset();
      //                    context.reset();
    }
  }
});

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

throw new InvocationTargetException(e);
} finally {
  input.reset();

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

public Object invoke(Method method, Object[] args) throws Throwable {
  InvocationChain invocationChain = chains.get(method.getName());
  if (invocationChain == null) {
    throw new ServiceRuntimeException("Unknown resource method: " + method.toString());
  }
  WorkContext context = WorkContextCache.getThreadWorkContext();   // work context set previously in RsContainer
  Message message = MessageCache.getAndResetMessage();
  try {
    message.setWorkContext(context);
    message.setBody(args);
    if (invocationChain != null) {
      Interceptor headInterceptor = invocationChain.getHeadInterceptor();
      Message ret = headInterceptor.invoke(message);
      if (ret.isFault()) {
        return handleFault(ret);
      } else {
        return ret.getBody();
      }
    } else {
      return null;
    }
  } catch (RuntimeException e) {
    throw new InvocationTargetException(e);
  } finally {
    message.reset();
  }
}

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

public Object invoke(Method method, Object[] args) throws Throwable {
  InvocationChain invocationChain = chains.get(method.getName());
  if (invocationChain == null) {
    throw new ServiceRuntimeException("Unknown resource method: " + method.toString());
  }
  WorkContext context = WorkContextCache.getThreadWorkContext();   // work context set previously in RsContainer
  Message message = MessageCache.getAndResetMessage();
  try {
    message.setWorkContext(context);
    message.setBody(args);
    if (invocationChain != null) {
      Interceptor headInterceptor = invocationChain.getHeadInterceptor();
      Message ret = headInterceptor.invoke(message);
      if (ret.isFault()) {
        return handleFault(ret);
      } else {
        return ret.getBody();
      }
    } else {
      return null;
    }
  } catch (RuntimeException e) {
    throw new InvocationTargetException(e);
  } finally {
    message.reset();
  }
}

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

inMessage.reset();
  return;
  sendResponse(request, responseSession, outMessage, response);
} finally {
  inMessage.reset();
  workContext.reset();
  if (responseSession != null) {

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

public boolean onUpload(String fileName, String contentType, InputStream uploadData) throws Exception {
  Object[] args = new Object[]{fileName, uploadData};
  WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext();
  Message input = MessageCache.getAndResetMessage();
  try {
    // set the header value for the request context
    workContext.setHeader(FtpConstants.HEADER_CONTENT_TYPE, contentType);
    input.setWorkContext(workContext);
    input.setBody(args);
    Message response = getInterceptor().invoke(input);
    if (response.isFault()) {
      monitor.fileProcessingError(servicePath, (Throwable) response.getBody());
      input.reset();
      return false;
    }
    return true;
  } finally {
    input.reset();
    workContext.reset();
  }
}

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

throw e;
} finally {
  message.reset();
  workContext.reset();

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

workContext.popCallbackReference();
message.reset();

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

workContext.popCallbackReference();
message.reset();

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

public void run() {
  WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext();
  workContext.addCallbackReferences(stack);
  workContext.addHeaders(headers);
  workContext.setSubject(subject);
  Message message = MessageCache.getAndResetMessage();
  message.setBody(payload);
  message.setWorkContext(workContext);
  Message response = next.invoke(message);
  if (response.isFault()) {
    // log the exception
    monitor.onError((Throwable) response.getBody());
  }
  message.reset();
  workContext.reset();
}

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

message.reset();

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

message.reset();

代码示例来源: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;
}

相关文章