Package org.apache.camel.spi

Examples of org.apache.camel.spi.ExecutorServiceManager


        FactoryFinderResolver factoryFinderResolver = getBeanForType(FactoryFinderResolver.class);
        if (factoryFinderResolver != null) {
            LOG.info("Using custom FactoryFinderResolver: " + factoryFinderResolver);
            getContext().setFactoryFinderResolver(factoryFinderResolver);
        }
        ExecutorServiceManager executorServiceStrategy = getBeanForType(ExecutorServiceManager.class);
        if (executorServiceStrategy != null) {
            LOG.info("Using custom ExecutorServiceStrategy: " + executorServiceStrategy);
            getContext().setExecutorServiceManager(executorServiceStrategy);
        }
        ThreadPoolFactory threadPoolFactory = getBeanForType(ThreadPoolFactory.class);
View Full Code Here


        FactoryFinderResolver factoryFinderResolver = getBeanForType(FactoryFinderResolver.class);
        if (factoryFinderResolver != null) {
            LOG.info("Using custom FactoryFinderResolver: " + factoryFinderResolver);
            getContext().setFactoryFinderResolver(factoryFinderResolver);
        }
        ExecutorServiceManager executorServiceStrategy = getBeanForType(ExecutorServiceManager.class);
        if (executorServiceStrategy != null) {
            LOG.info("Using custom ExecutorServiceStrategy: " + executorServiceStrategy);
            getContext().setExecutorServiceManager(executorServiceStrategy);
        }
        ThreadPoolFactory threadPoolFactory = getBeanForType(ThreadPoolFactory.class);
View Full Code Here

        FactoryFinderResolver factoryFinderResolver = getBeanForType(FactoryFinderResolver.class);
        if (factoryFinderResolver != null) {
            LOG.info("Using custom FactoryFinderResolver: " + factoryFinderResolver);
            getContext().setFactoryFinderResolver(factoryFinderResolver);
        }
        ExecutorServiceManager executorServiceStrategy = getBeanForType(ExecutorServiceManager.class);
        if (executorServiceStrategy != null) {
            LOG.info("Using custom ExecutorServiceStrategy: " + executorServiceStrategy);
            getContext().setExecutorServiceManager(executorServiceStrategy);
        }
        ThreadPoolFactory threadPoolFactory = getBeanForType(ThreadPoolFactory.class);
View Full Code Here

        if (getTimeout() != null) {
            answer.setTimeout(getTimeout());
        }
        if (isParallelProcessing() && executorService == null) {
            String ref = this.executorServiceRef != null ? this.executorServiceRef : "RecipientList";
            ExecutorServiceManager manager = routeContext.getCamelContext().getExecutorServiceManager();
            executorService = manager.newDefaultThreadPool(this, ref);
        }
        answer.setExecutorService(executorService);
        long timeout = getTimeout() != null ? getTimeout() : 0;
        if (timeout > 0 && !isParallelProcessing()) {
            throw new IllegalArgumentException("Timeout is used but ParallelProcessing has not been enabled.");
View Full Code Here

        if (aggregationStrategy == null) {
            // default to use latest aggregation strategy
            aggregationStrategy = new UseLatestAggregationStrategy();
        }

        ExecutorServiceManager executorServiceManager = routeContext.getCamelContext().getExecutorServiceManager();
        if (isParallelProcessing() && executorService == null) {
            String ref = this.executorServiceRef != null ? this.executorServiceRef : "Delay";
            executorService = executorServiceManager.newDefaultThreadPool(this, ref);
        }
        long timeout = getTimeout() != null ? getTimeout() : 0;
        if (timeout > 0 && !isParallelProcessing()) {
            throw new IllegalArgumentException("Timeout is used but ParallelProcessing has not been enabled.");
        }
View Full Code Here

     * @return the configured executor service, or <tt>null</tt> if none was configured.
     * @throws NoSuchBeanException 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) throws NoSuchBeanException {
        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 = routeContext.getCamelContext().getRegistry().lookup(definition.getExecutorServiceRef(), ExecutorService.class);
            if (answer == null) {
                // then create a thread pool assuming the ref is a thread pool profile id
                answer = manager.newThreadPool(definition, name, definition.getExecutorServiceRef());
            }
            if (answer == null) {
                throw new NoSuchBeanException(definition.getExecutorServiceRef(), "ExecutorService");
            }
            return answer;
View Full Code Here

     * @throws IllegalArgumentException is thrown if the found instance is not a ScheduledExecutorService type.
     * @throws NoSuchBeanException is thrown if lookup of executor service in {@link org.apache.camel.spi.Registry} was not found
     */
    public static ScheduledExecutorService getConfiguredScheduledExecutorService(RouteContext routeContext, String name,
                                                               ExecutorServiceAwareDefinition definition) throws IllegalArgumentException, NoSuchBeanException {
        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 = routeContext.getCamelContext().getRegistry().lookup(definition.getExecutorServiceRef(), ScheduledExecutorService.class);
            if (answer == null) {
                // then create a thread pool assuming the ref is a thread pool profile id
                ThreadPoolProfile profile = manager.getThreadPoolProfile(definition.getExecutorServiceRef());
                if (profile != null) {
                    answer = manager.newScheduledThreadPool(definition, name, profile);
                }
            }
            if (answer == null) {
                throw new NoSuchBeanException(definition.getExecutorServiceRef(), "ScheduledExecutorService");
            }
View Full Code Here

        if (executorService == null || executorService.isShutdown()) {
            // camel context will shutdown the executor when it shutdown so no need to shut it down when stopping
            if (executorServiceRef != null) {
                executorService = camelContext.getRegistry().lookup(executorServiceRef, ScheduledExecutorService.class);
                if (executorService == null) {
                    ExecutorServiceManager manager = camelContext.getExecutorServiceManager();
                    ThreadPoolProfile profile = manager.getThreadPoolProfile(executorServiceRef);
                    executorService = manager.newScheduledThreadPool(this, executorServiceRef, profile);
                }
                if (executorService == null) {
                    throw new IllegalArgumentException("ExecutorServiceRef " + executorServiceRef + " not found in registry.");
                }
            } else {
View Full Code Here

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Endpoint endpoint = resolveEndpoint(routeContext);

        String ref = this.executorServiceRef != null ? this.executorServiceRef : "WireTap";
        ExecutorServiceManager manager = routeContext.getCamelContext().getExecutorServiceManager();
        executorService = manager.newDefaultThreadPool(this, ref);
        WireTapProcessor answer = new WireTapProcessor(endpoint, getPattern(), executorService);

        answer.setCopy(isCopy());
        if (newExchangeProcessorRef != null) {
            newExchangeProcessor = routeContext.lookup(newExchangeProcessorRef, Processor.class);
View Full Code Here

        if (onWhen != null) {
            when = onWhen.getExpression().createPredicate(routeContext);
        }

        String ref = this.executorServiceRef != null ? this.executorServiceRef : "OnCompletion";
        ExecutorServiceManager manager = routeContext.getCamelContext().getExecutorServiceManager();
        executorService = manager.newDefaultThreadPool(this, ref);

        // should be false by default
        boolean original = getUseOriginalMessagePolicy() != null ? getUseOriginalMessagePolicy() : false;
        OnCompletionProcessor answer = new OnCompletionProcessor(routeContext.getCamelContext(), childProcessor,
                executorService, isOnCompleteOnly(), isOnFailureOnly(), when, original);
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.ExecutorServiceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.