Package org.apache.sling.commons.threads

Examples of org.apache.sling.commons.threads.ThreadPool


        }

        final String name = "ThreadPool-" + UUID.randomUUID().toString() +
             (label == null ? "" : " (" + label + ")");
        final Entry entry = new Entry(null, config, name, bundleContext);
        ThreadPool threadPool = null;
        synchronized ( this.pools ) {
            this.pools.put(name, entry);
            threadPool = entry.incUsage();
        }
        entry.registerMBean();
View Full Code Here


     */
    public ThreadPool get(final String name) {
        final String poolName = (name == null ? DEFAULT_THREADPOOL_NAME : name);
        Entry entry = null;
        boolean created = false;
        ThreadPool threadPool = null;
        synchronized (this.pools) {
            entry = this.pools.get(poolName);
            if ( entry == null ) {
                this.logger.debug("Creating new pool with name {}", poolName);
                final ModifiableThreadPoolConfig config = new ModifiableThreadPoolConfig();
View Full Code Here

                }
            }

        };
        // check if the thread pool is available
        final ThreadPool pool = Environment.THREAD_POOL;
        if ( pool != null ) {
            pool.execute(task);
        } else {
            // if we don't have a thread pool, we create the thread directly
            // (this should never happen for jobs, but is a safe fallback and
            // allows to call this method for other background processing.
            new Thread(task).start();
View Full Code Here

                            }
                        }

                    };
                    // check if the thread pool is available
                    final ThreadPool pool = this.threadPool;
                    if ( pool != null ) {
                        pool.execute(task);
                    } else {
                        // if we don't have a thread pool, we create the thread directly
                        // (this should never happen for jobs, but is a safe fall back)
                        new Thread(task).start();
                    }
View Full Code Here

        final ThreadPoolManager tpm = this.threadPoolManager;
        if ( tpm == null ) {
            final SchedulerFactory factory = new StdSchedulerFactory();
            this.scheduler = factory.getScheduler();
        } else {
            final ThreadPool pool = tpm.get(THREAD_POOL_NAME);
            final QuartzThreadPool quartzPool = new QuartzThreadPool(pool);
            final DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance();
            factory.createScheduler(quartzPool, new RAMJobStore());
            this.scheduler = factory.getScheduler();
        }
View Full Code Here

            }
        };

        // we need a thread pool manager
        this.handler.threadPoolManager = this.getMockery().mock(ThreadPoolManager.class);
        final ThreadPool pool = new ThreadPoolImpl();
        this.getMockery().checking(new Expectations() {{
            allowing(handler.threadPoolManager).get(EventHelper.THREAD_POOL_NAME);
            will(returnValue(pool));
            allowing(handler.threadPoolManager).create(with(equal(EventHelper.THREAD_POOL_NAME)), with(any(ThreadPoolConfig.class)));
            will(returnValue(null));
View Full Code Here

    /**
     * Activate this component.
     */
    protected void activate(ComponentContext context) throws Exception {
        this.logger.info("Starting thread pool manager.");
        final ThreadPool defaultPool = new DefaultThreadPool(
                    DEFAULT_THREADPOOL_NAME,
                    new ThreadPoolConfig());
        synchronized ( this.pools ) {
            this.pools.put(defaultPool.getName(), defaultPool);
        }
        this.logger.info("Thread pool manager startet with default pool.");
    }
View Full Code Here

    public ThreadPool get(String name) {
        if ( name == null ) {
            name = DEFAULT_THREADPOOL_NAME;
        }
        synchronized (this.pools) {
            ThreadPool pool = this.pools.get(name);
            if ( pool == null && !(name.equals(DEFAULT_THREADPOOL_NAME))) {
                this.logger.info("Requested pool {} is not available, returning default pool.", name);
                pool = this.pools.get(DEFAULT_THREADPOOL_NAME);
            }
            return pool;
View Full Code Here

        }
        if ( config == null ) {
            throw new IllegalArgumentException("Config must not be null.");
        }
        synchronized ( this.pools ) {
            ThreadPool pool = this.pools.get(name);
            if ( pool != null ) {
                // pool already exists
                return null;
            }
            pool = new DefaultThreadPool(name, config);
View Full Code Here

        final ThreadPoolManager tpm = this.threadPoolManager;
        if ( tpm == null ) {
            final SchedulerFactory factory = new StdSchedulerFactory();
            this.scheduler = factory.getScheduler();
        } else {
            final ThreadPool pool = tpm.get(THREAD_POOL_NAME);
            final QuartzThreadPool quartzPool = new QuartzThreadPool(pool);
            final DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance();
            factory.createScheduler(quartzPool, new RAMJobStore());
            this.scheduler = factory.getScheduler();
        }
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.threads.ThreadPool

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.