org.apache.felix.ipojo.extender.internal.queue

## Class ExecutorQueueService

- java.lang.Object
- - org.apache.felix.ipojo.extender.internal.AbstractService
  - - org.apache.felix.ipojo.extender.internal.queue.AbstractQueueService
    - - org.apache.felix.ipojo.extender.internal.queue.ExecutorQueueService

All Implemented Interfaces:
  Lifecycle, LifecycleQueueService, QueueNotifier, QueueService, org.osgi.service.cm.ManagedService

    public class ExecutorQueueService
    extends AbstractQueueService
    implements LifecycleQueueService, org.osgi.service.cm.ManagedService

An asynchronous implementation of the queue service. This implementation relies on an executor service.

### Field Summary

Fields
`static java.lang.String` `EXECUTOR_QUEUE_SERVICE_PID` Service PID used to identify service with ConfigAdmin.
`static java.lang.String` `THREADPOOL_SIZE_PROPERTY` Property name used to configure this ThreadPool's size (usable as System Property or ConfigAdmin property).

### Fields inherited from class org.apache.felix.ipojo.extender.internal.queue.AbstractQueueService

`m_listeners`

### Fields inherited from class org.apache.felix.ipojo.extender.internal.AbstractService

`m_bundleContext`

### Fields inherited from interface org.apache.felix.ipojo.extender.queue.QueueService

`ASYNCHRONOUS_QUEUE_MODE, GLOABL_QUEUE_SCOPE, PREFERENCE_QUEUE_MODE, QUEUE_MODE_PROPERTY, QUEUE_SCOPE_PROPERTY, SYNCHRONOUS_QUEUE_MODE`

### Constructor Summary

Constructors
Constructor and Description
`ExecutorQueueService(org.osgi.framework.BundleContext bundleContext)` Creates the queue service using the default pool size.
`ExecutorQueueService(org.osgi.framework.BundleContext bundleContext, int size)` Creates the queue service.
`ExecutorQueueService(org.osgi.framework.BundleContext bundleContext, int size, java.util.concurrent.ThreadFactory threadFactory)` Creates the queue service.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `getCurrents()`
`int` `getFinished()`
`protected java.util.Dictionary<java.lang.String,?>` `getServiceProperties()`
`int` `getWaiters()`
`java.util.List<JobInfo>` `getWaitersInfo()`
`protected org.osgi.framework.ServiceRegistration<?>` `registerService()`
`void` `stop()` Stops the service.
`<T> java.util.concurrent.Future<T>` `submit(Job<T> callable)` Submits a job to the queue service.
`<T> java.util.concurrent.Future<T>` `submit(Job<T> callable, Callback<T> callback, java.lang.String description)` Submits a job to the queue.
`<T> java.util.concurrent.Future<T>` `submit(Job<T> callable, java.lang.String description)` Submits a job to the queue service.
`void` `updated(java.util.Dictionary properties)`

### Methods inherited from class org.apache.felix.ipojo.extender.internal.queue.AbstractQueueService

`addQueueListener, fireEnlistedJobInfo, fireExecutedJobInfo, fireFailedJobInfo, fireStartedJobInfo, removeQueueListener`

### Methods inherited from class org.apache.felix.ipojo.extender.internal.AbstractService

`getBundleContext, getRegistration, isRegistered, start`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.felix.ipojo.extender.queue.QueueService

`addQueueListener, removeQueueListener`

### Methods inherited from interface org.apache.felix.ipojo.extender.internal.Lifecycle

`start`

### Field Detail

#### THREADPOOL_SIZE_PROPERTY

    public static final java.lang.String THREADPOOL_SIZE_PROPERTY

Property name used to configure this ThreadPool's size (usable as System Property or ConfigAdmin property).

See Also:
  Constant Field Values

#### EXECUTOR_QUEUE_SERVICE_PID

    public static final java.lang.String EXECUTOR_QUEUE_SERVICE_PID

Service PID used to identify service with ConfigAdmin.

See Also:
  Constant Field Values

### Constructor Detail

#### ExecutorQueueService

    public ExecutorQueueService(org.osgi.framework.BundleContext bundleContext)

Creates the queue service using the default pool size.

Parameters:
  `bundleContext` - the bundle context.

#### ExecutorQueueService

    public ExecutorQueueService(org.osgi.framework.BundleContext bundleContext,
                                int size)

Creates the queue service.

Parameters:
  `bundleContext` - the bundle context.
  `size` - the thread pool size.

#### ExecutorQueueService

    public ExecutorQueueService(org.osgi.framework.BundleContext bundleContext,
                                int size,
                                java.util.concurrent.ThreadFactory threadFactory)

Creates the queue service.

Parameters:
  `bundleContext` - the bundle context.
  `size` - the thread pool size
  `threadFactory` - the thread factory

### Method Detail

#### registerService

    protected org.osgi.framework.ServiceRegistration<?> registerService()

Overrides:
  `registerService` in class `AbstractService`

#### stop

    public void stop()

Stops the service.

Specified by:
  `stop` in interface `Lifecycle`
Overrides:
  `stop` in class `AbstractService`

#### getServiceProperties

    protected java.util.Dictionary<java.lang.String,?> getServiceProperties()

Overrides:
  `getServiceProperties` in class `AbstractService`
Returns:
  the service properties, null by default.

#### getFinished

    public int getFinished()

Specified by:
  `getFinished` in interface `QueueService`
Returns:
  the number of jobs that have been executed entirely (including successful and erroneous jobs).

#### getWaiters

    public int getWaiters()

Specified by:
  `getWaiters` in interface `QueueService`
Returns:
  the number of jobs scheduled but not yet started.

#### getCurrents

    public int getCurrents()

Specified by:
  `getCurrents` in interface `QueueService`
Returns:
  the number of jobs currently executed (started but not finished).

#### getWaitersInfo

    public java.util.List<JobInfo> getWaitersInfo()

Specified by:
  `getWaitersInfo` in interface `QueueService`
Returns:
  a snapshot of the currently waiting jobs.

#### submit

    public <T> java.util.concurrent.Future<T> submit(Job<T> callable,
                                                     Callback<T> callback,
                                                     java.lang.String description)

Submits a job to the queue. The submitted job is wrapped into a `JobInfoCallable` to collect the statistics.

Specified by:
  `submit` in interface `QueueService`
Parameters:
  `callable` - the job
  `callback` - callback called when the job is processed
  `description` - a description of the job
Returns:
  the reference on the submitted job

#### submit

    public <T> java.util.concurrent.Future<T> submit(Job<T> callable,
                                                     java.lang.String description)

Description copied from interface: `QueueService`
Submits a job to the queue service.

Specified by:
  `submit` in interface `QueueService`
Parameters:
  `callable` - the job
  `description` - a description of the job
Returns:
  the future object to retrieve the result

#### submit

    public <T> java.util.concurrent.Future<T> submit(Job<T> callable)

Description copied from interface: `QueueService`
Submits a job to the queue service.

Specified by:
  `submit` in interface `QueueService`
Parameters:
  `callable` - the job
Returns:
  the future object to retrieve the result

#### updated

    public void updated(java.util.Dictionary properties)
                 throws org.osgi.service.cm.ConfigurationException

Specified by:
  `updated` in interface `org.osgi.service.cm.ManagedService`
Throws:
  `org.osgi.service.cm.ConfigurationException`