Interface ScheduledExecutorServiceProvider

All Superinterfaces:
All Known Implementing Classes:

@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:

 public MySchedulerProvider implements ScheduledExecutorServiceProvider {


 // Injecting ScheduledExecutorService provided by the MySchedulerProvider
 @Inject @Named("my-scheduler") ScheduledExecutorService myScheduler;
Marek Potociar
See Also:
  • Method Details

    • 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
      a scheduled executor service. Must not return null.