org.glassfish.jersey.spi

## Interface ScheduledExecutorServiceProvider

All Superinterfaces:
  ExecutorServiceProvider

All Known Implementing Classes:
  ScheduledThreadPoolExecutorProvider

    @Contract
    public interface ScheduledExecutorServiceProvider
    extends ExecutorServiceProvider

An extension contract for providing pluggable scheduled executor service providers to be used by Jersey client or server runtime whenever a specific scheduler is needed to schedule execution of a Jersey runtime processing task.

This mechanism allows Jersey to run in environments that have specific thread management and provisioning requirements, such as application servers, cloud environments etc. Dedicated Jersey extension modules or applications running in such environment may provide a custom implementation of the `ScheduledExecutorServiceProvider` interface to customize the default Jersey runtime thread management & provisioning strategy in order to comply with the threading requirements, models and policies specific to each particular environment.

Jersey runtime expects that a concrete scheduled executor service provider implementation class is annotated with a `qualifier` annotation. This qualifier is then used to createAndInitialize a qualified injection point for injecting the scheduled executor service instance provided by the annotated provider. `Named` providers are also supported. For example:

     @Named("my-scheduler")
     public MySchedulerProvider implements ScheduledExecutorServiceProvider {
         ...
     }

     ...

     // Injecting ScheduledExecutorService provided by the MySchedulerProvider
     @Inject @Named("my-scheduler") ScheduledExecutorService myScheduler;

Since:
  2.18
Author:
  Marek Potociar
See Also:
  `ExecutorServiceProvider`, `ScheduledThreadPoolExecutorProvider`

### Method Summary

All Methods Instance Methods Abstract Methods
`ScheduledExecutorService` `getExecutorService()` Get a scheduled executor service to be used by Jersey client or server runtime to schedule execution of specific tasks.

### Methods inherited from interface org.glassfish.jersey.spi.ExecutorServiceProvider

`dispose`

### Method Detail

#### getExecutorService

    ScheduledExecutorService getExecutorService()

Get a scheduled executor service to be used by Jersey client or server runtime to schedule execution of specific tasks.

This method is usually invoked just once at either Jersey client or server application runtime initialization, it may however be invoked multiple times. Once the instance of the provided scheduled executor service is not needed anymore by Jersey application runtime, it will be `disposed`. This typically happens in one of the following situations:

- Jersey client instance is closed (client runtime is shut down).
- Jersey container running a server-side Jersey application is shut down.
- Jersey server-side application is un-deployed.

Specified by:
  `getExecutorService` in interface `ExecutorServiceProvider`
Returns:
  a scheduled executor service. Must not return `null`.