本文整理汇总了Java中org.apache.camel.spi.RouteContext.getCamelContext方法的典型用法代码示例。如果您正苦于以下问题:Java RouteContext.getCamelContext方法的具体用法?Java RouteContext.getCamelContext怎么用?Java RouteContext.getCamelContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.spi.RouteContext
的用法示例。
在下文中一共展示了RouteContext.getCamelContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFlowBeginProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
private static FlowBeginProcessor createFlowBeginProcessor(RouteContext routeContext) {
CamelContext camelContext = routeContext.getCamelContext();
// Try to obtain a FlowBeginProcessor bean (its definition is optional)
FlowBeginProcessor processor = ContextUtils.beanOrNull(FlowBeginProcessor.class, camelContext);
if (processor != null) {
return processor;
}
// No FlowBeginProcessor bean found so let's create one. We need a
// - reference to a ReplayStrategyRegistry
// - reference to a FlowManager
processor = new FlowBeginProcessor();
processor.setCamelContext(camelContext);
processor.setFlowManager(ContextUtils.bean(FlowManager.class, camelContext));
processor.setRegistry(ContextUtils.bean(ReplayStrategyRegistry.class, camelContext));
return processor;
}
示例2: createCompositeProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
protected Processor createCompositeProcessor(RouteContext routeContext, List<Processor> list) throws Exception {
final AggregationStrategy strategy = createAggregationStrategy(routeContext);
boolean isParallelProcessing = getParallelProcessing() != null && getParallelProcessing();
boolean isShareUnitOfWork = getShareUnitOfWork() != null && getShareUnitOfWork();
boolean isStreaming = getStreaming() != null && getStreaming();
boolean isStopOnException = getStopOnException() != null && getStopOnException();
boolean isParallelAggregate = getParallelAggregate() != null && getParallelAggregate();
boolean shutdownThreadPool = ProcessorDefinitionHelper.willCreateNewThreadPool(routeContext, this, isParallelProcessing);
ExecutorService threadPool = ProcessorDefinitionHelper.getConfiguredExecutorService(routeContext, "Multicast", this, isParallelProcessing);
long timeout = getTimeout() != null ? getTimeout() : 0;
if (timeout > 0 && !isParallelProcessing) {
throw new IllegalArgumentException("Timeout is used but ParallelProcessing has not been enabled.");
}
if (onPrepareRef != null) {
onPrepare = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), onPrepareRef, Processor.class);
}
MulticastProcessor answer = new MulticastProcessor(routeContext.getCamelContext(), list, strategy, isParallelProcessing,
threadPool, shutdownThreadPool, isStreaming, isStopOnException, timeout, onPrepare, isShareUnitOfWork, isParallelAggregate);
return answer;
}
示例3: createProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
Processor childProcessor = this.createChildProcessor(routeContext, false);
Expression delay = createAbsoluteTimeDelayExpression(routeContext);
boolean async = getAsyncDelayed() != null && getAsyncDelayed();
boolean shutdownThreadPool = ProcessorDefinitionHelper.willCreateNewThreadPool(routeContext, this, async);
ScheduledExecutorService threadPool = ProcessorDefinitionHelper.getConfiguredScheduledExecutorService(routeContext, "Delay", this, async);
Delayer answer = new Delayer(routeContext.getCamelContext(), childProcessor, delay, threadPool, shutdownThreadPool);
if (getAsyncDelayed() != null) {
answer.setAsyncDelayed(getAsyncDelayed());
}
if (getCallerRunsWhenRejected() == null) {
// should be default true
answer.setCallerRunsWhenRejected(true);
} else {
answer.setCallerRunsWhenRejected(getCallerRunsWhenRejected());
}
return answer;
}
示例4: createErrorHandler
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
public Processor createErrorHandler(final RouteContext routeContext, final Processor processor) {
CamelLogger logger = new CamelLogger(log, level);
// configure policy to use the selected logging level, and only log exhausted
RedeliveryPolicy policy = new RedeliveryPolicy();
policy.setLogExhausted(true);
policy.setRetriesExhaustedLogLevel(level);
policy.setLogStackTrace(true);
policy.setLogRetryAttempted(false);
policy.setRetryAttemptedLogLevel(LoggingLevel.OFF);
policy.setLogRetryStackTrace(false);
policy.setLogContinued(false);
policy.setLogHandled(false);
LoggingErrorHandler handler = new LoggingErrorHandler(routeContext.getCamelContext(), processor, logger,
policy, getExceptionPolicyStrategy());
configure(routeContext, handler);
return handler;
}
示例5: createFlowEndProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
private static FlowEndProcessor createFlowEndProcessor(RouteContext routeContext) {
CamelContext camelContext = routeContext.getCamelContext();
FlowEndProcessor processor = beanOrNull(FlowEndProcessor.class, camelContext);
if (processor != null) {
return processor;
}
processor = new FlowEndProcessor();
processor.setCamelContext(camelContext);
processor.setFlowManager(ContextUtils.bean(FlowManager.class, camelContext));
return processor;
}
示例6: createDedupe
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
private static Dedupe createDedupe(RouteContext routeContext) {
CamelContext camelContext = routeContext.getCamelContext();
Dedupe dedupe = beanOrNull(Dedupe.class, camelContext);
if (dedupe != null) {
return dedupe;
}
dedupe = new Dedupe();
dedupe.setFlowManager(ContextUtils.bean(FlowManager.class, camelContext));
return dedupe;
}
示例7: createFlowErrorProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
private static FlowErrorProcessor createFlowErrorProcessor(RouteContext routeContext) {
CamelContext camelContext = routeContext.getCamelContext();
FlowErrorProcessor processor = beanOrNull(FlowErrorProcessor.class, camelContext);
if (processor != null) {
return processor;
}
processor = new FlowErrorProcessor();
processor.setCamelContext(camelContext);
processor.setFlowManager(ContextUtils.bean(FlowManager.class, camelContext));
return processor;
}
示例8: createProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
Processor childProcessor = this.createChildProcessor(routeContext, true);
boolean async = getAsyncDelayed() != null && getAsyncDelayed();
boolean shutdownThreadPool = ProcessorDefinitionHelper.willCreateNewThreadPool(routeContext, this, async);
ScheduledExecutorService threadPool = ProcessorDefinitionHelper.getConfiguredScheduledExecutorService(routeContext, "Throttle", this, async);
// should be default 1000 millis
long period = getTimePeriodMillis() != null ? getTimePeriodMillis() : 1000L;
// max requests per period is mandatory
Expression maxRequestsExpression = createMaxRequestsPerPeriodExpression(routeContext);
if (maxRequestsExpression == null) {
throw new IllegalArgumentException("MaxRequestsPerPeriod expression must be provided on " + this);
}
boolean reject = getRejectExecution() != null && getRejectExecution();
Throttler answer = new Throttler(routeContext.getCamelContext(), childProcessor, maxRequestsExpression, period, threadPool, shutdownThreadPool, reject);
answer.setAsyncDelayed(async);
if (getCallerRunsWhenRejected() == null) {
// should be true by default
answer.setCallerRunsWhenRejected(true);
} else {
answer.setCallerRunsWhenRejected(getCallerRunsWhenRejected());
}
return answer;
}
示例9: createProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
Processor childProcessor = this.createChildProcessor(routeContext, true);
aggregationStrategy = createAggregationStrategy(routeContext);
boolean isParallelProcessing = getParallelProcessing() != null && getParallelProcessing();
boolean isStreaming = getStreaming() != null && getStreaming();
boolean isShareUnitOfWork = getShareUnitOfWork() != null && getShareUnitOfWork();
boolean isParallelAggregate = getParallelAggregate() != null && getParallelAggregate();
boolean shutdownThreadPool = ProcessorDefinitionHelper.willCreateNewThreadPool(routeContext, this, isParallelProcessing);
ExecutorService threadPool = ProcessorDefinitionHelper.getConfiguredExecutorService(routeContext, "Split", this, isParallelProcessing);
long timeout = getTimeout() != null ? getTimeout() : 0;
if (timeout > 0 && !isParallelProcessing) {
throw new IllegalArgumentException("Timeout is used but ParallelProcessing has not been enabled.");
}
if (onPrepareRef != null) {
onPrepare = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), onPrepareRef, Processor.class);
}
Expression exp = getExpression().createExpression(routeContext);
Splitter answer = new Splitter(routeContext.getCamelContext(), exp, childProcessor, aggregationStrategy,
isParallelProcessing, threadPool, shutdownThreadPool, isStreaming, isStopOnException(),
timeout, onPrepare, isShareUnitOfWork, isParallelAggregate);
return answer;
}
示例10: createProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
Expression expression = getExpression().createExpression(routeContext);
String delimiter = getUriDelimiter() != null ? getUriDelimiter() : DEFAULT_DELIMITER;
DynamicRouter dynamicRouter = new DynamicRouter(routeContext.getCamelContext(), expression, delimiter);
if (getIgnoreInvalidEndpoints() != null) {
dynamicRouter.setIgnoreInvalidEndpoints(getIgnoreInvalidEndpoints());
}
if (getCacheSize() != null) {
dynamicRouter.setCacheSize(getCacheSize());
}
return dynamicRouter;
}
示例11: createBatchResequencer
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
/**
* Creates a batch {@link Resequencer} instance applying the given <code>config</code>.
*
* @param routeContext route context.
* @param config batch resequencer configuration.
* @return the configured batch resequencer.
* @throws Exception can be thrown
*/
@SuppressWarnings("deprecation")
protected Resequencer createBatchResequencer(RouteContext routeContext,
BatchResequencerConfig config) throws Exception {
Processor processor = this.createChildProcessor(routeContext, true);
Expression expression = getExpression().createExpression(routeContext);
// and wrap in unit of work
CamelInternalProcessor internal = new CamelInternalProcessor(processor);
internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(routeContext));
ObjectHelper.notNull(config, "config", this);
ObjectHelper.notNull(expression, "expression", this);
boolean isReverse = config.getReverse() != null && config.getReverse();
boolean isAllowDuplicates = config.getAllowDuplicates() != null && config.getAllowDuplicates();
Resequencer resequencer = new Resequencer(routeContext.getCamelContext(), internal, expression, isAllowDuplicates, isReverse);
resequencer.setBatchSize(config.getBatchSize());
resequencer.setBatchTimeout(config.getBatchTimeout());
resequencer.setReverse(isReverse);
resequencer.setAllowDuplicates(isAllowDuplicates);
if (config.getIgnoreInvalidExchanges() != null) {
resequencer.setIgnoreInvalidExchanges(config.getIgnoreInvalidExchanges());
}
return resequencer;
}
示例12: createStreamResequencer
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
/**
* Creates a {@link StreamResequencer} instance applying the given <code>config</code>.
*
* @param routeContext route context.
* @param config stream resequencer configuration.
* @return the configured stream resequencer.
* @throws Exception can be thrwon
*/
protected StreamResequencer createStreamResequencer(RouteContext routeContext,
StreamResequencerConfig config) throws Exception {
Processor processor = this.createChildProcessor(routeContext, true);
Expression expression = getExpression().createExpression(routeContext);
CamelInternalProcessor internal = new CamelInternalProcessor(processor);
internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(routeContext));
ObjectHelper.notNull(config, "config", this);
ObjectHelper.notNull(expression, "expression", this);
ExpressionResultComparator comparator;
if (config.getComparatorRef() != null) {
comparator = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), config.getComparatorRef(), ExpressionResultComparator.class);
} else {
comparator = config.getComparator();
}
comparator.setExpression(expression);
StreamResequencer resequencer = new StreamResequencer(routeContext.getCamelContext(), internal, comparator, expression);
resequencer.setTimeout(config.getTimeout());
resequencer.setCapacity(config.getCapacity());
resequencer.setRejectOld(config.getRejectOld());
if (config.getIgnoreInvalidExchanges() != null) {
resequencer.setIgnoreInvalidExchanges(config.getIgnoreInvalidExchanges());
}
return resequencer;
}
示例13: createProcessor
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
Expression expression = getExpression().createExpression(routeContext);
String delimiter = getUriDelimiter() != null ? getUriDelimiter() : DEFAULT_DELIMITER;
RoutingSlip routingSlip = new RoutingSlip(routeContext.getCamelContext(), expression, delimiter);
if (getIgnoreInvalidEndpoints() != null) {
routingSlip.setIgnoreInvalidEndpoints(getIgnoreInvalidEndpoints());
}
if (getCacheSize() != null) {
routingSlip.setCacheSize(getCacheSize());
}
return routingSlip;
}
示例14: createErrorHandler
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
public Processor createErrorHandler(RouteContext routeContext, Processor processor) throws Exception {
DefaultErrorHandler answer = new DefaultErrorHandler(routeContext.getCamelContext(), processor, getLogger(), getOnRedelivery(),
getRedeliveryPolicy(), getExceptionPolicyStrategy(), getRetryWhilePolicy(routeContext.getCamelContext()),
getExecutorService(routeContext.getCamelContext()), getOnPrepareFailure(), getOnExceptionOccurred());
// configure error handler before we can use it
configure(routeContext, answer);
return answer;
}
示例15: createErrorHandler
import org.apache.camel.spi.RouteContext; //导入方法依赖的package包/类
public Processor createErrorHandler(RouteContext routeContext, Processor processor) throws Exception {
validateDeadLetterUri(routeContext);
DeadLetterChannel answer = new DeadLetterChannel(routeContext.getCamelContext(), processor, getLogger(), getOnRedelivery(),
getRedeliveryPolicy(), getExceptionPolicyStrategy(), getFailureProcessor(), getDeadLetterUri(), isDeadLetterHandleNewException(),
isUseOriginalMessage(), getRetryWhilePolicy(routeContext.getCamelContext()), getExecutorService(routeContext.getCamelContext()),
getOnPrepareFailure(), getOnExceptionOccurred());
// configure error handler before we can use it
configure(routeContext, answer);
return answer;
}