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

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

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

Message.copyFrom介绍

暂无

代码示例

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

  1. if (storeMessage(msg)) {
  2. Message msgCopy = new Message();
  3. msgCopy.copyFrom(msg);
  4. messageQueueBuffer.add(msgCopy);

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

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

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

  1. @Override
  2. public void successCallback(String channel, Object message) {
  3. LOG.trace("PubNub response {}", message);
  4. exchange.getIn().setHeader(PubNubConstants.CHANNEL, channel);
  5. if (exchange.getPattern().isOutCapable()) {
  6. exchange.getOut().copyFrom(exchange.getIn());
  7. exchange.getOut().setBody(message);
  8. }
  9. callback.done(false);
  10. }

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

  1. private Message getMessageForResponse(Exchange exchange) {
  2. if (exchange.getPattern().isOutCapable()) {
  3. Message out = exchange.getOut();
  4. out.copyFrom(exchange.getIn());
  5. return out;
  6. }
  7. return exchange.getIn();
  8. }

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

  1. private Message getMessageForResponse(final Exchange exchange) {
  2. if (exchange.getPattern().isOutCapable()) {
  3. Message out = exchange.getOut();
  4. out.copyFrom(exchange.getIn());
  5. return out;
  6. }
  7. return exchange.getIn();
  8. }

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

  1. public static Message getMessageForResponse(final Exchange exchange) {
  2. if (exchange.getPattern().isOutCapable()) {
  3. Message out = exchange.getOut();
  4. out.copyFrom(exchange.getIn());
  5. return out;
  6. }
  7. return exchange.getIn();
  8. }
  9. }

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

  1. public static Message getMessageForResponse(final Exchange exchange) {
  2. if (exchange.getPattern().isOutCapable()) {
  3. Message out = exchange.getOut();
  4. out.copyFrom(exchange.getIn());
  5. return out;
  6. }
  7. return exchange.getIn();
  8. }
  9. }

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

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

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

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

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

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

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

  1. public void process(Exchange exchange) throws Exception {
  2. Signature service = initSignatureService(exchange);
  3. calculateSignature(exchange, service);
  4. byte[] signature = service.sign();
  5. Message in = exchange.getIn();
  6. clearMessageHeaders(in);
  7. Message out = exchange.getOut();
  8. out.copyFrom(in);
  9. out.setHeader(config.getSignatureHeaderName(), new Base64().encode(signature));
  10. }

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

  1. public void process(Exchange exchange) throws Exception {
  2. Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class);
  3. Integer inResponseTo = exchange.getIn().getHeader(GitHubConstants.GITHUB_INRESPONSETO, Integer.class);
  4. String text = exchange.getIn().getBody(String.class);
  5. Comment response;
  6. if (inResponseTo != null && inResponseTo > 0) {
  7. response = pullRequestService.replyToComment(getRepository(), pullRequestNumber, inResponseTo, text);
  8. } else {
  9. // Otherwise, just comment on the pull request itself.
  10. response = issueService.createComment(getRepository(), pullRequestNumber, text);
  11. }
  12. // support InOut
  13. if (exchange.getPattern().isOutCapable()) {
  14. // copy the header of in message to the out message
  15. exchange.getOut().copyFrom(exchange.getIn());
  16. exchange.getOut().setBody(response);
  17. }
  18. }

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

  1. /**
  2. * Creates the exchange for the next processor returned by
  3. * {@link #getProcessor()} from a source exchange.
  4. *
  5. * @param source
  6. * a source exchange.
  7. * @return exchange for the next processor.
  8. */
  9. protected Exchange createDelegateExchange(Exchange source) {
  10. DefaultExchange result = new DefaultExchange(source.getContext());
  11. result.getIn().copyFrom(source.getIn());
  12. return result;
  13. }

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

  1. /**
  2. * Returns the message where to write results. This method copies the
  3. * in-message to the out-message if the exchange is out-capable.
  4. *
  5. * @param exchange message exchange.
  6. * @return result message.
  7. */
  8. public static Message prepareResult(Exchange exchange) {
  9. Message result = resultMessage(exchange);
  10. if (exchange.getPattern().isOutCapable()) {
  11. result.copyFrom(exchange.getIn());
  12. }
  13. return result;
  14. }

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

  1. public void process(Exchange exchange) throws Exception {
  2. String pullRequestNumberSHA = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST_HEAD_COMMIT_SHA, String.class);
  3. String text = exchange.getIn().getBody(String.class);
  4. CommitStatus status = new CommitStatus();
  5. if (state != null) {
  6. status.setState(state);
  7. }
  8. if (targetUrl != null) {
  9. status.setTargetUrl(targetUrl);
  10. }
  11. if (text != null) {
  12. status.setDescription(text);
  13. }
  14. CommitStatus response = commitService.createStatus(getRepository(), pullRequestNumberSHA, status);
  15. // copy the header of in message to the out message
  16. exchange.getOut().copyFrom(exchange.getIn());
  17. exchange.getOut().setBody(response);
  18. }

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

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

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

  1. public static final int MESSAGE_CHECK_BTN_STILL_PRESSED = 1;
  2. public final Handler myGuiHandler = new Handler() {
  3. @Override
  4. public void handleMessage(Message msg) {
  5. switch (msg.what) {
  6. case MESSAGE_CHECK_BTN_STILL_PRESSED:
  7. Button btn = (Button) findViewById(msg.arg1);
  8. if (btn.getTag() != null) { // button is still pressed
  9. Log.i("myBtn", "still pressed");
  10. btn.performClick(); // perform Click or different long press action
  11. Message msg1 = new Message(); // schedule next btn pressed check
  12. msg1.copyFrom(msg);
  13. myGuiHandler.sendMessageDelayed(msg1, msg1.arg2);
  14. }
  15. break;
  16. }
  17. }
  18. };

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

  1. @Override
  2. public void process(Exchange exchange) throws Exception {
  3. // update user's status
  4. Object in = exchange.getIn().getBody();
  5. Status response;
  6. if (in instanceof StatusUpdate) {
  7. response = updateStatus((StatusUpdate) in);
  8. } else {
  9. String s = exchange.getIn().getMandatoryBody(String.class);
  10. response = updateStatus(s);
  11. }
  12. /*
  13. * Support the InOut exchange pattern in order to provide access to
  14. * the unique identifier for the published tweet which is returned in the response
  15. * by the Twitter REST API: https://dev.twitter.com/docs/api/1/post/statuses/update
  16. */
  17. if (exchange.getPattern().isOutCapable()) {
  18. // here we just copy the header of in message to the out message
  19. exchange.getOut().copyFrom(exchange.getIn());
  20. exchange.getOut().setBody(response);
  21. }
  22. }

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

  1. /**
  2. * Copies the <code>source</code> exchange to <code>target</code> exchange
  3. * preserving the {@link ExchangePattern} of <code>target</code>.
  4. *
  5. * @param source source exchange.
  6. * @param target target exchange.
  7. *
  8. * @see #resultMessage(Exchange)
  9. */
  10. public static void copyExchange(Exchange source, Exchange target) {
  11. if (source == target) {
  12. // no need to copy
  13. return;
  14. }
  15. // copy in message
  16. target.getIn().copyFrom(source.getIn());
  17. // copy out message
  18. if (source.hasOut()) {
  19. resultMessage(target).copyFrom(source.getOut());
  20. }
  21. // copy exception
  22. target.setException(source.getException());
  23. // copy properties
  24. target.getProperties().putAll(source.getProperties());
  25. }

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

  1. private void processMessage(Exchange exchange, AsyncCallback callback, PNStatus status, Object body) {
  2. if (status.isError()) {
  3. PNErrorData errorData = status.getErrorData();
  4. exchange.setException(errorData.getThrowable());
  5. if (errorData != null && errorData.getThrowable() instanceof PubNubException) {
  6. PubNubException pubNubException = (PubNubException) errorData.getThrowable();
  7. throw new RuntimeException(pubNubException.getPubnubError().getMessage(), errorData.getThrowable());
  8. }
  9. throw new RuntimeException(status.getErrorData().getThrowable());
  10. }
  11. if (exchange.getPattern().isOutCapable()) {
  12. exchange.getOut().copyFrom(exchange.getIn());
  13. exchange.getOut().setBody(body);
  14. } else {
  15. exchange.getIn().setBody(body);
  16. }
  17. // signal exchange completion
  18. callback.done(false);
  19. }

相关文章