本文整理汇总了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());
}
}
示例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());
}
}
}
示例3: getExchangePattern
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Override
public ExchangePattern getExchangePattern() {
return ExchangePattern.InOptionalOut;
}