org.apache.camel.Message.copyFrom()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(224)

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

Message.copyFrom介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

if (storeMessage(msg)) {
  Message msgCopy = new Message();
  msgCopy.copyFrom(msg);
  messageQueueBuffer.add(msgCopy);

代码示例来源:origin: org.apache.camel/camel-github

public void process(Exchange exchange) throws Exception {
  Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class);
  java.util.List<CommitFile> response = pullRequestService.getFiles(getRepository(), pullRequestNumber);
  // copy the header of in message to the out message
  exchange.getOut().copyFrom(exchange.getIn());
  exchange.getOut().setBody(response);
}

代码示例来源:origin: io.rhiot/camel-pubnub

@Override
public void successCallback(String channel, Object message) {
  LOG.trace("PubNub response {}", message);
  exchange.getIn().setHeader(PubNubConstants.CHANNEL, channel);
  if (exchange.getPattern().isOutCapable()) {
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(message);
  }
  callback.done(false);
}

代码示例来源:origin: org.apache.camel/camel-ironmq

private Message getMessageForResponse(Exchange exchange) {
  if (exchange.getPattern().isOutCapable()) {
    Message out = exchange.getOut();
    out.copyFrom(exchange.getIn());
    return out;
  }
  return exchange.getIn();
}

代码示例来源:origin: org.apache.camel/camel-hipchat

private Message getMessageForResponse(final Exchange exchange) {
  if (exchange.getPattern().isOutCapable()) {
    Message out = exchange.getOut();
    out.copyFrom(exchange.getIn());
    return out;
  }
  return exchange.getIn();
}

代码示例来源:origin: org.apache.camel/camel-azure

public static Message getMessageForResponse(final Exchange exchange) {
    if (exchange.getPattern().isOutCapable()) {
      Message out = exchange.getOut();
      out.copyFrom(exchange.getIn());
      return out;
    }
    return exchange.getIn();
  }
}

代码示例来源:origin: io.konig/konig-camel-aws-s3

public static Message getMessageForResponse(final Exchange exchange) {
      if (exchange.getPattern().isOutCapable()) {
        Message out = exchange.getOut();
        out.copyFrom(exchange.getIn());
        return out;
      }
      return exchange.getIn();
    }
}

代码示例来源:origin: org.apache.camel/camel-cassandraql

public void process(Exchange exchange) throws Exception {
  // copy the header of in message to the out message
  exchange.getOut().copyFrom(exchange.getIn());
  ResultSet resultSet = execute(exchange.getIn());
  getEndpoint().fillMessage(resultSet, exchange.getOut());
}

代码示例来源:origin: org.apache.camel/camel-github

public void process(Exchange exchange) throws Exception {
  CommitFile file = exchange.getIn().getBody(CommitFile.class);
  Blob response = dataService.getBlob(getRepository(), file.getSha());
  String text = response.getContent();
  // By default, if blob encoding is base64 then we convert to UTF-8. If
  // base64 encoding is required, then must be explicitly requested
  if (response.getEncoding().equals(Blob.ENCODING_BASE64) 
    && encoding != null && encoding.equalsIgnoreCase(Blob.ENCODING_UTF8)) {
    text = new String(Base64.decodeBase64(text));
  }
  // copy the header of in message to the out message
  exchange.getOut().copyFrom(exchange.getIn());
  exchange.getOut().setBody(text);
}

代码示例来源:origin: org.apache.camel/camel-github

public void process(Exchange exchange) throws Exception {
  Issue issue = new Issue();
  String issueTitle = exchange.getIn().getHeader(GitHubConstants.GITHUB_ISSUE_TITLE, String.class);
  if (ObjectHelper.isEmpty(issueTitle)) {
    throw new IllegalArgumentException("Issue Title must be specified to create an issue");
  }
  issue.setTitle(issueTitle);
  issue.setBody(exchange.getIn().getBody(String.class));
  
  Issue finalIssue = issueService.createIssue(getRepository(), issue);
  
  // copy the header of in message to the out message
  exchange.getOut().copyFrom(exchange.getIn());
  exchange.getOut().setBody(finalIssue);
}

代码示例来源:origin: org.apache.camel/camel-crypto

public void process(Exchange exchange) throws Exception {
  Signature service = initSignatureService(exchange);
  calculateSignature(exchange, service);
  byte[] signature = service.sign();
  Message in = exchange.getIn();
  clearMessageHeaders(in);
  Message out = exchange.getOut();
  out.copyFrom(in);
  out.setHeader(config.getSignatureHeaderName(), new Base64().encode(signature));
}

代码示例来源:origin: org.apache.camel/camel-github

public void process(Exchange exchange) throws Exception {
  Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class);
  Integer inResponseTo = exchange.getIn().getHeader(GitHubConstants.GITHUB_INRESPONSETO, Integer.class);
  String text = exchange.getIn().getBody(String.class);
  
  Comment response;
  if (inResponseTo != null && inResponseTo > 0) {
    response = pullRequestService.replyToComment(getRepository(), pullRequestNumber, inResponseTo, text);
  } else {
    // Otherwise, just comment on the pull request itself.
    response = issueService.createComment(getRepository(), pullRequestNumber, text);
  }
  
  // support InOut
  if (exchange.getPattern().isOutCapable()) {
    // copy the header of in message to the out message
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(response);
  }
}

代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-core

/**
 * Creates the exchange for the next processor returned by
 * {@link #getProcessor()} from a source exchange.
 * 
 * @param source
 *            a source exchange.
 * @return exchange for the next processor.
 */
protected Exchange createDelegateExchange(Exchange source) {
  DefaultExchange result = new DefaultExchange(source.getContext());
  result.getIn().copyFrom(source.getIn());
  return result;
}

代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-core

/**
 * Returns the message where to write results. This method copies the
 * in-message to the out-message if the exchange is out-capable.
 * 
 * @param exchange message exchange.
 * @return result message.
 */
public static Message prepareResult(Exchange exchange) {
  Message result = resultMessage(exchange);
  if (exchange.getPattern().isOutCapable()) {
    result.copyFrom(exchange.getIn());
  }
  return result;
}

代码示例来源:origin: org.apache.camel/camel-github

public void process(Exchange exchange) throws Exception {
  String pullRequestNumberSHA = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST_HEAD_COMMIT_SHA, String.class);
  String text = exchange.getIn().getBody(String.class);
  CommitStatus status = new CommitStatus();
  if (state != null) {
    status.setState(state);
  }
  if (targetUrl != null) {
    status.setTargetUrl(targetUrl);
  }
  if (text != null) {
    status.setDescription(text);
  }
  CommitStatus response = commitService.createStatus(getRepository(), pullRequestNumberSHA, status);
  // copy the header of in message to the out message
  exchange.getOut().copyFrom(exchange.getIn());
  exchange.getOut().setBody(response);
}

代码示例来源:origin: org.apache.camel/camel-github

public void process(Exchange exchange) throws Exception {
  Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class);
  PullRequest pullRequest = pullRequestService.getPullRequest(getRepository(), pullRequestNumber);
  pullRequest.setState("closed");
  pullRequest.setClosedAt(Calendar.getInstance().getTime());
  pullRequest = pullRequestService.editPullRequest(getRepository(), pullRequest);
  
  // support InOut
  if (exchange.getPattern().isOutCapable()) {
    // copy the header of in message to the out message
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(pullRequest);
  }
}

代码示例来源:origin: stackoverflow.com

public static final int MESSAGE_CHECK_BTN_STILL_PRESSED = 1;

public final Handler myGuiHandler = new Handler() {
  @Override
  public void handleMessage(Message msg) {
    switch (msg.what) { 
    case MESSAGE_CHECK_BTN_STILL_PRESSED: 
      Button btn = (Button) findViewById(msg.arg1);
      if (btn.getTag() != null) { // button is still pressed
        Log.i("myBtn", "still pressed");
        btn.performClick(); // perform Click or different long press action
        Message msg1 = new Message(); // schedule next btn pressed check
        msg1.copyFrom(msg);
        myGuiHandler.sendMessageDelayed(msg1, msg1.arg2);
      }
      break;
    } 
  }
};

代码示例来源:origin: org.apache.camel/camel-twitter

@Override
public void process(Exchange exchange) throws Exception {
  // update user's status
  Object in = exchange.getIn().getBody();
  Status response;
  if (in instanceof StatusUpdate) {
    response = updateStatus((StatusUpdate) in);
  } else {
    String s = exchange.getIn().getMandatoryBody(String.class);
    response = updateStatus(s);
  }
  /*
   * Support the InOut exchange pattern in order to provide access to
   * the unique identifier for the published tweet which is returned in the response
   * by the Twitter REST API: https://dev.twitter.com/docs/api/1/post/statuses/update
   */
  if (exchange.getPattern().isOutCapable()) {
    // here we just copy the header of in message to the out message
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(response);
  }
}

代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-core

/**
 * Copies the <code>source</code> exchange to <code>target</code> exchange
 * preserving the {@link ExchangePattern} of <code>target</code>.  
 * 
 * @param source source exchange.
 * @param target target exchange.
 * 
 * @see #resultMessage(Exchange)
 */
public static void copyExchange(Exchange source, Exchange target) {
  if (source == target) {
    // no need to copy
    return;
  }
  
  // copy in message
  target.getIn().copyFrom(source.getIn());

  // copy out message
  if (source.hasOut()) {
    resultMessage(target).copyFrom(source.getOut());
  }
  
  // copy exception
  target.setException(source.getException());
  // copy properties
  target.getProperties().putAll(source.getProperties());
  
}

代码示例来源:origin: org.apache.camel/camel-pubnub

private void processMessage(Exchange exchange, AsyncCallback callback, PNStatus status, Object body) {
  if (status.isError()) {
    PNErrorData errorData = status.getErrorData();
    exchange.setException(errorData.getThrowable());
    if (errorData != null && errorData.getThrowable() instanceof PubNubException) {
      PubNubException pubNubException = (PubNubException) errorData.getThrowable();
      throw new RuntimeException(pubNubException.getPubnubError().getMessage(), errorData.getThrowable());
    }
    throw new RuntimeException(status.getErrorData().getThrowable());
  }
  if (exchange.getPattern().isOutCapable()) {
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(body);
  } else {
    exchange.getIn().setBody(body);
  }
  // signal exchange completion
  callback.done(false);
}

相关文章