当前位置: 首页>>代码示例>>Java>>正文


Java ExchangeHelper.createCopy方法代码示例

本文整理汇总了Java中org.apache.camel.util.ExchangeHelper.createCopy方法的典型用法代码示例。如果您正苦于以下问题:Java ExchangeHelper.createCopy方法的具体用法?Java ExchangeHelper.createCopy怎么用?Java ExchangeHelper.createCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.ExchangeHelper的用法示例。


在下文中一共展示了ExchangeHelper.createCopy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matches

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
@Override
public boolean matches(Exchange exchange) {
    Object msgBody = exchange.getIn().getBody();

    // TODO: Maybe check for content-type, too ?
    // String contentType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class);
    // if ("application/json".equals(contentType)) { ... }
    // ???
    if (!(msgBody instanceof String)) {
        return language.createPredicate(expression).matches(exchange);
    }

    Exchange exchangeToCheck = exchange;
    // If it is a json document , suppose that this is a document which needs to be parsed as JSON
    // Therefor we set a map instead of the string
    Map jsonDocument = jsonStringAsMap((String) msgBody, exchange);
    if (jsonDocument != null) {
        // Clone the exchange and set the JSON message converted to a Map / List as in message.
        // The intention is that only this predicate acts on the converted value,
        // but the original in-message still continues to carry the same format
        // The predicated is supposed to be read only with respect to the incoming messaeg.
        exchangeToCheck = ExchangeHelper.createCopy(exchange, true);
        exchangeToCheck.getIn().setBody(jsonDocument);
    }
    return language.createPredicate(convertSimpleToOGNLForMaps(expression)).matches(exchangeToCheck);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:27,代码来源:JsonSimplePredicate.java

示例2: onExchange

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
protected synchronized void onExchange(Exchange exchange) {
    try {
        if (reporter != null) {
            reporter.process(exchange);
        }
        Exchange copy = exchange;
        if (copyOnExchange) {
            // copy the exchange so the mock stores the copy and not the actual exchange
            copy = ExchangeHelper.createCopy(exchange, true);
        }
        performAssertions(exchange, copy);
    } catch (Throwable e) {
        // must catch java.lang.Throwable as AssertionError extends java.lang.Error
        failures.add(e);
    } finally {
        // make sure latch is counted down to avoid test hanging forever
        if (latch != null) {
            latch.countDown();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:MockEndpoint.java

示例3: prepareExchange

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
/**
 * Prepares the exchange for the next iteration
 *
 * @param exchange the exchange
 * @param index the index of the next iteration
 * @return the exchange to use
 */
protected Exchange prepareExchange(Exchange exchange, int index, Exchange original) {
    if (copy) {
        // use a copy but let it reuse the same exchange id so it appear as one exchange
        // use the original exchange rather than the looping exchange (esp. with the async routing engine)
        return ExchangeHelper.createCopy(original, true);
    } else {
        ExchangeHelper.prepareOutToIn(exchange);
        return exchange;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:LoopProcessor.java

示例4: copyExchangeNoAttachments

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
private static Exchange copyExchangeNoAttachments(Exchange exchange, boolean preserveExchangeId) {
    Exchange answer = ExchangeHelper.createCopy(exchange, preserveExchangeId);
    // we do not want attachments for the splitted sub-messages
    answer.getIn().setAttachments(null);
    // we do not want to copy the message history for splitted sub-messages
    answer.getProperties().remove(Exchange.MESSAGE_HISTORY);
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:Splitter.java

示例5: defensiveCopyExchangeIfNeeded

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
/**
 * Performs a defensive copy of the exchange if needed
 *
 * @param exchange the exchange
 * @return the defensive copy, or <tt>null</tt> if not needed (redelivery is not enabled).
 */
protected Exchange defensiveCopyExchangeIfNeeded(Exchange exchange) {
    // only do a defensive copy if redelivery is enabled
    if (redeliveryEnabled) {
        return ExchangeHelper.createCopy(exchange, true);
    } else {
        return null;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:RedeliveryErrorHandler.java

示例6: run

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
@Override
public void run() {
    String task = null;
    Object result = null;

    try {
        // create dummy exchange
        Exchange dummy = ExchangeHelper.createCopy(exchange, true);

        task = dummy.getIn().getMandatoryBody(String.class);
        if (task != null) {
            Expression exp = language.createExpression(task);
            result = exp.evaluate(dummy, Object.class);
        }

        if (result != null && !getEndpoint().isAsync()) {
            // can only set result on exchange if sync
            exchange.getIn().setBody(result);
        }

        if (task != null) {
            logger.log("ControlBus task done [" + task + "] with result -> " + (result != null ? result : "void"));
        }
    } catch (Exception e) {
        logger.log("Error executing ControlBus task [" + task + "]. This exception will be ignored.", e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:ControlBusProducer.java

示例7: prepareExchangeForFailover

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
/**
 * Prepares the exchange for failover
 *
 * @param exchange the exchange
 * @return a copy of the exchange to use for failover
 */
protected Exchange prepareExchangeForFailover(Exchange exchange) {
    // use a copy of the exchange to avoid side effects on the original exchange
    return ExchangeHelper.createCopy(exchange, true);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:FailOverLoadBalancer.java


注:本文中的org.apache.camel.util.ExchangeHelper.createCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。