org.apache.sling.commons.threads.impl
Class DefaultThreadPoolManager

java.lang.Object
  extended by org.apache.sling.commons.threads.impl.DefaultThreadPoolManager
All Implemented Interfaces:
ThreadPoolManager, org.osgi.service.cm.ManagedServiceFactory

public class DefaultThreadPoolManager
extends Object
implements ThreadPoolManager, org.osgi.service.cm.ManagedServiceFactory

The DefaultThreadPoolManager implements the ThreadPoolManager interface and is responsible for managing ThreadPools.


Nested Class Summary
protected static class DefaultThreadPoolManager.Entry
           
 
Field Summary
protected  org.osgi.framework.BundleContext bundleContext
          The bundle context.
protected  org.slf4j.Logger logger
          By default we use the logger for this class.
protected  Map<String,DefaultThreadPoolManager.Entry> pools
          The managed thread pools
protected  Dictionary<String,Object> properties
          The properties.
 
Fields inherited from interface org.apache.sling.commons.threads.ThreadPoolManager
DEFAULT_THREADPOOL_NAME
 
Constructor Summary
DefaultThreadPoolManager(org.osgi.framework.BundleContext bc, Dictionary<String,Object> props)
          Constructor and activate this component.
 
Method Summary
 ThreadPool create(ThreadPoolConfig config)
          Create a new thread pool with this configuration.
 ThreadPool create(ThreadPoolConfig config, String label)
          Create a new thread pool with this configuration.
 void deleted(String pid)
           
 void destroy()
          Deactivate this component.
 ThreadPool get(String name)
          Get a thread pool.
 DefaultThreadPoolManager.Entry[] getConfigurations()
          Return all configurations for the web console printer
 String getName()
           
 void release(ThreadPool pool)
          Release the thread pool again.
 void updated(String pid, Dictionary properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
By default we use the logger for this class.


pools

protected final Map<String,DefaultThreadPoolManager.Entry> pools
The managed thread pools


properties

protected final Dictionary<String,Object> properties
The properties.


bundleContext

protected final org.osgi.framework.BundleContext bundleContext
The bundle context.

Constructor Detail

DefaultThreadPoolManager

public DefaultThreadPoolManager(org.osgi.framework.BundleContext bc,
                                Dictionary<String,Object> props)
Constructor and activate this component.

Method Detail

destroy

public void destroy()
Deactivate this component.


get

public ThreadPool get(String name)
Description copied from interface: ThreadPoolManager
Get a thread pool. If there is no thread pool with the given name, a new thread pool with the default configuration is created and returned. A thread pool must be released when not used anymore with the ThreadPoolManager.release(ThreadPool) method.

Specified by:
get in interface ThreadPoolManager
Parameters:
name - The name of the thread pool or null for the default pool.
Returns:
A thread pool.
See Also:
ThreadPoolManager.get(java.lang.String)

release

public void release(ThreadPool pool)
Description copied from interface: ThreadPoolManager
Release the thread pool again.

Specified by:
release in interface ThreadPoolManager
See Also:
ThreadPoolManager.release(org.apache.sling.commons.threads.ThreadPool)

create

public ThreadPool create(ThreadPoolConfig config)
Description copied from interface: ThreadPoolManager
Create a new thread pool with this configuration. A thread pool must be released when not used anymore with the ThreadPoolManager.release(ThreadPool) method.

Specified by:
create in interface ThreadPoolManager
Parameters:
config - The thread pool configuration.
Returns:
A new thread pool.
See Also:
ThreadPoolManager.create(org.apache.sling.commons.threads.ThreadPoolConfig)

create

public ThreadPool create(ThreadPoolConfig config,
                         String label)
Description copied from interface: ThreadPoolManager
Create a new thread pool with this configuration. A thread pool must be released when not used anymore with the ThreadPoolManager.release(ThreadPool) method.

Specified by:
create in interface ThreadPoolManager
Parameters:
config - The thread pool configuration.
label - An optional label for the thread pool. The label will be appended to the name of the pool.
Returns:
A new thread pool.

getName

public String getName()
Specified by:
getName in interface org.osgi.service.cm.ManagedServiceFactory
See Also:
ManagedServiceFactory.getName()

getConfigurations

public DefaultThreadPoolManager.Entry[] getConfigurations()
Return all configurations for the web console printer


updated

public void updated(String pid,
                    Dictionary properties)
             throws org.osgi.service.cm.ConfigurationException
Specified by:
updated in interface org.osgi.service.cm.ManagedServiceFactory
Throws:
org.osgi.service.cm.ConfigurationException
See Also:
ManagedServiceFactory.updated(java.lang.String, java.util.Dictionary)

deleted

public void deleted(String pid)
Specified by:
deleted in interface org.osgi.service.cm.ManagedServiceFactory
See Also:
ManagedServiceFactory.deleted(java.lang.String)


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.