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

## Class PreferenceQueueService

- java.lang.Object
- - org.apache.felix.ipojo.extender.internal.queue.pref.PreferenceQueueService

All Implemented Interfaces:
  Lifecycle, LifecycleQueueService, QueueService

    public class PreferenceQueueService
    extends java.lang.Object
    implements LifecycleQueueService

An implementation of the queue service delegating on the synchronous and asynchronous implementations according to the processing preference.

### Field Summary

### 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
`PreferenceQueueService(PreferenceSelection strategy, LifecycleQueueService syncQueue, LifecycleQueueService asyncQueue)` Creates the preference queue service.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addQueueListener(QueueListener listener)` Add a `QueueListener` that will be notified on events relative to this `QueueService`.
`int` `getCurrents()`
`int` `getFinished()`
`int` `getWaiters()`
`java.util.List<JobInfo>` `getWaitersInfo()` Gets the number of waiting job.
`void` `removeQueueListener(QueueListener listener)` Remove a `QueueListener` from this `QueueService`.
`void` `start()` Starting queues.
`void` `stop()` Stopping queues.
`<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 right queue.
`<T> java.util.concurrent.Future<T>` `submit(Job<T> callable, java.lang.String description)` Submits a job to the queue service.

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

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

### Constructor Detail

#### PreferenceQueueService

    public PreferenceQueueService(PreferenceSelection strategy,
                                  LifecycleQueueService syncQueue,
                                  LifecycleQueueService asyncQueue)

Creates the preference queue service.

Parameters:
  `strategy` - the preference strategy
  `syncQueue` - the synchronous queue service
  `asyncQueue` - the asynchronous queue service

### Method Detail

#### start

    public void start()

Starting queues.

Specified by:
  `start` in interface `Lifecycle`

#### stop

    public void stop()

Stopping queues.

Specified by:
  `stop` in interface `Lifecycle`

#### getFinished

    public int getFinished()

Specified by:
  `getFinished` in interface `QueueService`
Returns:
  the number of completed jobs.

#### getWaiters

    public int getWaiters()

Specified by:
  `getWaiters` in interface `QueueService`
Returns:
  the number of waiting jobs.

#### getCurrents

    public int getCurrents()

Specified by:
  `getCurrents` in interface `QueueService`
Returns:
  the number of jobs being processed.

#### getWaitersInfo

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

Gets the number of waiting job. Notice that the synchronous queue does not have a waiting queue.

Specified by:
  `getWaitersInfo` in interface `QueueService`
Returns:
  the number of waiting job.

#### submit

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

Submits a job to the right queue. The queue selection works as follow: If the bundle submitting the queue has a preference, use this preference, otherwise use the default preference.

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 of 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

#### addQueueListener

    public void addQueueListener(QueueListener listener)

Description copied from interface: `QueueService`
Add a `QueueListener` that will be notified on events relative to this `QueueService`.

Specified by:
  `addQueueListener` in interface `QueueService`
Parameters:
  `listener` - added listener

#### removeQueueListener

    public void removeQueueListener(QueueListener listener)

Description copied from interface: `QueueService`
Remove a `QueueListener` from this `QueueService`.

Specified by:
  `removeQueueListener` in interface `QueueService`
Parameters:
  `listener` - removed listener