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


Java ExchangePattern.InOptionalOut方法代码示例

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


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

示例1: copyResultsPreservePattern

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
/**
 * Copies the <code>source</code> exchange to <code>target</code> exchange
 * preserving the {@link ExchangePattern} of <code>target</code>.
 *
 * @param source source exchange.
 * @param result target exchange.
 */
public static void copyResultsPreservePattern(Exchange result, Exchange source) {

    // --------------------------------------------------------------------
    //  TODO: merge logic with that of copyResults()
    // --------------------------------------------------------------------

    if (result == source) {
        // we just need to ensure MEP is as expected (eg copy result to OUT if out capable)
        // and the result is not failed
        if (result.getPattern() == ExchangePattern.InOptionalOut) {
            // keep as is
        } else if (result.getPattern().isOutCapable() && !result.hasOut() && !result.isFailed()) {
            // copy IN to OUT as we expect a OUT response
            result.getOut().copyFrom(source.getIn());
        }
        return;
    }

    // copy in message
    result.getIn().copyFrom(source.getIn());

    // copy out message
    if (source.hasOut()) {
        // exchange pattern sensitive
        Message resultMessage = source.getOut().isFault() ? result.getOut() : getResultMessage(result);
        resultMessage.copyFrom(source.getOut());
    }

    // copy exception
    result.setException(source.getException());

    // copy properties
    if (source.hasProperties()) {
        result.getProperties().putAll(source.getProperties());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:44,代码来源:ExchangeHelper.java

示例2: copyResults

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
/**
 * Copies the results of a message exchange from the source exchange to the result exchange
 * which will copy the message contents, exchange properties and the exception.
 * Notice the {@link ExchangePattern} is <b>not</b> copied/altered.
 *
 * @param result the result exchange which will have the output and error state added
 * @param source the source exchange which is not modified
 */
public static void copyResults(Exchange result, Exchange source) {

    // --------------------------------------------------------------------
    //  TODO: merge logic with that of copyResultsPreservePattern()
    // --------------------------------------------------------------------

    if (result == source) {
        // we just need to ensure MEP is as expected (eg copy result to OUT if out capable)
        // and the result is not failed
        if (result.getPattern() == ExchangePattern.InOptionalOut) {
            // keep as is
        } else if (result.getPattern().isOutCapable() && !result.hasOut() && !result.isFailed()) {
            // copy IN to OUT as we expect a OUT response
            result.getOut().copyFrom(source.getIn());
        }
        return;
    }

    if (result != source) {
        result.setException(source.getException());
        if (source.hasOut()) {
            result.getOut().copyFrom(source.getOut());
        } else if (result.getPattern() == ExchangePattern.InOptionalOut) {
            // special case where the result is InOptionalOut and with no OUT response
            // so we should return null to indicate this fact
            result.setOut(null);
        } else {
            // no results so lets copy the last input
            // as the final processor on a pipeline might not
            // have created any OUT; such as a mock:endpoint
            // so lets assume the last IN is the OUT
            if (result.getPattern().isOutCapable()) {
                // only set OUT if its OUT capable
                result.getOut().copyFrom(source.getIn());
            } else {
                // if not replace IN instead to keep the MEP
                result.getIn().copyFrom(source.getIn());
                // clear any existing OUT as the result is on the IN
                if (result.hasOut()) {
                    result.setOut(null);
                }
            }
        }

        if (source.hasProperties()) {
            result.getProperties().putAll(source.getProperties());
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:58,代码来源:ExchangeHelper.java

示例3: getExchangePattern

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Override
public ExchangePattern getExchangePattern() {
    return ExchangePattern.InOptionalOut;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:TwitterEndpointDirect.java


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