• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RouteContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.camel.spi.RouteContext的典型用法代码示例。如果您正苦于以下问题:Java RouteContext类的具体用法?Java RouteContext怎么用?Java RouteContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RouteContext类属于org.apache.camel.spi包,在下文中一共展示了RouteContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:20,代码来源:FlowBeginProcessorDefinition.java


示例2: createProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Processor createProcessor(RouteContext routeContext) throws Exception {
    // lookup in registry
    if (ObjectHelper.isNotEmpty(comparatorRef)) {
        comparator = routeContext.getCamelContext().getRegistry().lookupByNameAndType(comparatorRef, Comparator.class);
    }

    // if no comparator then default on to string representation
    if (comparator == null) {
        comparator = new Comparator<T>() {
            public int compare(T o1, T o2) {
                return ObjectHelper.compare(o1, o2);
            }
        };
    }

    // if no expression provided then default to body expression
    Expression exp;
    if (getExpression() == null) {
        exp = bodyExpression();
    } else {
        exp = getExpression().createExpression(routeContext);
    }
    return new SortProcessor<T>(exp, getComparator());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:SortDefinition.java


示例3: createProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
    ObjectHelper.notEmpty(uri, "uri", this);

    Expression exp = createExpression(routeContext);

    SendDynamicProcessor processor = new SendDynamicProcessor(uri, exp);
    processor.setCamelContext(routeContext.getCamelContext());
    processor.setPattern(pattern);
    if (cacheSize != null) {
        processor.setCacheSize(cacheSize);
    }
    if (ignoreInvalidEndpoint != null) {
        processor.setIgnoreInvalidEndpoint(ignoreInvalidEndpoint);
    }
    return processor;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:ToDynamicDefinition.java


示例4: configureServerListStrategy

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
protected ServiceCallServerListStrategy configureServerListStrategy(C conf, RouteContext routeContext, ServiceCallConfigurationDefinition config)  throws Exception {
    ServiceCallServerListStrategy sl = config.getServerListStrategy();
    String ref = config.getServerListStrategyRef();
    if (sl == null && ref != null) {
        sl = builtInServerListStrategy(
                conf,
                ref)
            .orElseGet(() -> CamelContextHelper.mandatoryLookup(
                routeContext.getCamelContext(),
                ref,
                ServiceCallServerListStrategy.class)
        );
    }

    return sl;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:DefaultServiceCallProcessorFactory.java


示例5: createDataFormat

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
protected DataFormat createDataFormat(RouteContext routeContext) {
    if (classType == null && clazz == null) {
        throw new IllegalArgumentException("Either packages or classType must be specified");
    }

    if (type == BindyType.Csv) {
        setDataFormatName("bindy-csv");
    } else if (type == BindyType.Fixed) {
        setDataFormatName("bindy-fixed");
    } else {
        setDataFormatName("bindy-kvp");
    }

    if (clazz == null && classType != null) {
        try {
            clazz = routeContext.getCamelContext().getClassResolver().resolveMandatoryClass(classType);
        } catch (ClassNotFoundException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }
    return super.createDataFormat(routeContext);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:BindyDataFormat.java


示例6: createLoadBalancer

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
/**
 * Factory method to create the load balancer from the loadBalancerTypeName
 */
protected LoadBalancer createLoadBalancer(RouteContext routeContext) {
    ObjectHelper.notEmpty(loadBalancerTypeName, "loadBalancerTypeName", this);

    LoadBalancer answer = null;
    if (loadBalancerTypeName != null) {
        Class<?> type = routeContext.getCamelContext().getClassResolver().resolveClass(loadBalancerTypeName, LoadBalancer.class);
        if (type == null) {
            throw new IllegalArgumentException("Cannot find class: " + loadBalancerTypeName + " in the classpath");
        }
        answer = (LoadBalancer) routeContext.getCamelContext().getInjector().newInstance(type);
        configureLoadBalancer(answer);
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:LoadBalancerDefinition.java


示例7: 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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:MulticastDefinition.java


示例8: createProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {

    // if no timeout then we should block, and there use a negative timeout
    long time = timeout != null ? timeout : -1;
    boolean isIgnoreInvalidEndpoint = getIgnoreInvalidEndpoint() != null && getIgnoreInvalidEndpoint();
    Expression exp = getExpression().createExpression(routeContext);

    PollEnricher enricher = new PollEnricher(exp, time);

    AggregationStrategy strategy = createAggregationStrategy(routeContext);
    if (strategy == null) {
        enricher.setDefaultAggregationStrategy();
    } else {
        enricher.setAggregationStrategy(strategy);
    }
    if (getAggregateOnException() != null) {
        enricher.setAggregateOnException(getAggregateOnException());
    }
    if (getCacheSize() != null) {
        enricher.setCacheSize(getCacheSize());
    }
    enricher.setIgnoreInvalidEndpoint(isIgnoreInvalidEndpoint);

    return enricher;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:PollEnrichDefinition.java


示例9: configureLoadBalancer

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
protected ServiceCallLoadBalancer configureLoadBalancer(C conf, RouteContext routeContext, ServiceCallDefinition sd)  throws Exception {
    ServiceCallLoadBalancer lb = null;
    String ref;

    if (sd != null) {
        lb = sd.getLoadBalancer();
        ref = sd.getLoadBalancerRef();
        if (lb == null && ref != null) {
            lb = builtInLoadBalancer(
                    conf,
                    ref)
                .orElseGet(() -> CamelContextHelper.mandatoryLookup(
                    routeContext.getCamelContext(),
                    ref,
                    ServiceCallLoadBalancer.class)
            );
        }
    }

    return lb;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:DefaultServiceCallProcessorFactory.java


示例10: onErrorHandlerAdd

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
public void onErrorHandlerAdd(RouteContext routeContext, Processor errorHandler, ErrorHandlerFactory errorHandlerBuilder) {
    if (!shouldRegister(errorHandler, null)) {
        // avoid registering if not needed
        return;
    }

    Object me = getManagementObjectStrategy().getManagedObjectForErrorHandler(camelContext, routeContext, errorHandler, errorHandlerBuilder);

    // skip already managed services, for example if a route has been restarted
    if (getManagementStrategy().isManaged(me, null)) {
        LOG.trace("The error handler builder is already managed: {}", errorHandlerBuilder);
        return;
    }

    try {
        manageObject(me);
    } catch (Exception e) {
        LOG.warn("Could not register error handler builder: " + errorHandlerBuilder + " as ErrorHandler MBean.", e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:DefaultManagementLifecycleStrategy.java


示例11: getConfiguredExecutorService

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
/**
 * Will lookup and get the configured {@link java.util.concurrent.ExecutorService} from the given definition.
 * <p/>
 * This method will lookup for configured thread pool in the following order
 * <ul>
 * <li>from the definition if any explicit configured executor service.</li>
 * <li>from the {@link org.apache.camel.spi.Registry} if found</li>
 * <li>from the known list of {@link org.apache.camel.spi.ThreadPoolProfile ThreadPoolProfile(s)}.</li>
 * <li>if none found, then <tt>null</tt> is returned.</li>
 * </ul>
 * The various {@link ExecutorServiceAwareDefinition} should use this helper method to ensure they support
 * configured executor services in the same coherent way.
 *
 * @param routeContext the route context
 * @param name         name which is appended to the thread name, when the {@link java.util.concurrent.ExecutorService}
 *                     is created based on a {@link org.apache.camel.spi.ThreadPoolProfile}.
 * @param definition   the node definition which may leverage executor service.
 * @param useDefault   whether to fallback and use a default thread pool, if no explicit configured
 * @return the configured executor service, or <tt>null</tt> if none was configured.
 * @throws IllegalArgumentException is thrown if lookup of executor service in {@link org.apache.camel.spi.Registry} was not found
 */
public static ExecutorService getConfiguredExecutorService(RouteContext routeContext, String name,
                                                           ExecutorServiceAwareDefinition<?> definition,
                                                           boolean useDefault) throws IllegalArgumentException {
    ExecutorServiceManager manager = routeContext.getCamelContext().getExecutorServiceManager();
    ObjectHelper.notNull(manager, "ExecutorServiceManager", routeContext.getCamelContext());

    // prefer to use explicit configured executor on the definition
    if (definition.getExecutorService() != null) {
        return definition.getExecutorService();
    } else if (definition.getExecutorServiceRef() != null) {
        // lookup in registry first and use existing thread pool if exists
        ExecutorService answer = lookupExecutorServiceRef(routeContext, name, definition, definition.getExecutorServiceRef());
        if (answer == null) {
            throw new IllegalArgumentException("ExecutorServiceRef " + definition.getExecutorServiceRef() + " not found in registry or as a thread pool profile.");
        }
        return answer;
    } else if (useDefault) {
        return manager.newDefaultThreadPool(definition, name);
    }

    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:44,代码来源:ProcessorDefinitionHelper.java


示例12: getConfiguredScheduledExecutorService

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
/**
 * Will lookup and get the configured {@link java.util.concurrent.ScheduledExecutorService} from the given definition.
 * <p/>
 * This method will lookup for configured thread pool in the following order
 * <ul>
 * <li>from the definition if any explicit configured executor service.</li>
 * <li>from the {@link org.apache.camel.spi.Registry} if found</li>
 * <li>from the known list of {@link org.apache.camel.spi.ThreadPoolProfile ThreadPoolProfile(s)}.</li>
 * <li>if none found, then <tt>null</tt> is returned.</li>
 * </ul>
 * The various {@link ExecutorServiceAwareDefinition} should use this helper method to ensure they support
 * configured executor services in the same coherent way.
 *
 * @param routeContext the rout context
 * @param name         name which is appended to the thread name, when the {@link java.util.concurrent.ExecutorService}
 *                     is created based on a {@link org.apache.camel.spi.ThreadPoolProfile}.
 * @param definition   the node definition which may leverage executor service.
 * @param useDefault   whether to fallback and use a default thread pool, if no explicit configured
 * @return the configured executor service, or <tt>null</tt> if none was configured.
 * @throws IllegalArgumentException is thrown if the found instance is not a ScheduledExecutorService type,
 *                                  or lookup of executor service in {@link org.apache.camel.spi.Registry} was not found
 */
public static ScheduledExecutorService getConfiguredScheduledExecutorService(RouteContext routeContext, String name,
                                                                             ExecutorServiceAwareDefinition<?> definition,
                                                                             boolean useDefault) throws IllegalArgumentException {
    ExecutorServiceManager manager = routeContext.getCamelContext().getExecutorServiceManager();
    ObjectHelper.notNull(manager, "ExecutorServiceManager", routeContext.getCamelContext());

    // prefer to use explicit configured executor on the definition
    if (definition.getExecutorService() != null) {
        ExecutorService executorService = definition.getExecutorService();
        if (executorService instanceof ScheduledExecutorService) {
            return (ScheduledExecutorService) executorService;
        }
        throw new IllegalArgumentException("ExecutorServiceRef " + definition.getExecutorServiceRef() + " is not an ScheduledExecutorService instance");
    } else if (definition.getExecutorServiceRef() != null) {
        ScheduledExecutorService answer = lookupScheduledExecutorServiceRef(routeContext, name, definition, definition.getExecutorServiceRef());
        if (answer == null) {
            throw new IllegalArgumentException("ExecutorServiceRef " + definition.getExecutorServiceRef() + " not found in registry or as a thread pool profile.");
        }
        return answer;
    } else if (useDefault) {
        return manager.newDefaultScheduledThreadPool(definition, name);
    }

    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:48,代码来源:ProcessorDefinitionHelper.java


示例13: createProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
    Policy policy = resolvePolicy(routeContext);
    ObjectHelper.notNull(policy, "policy", this);

    // before wrap
    policy.beforeWrap(routeContext, this);

    // create processor after the before wrap
    Processor childProcessor = this.createChildProcessor(routeContext, true);

    // wrap
    Processor target = policy.wrap(routeContext, childProcessor);

    if (!(target instanceof Service)) {
        // wrap the target so it becomes a service and we can manage its lifecycle
        target = new WrapProcessor(target, childProcessor);
    }
    return target;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:PolicyDefinition.java


示例14: addExceptionPolicy

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
public void addExceptionPolicy(RouteContext routeContext, OnExceptionDefinition exceptionType) {
    if (routeContext != null) {
        // add error handler as child service so they get lifecycle handled
        Processor errorHandler = exceptionType.getErrorHandler(routeContext.getRoute().getId());
        if (errorHandler != null) {
            addChildService(errorHandler);
        }
    }

    List<Class<? extends Throwable>> list = exceptionType.getExceptionClasses();
    for (Class<? extends Throwable> clazz : list) {
        String routeId = null;
        // only get the route id, if the exception type is route scoped
        if (exceptionType.isRouteScoped()) {
            RouteDefinition route = ProcessorDefinitionHelper.getRoute(exceptionType);
            if (route != null) {
                routeId = route.getId();
            }
        }
        ExceptionPolicyKey key = new ExceptionPolicyKey(routeId, clazz, exceptionType.getOnWhen());
        exceptionPolicies.put(key, exceptionType);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:ErrorHandlerSupport.java


示例15: createProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Processor createProcessor(RouteContext routeContext) throws Exception {
    Processor childProcessor = this.createChildProcessor(routeContext, true);

    IdempotentRepository<String> idempotentRepository =
            (IdempotentRepository<String>) resolveMessageIdRepository(routeContext);
    ObjectHelper.notNull(idempotentRepository, "idempotentRepository", this);

    Expression expression = getExpression().createExpression(routeContext);

    // these boolean should be true by default
    boolean eager = getEager() == null || getEager();
    boolean duplicate = getSkipDuplicate() == null || getSkipDuplicate();
    boolean remove = getRemoveOnFailure() == null || getRemoveOnFailure();
    // these boolean should be false by default
    boolean completionEager = getCompletionEager() != null && getCompletionEager();

    return new IdempotentConsumer(expression, idempotentRepository, eager, completionEager, duplicate, remove, childProcessor);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:IdempotentConsumerDefinition.java


示例16: 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;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:14,代码来源:FlowEndProcessorDefinition.java


示例17: createProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
    FlowProcessor processor = doCreateProcessor(routeContext);
    processor
        .inType(inType)
        .outType(outType)
        .inFormat(inFormat)
        .outFormat(outFormat)
        .outConversion(outConversion)
        .renderer(renderer(routeContext, processor.getMessageRenderer()))
        .setProcessor(createChildProcessor(routeContext, false));
    return processor;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:14,代码来源:FlowProcessorDefinition.java


示例18: renderer

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
private PlatformMessageRenderer renderer(RouteContext routeContext, PlatformMessageRenderer defaultRenderer) {
    if (messageRenderer != null) {
        return messageRenderer;
    } else if (messageRendererBeanName != null) {
        return routeContext.lookup(messageRendererBeanName, PlatformMessageRenderer.class);
    } else {
        return defaultRenderer;
    }
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:10,代码来源:FlowProcessorDefinition.java


示例19: 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;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:13,代码来源:DedupeDefinition.java


示例20: doCreateProcessor

import org.apache.camel.spi.RouteContext; //导入依赖的package包/类
@Override
public FlowProcessor doCreateProcessor(RouteContext routeContext) throws Exception {
    FlowBeginProcessor processor = createFlowBeginProcessor(routeContext);
    processor
        .identifier(identifier)
        .application(application)
        .expectedAckCount(expectedAckCount)
        .replayErrorHandler(replayErrorUri)
        .register();
    return processor;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:12,代码来源:FlowBeginProcessorDefinition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IfSqlNode类代码示例发布时间:2022-05-22
下一篇:
Java WeekViewEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap