@Reference(policy = ReferencePolicy.DYNAMIC)
    protected void setScheduler(ScheduledExecutorService scheduler) {

        ScheduledExecutorService oldService = executorService.getAndSet(scheduler);

        if (oldService != null && fileMonitors != null) {
            // Monitors must reschedule their tasks with the new service
            for (MonitorHolder mh : fileMonitors.values()) {
                mh.reschedule();
            }
        }
    }
@ Reference ( policy = ReferencePolicy . DYNAMIC ) protected void setScheduler ( ScheduledExecutorService scheduler ) { ScheduledExecutorService oldService = executorService . getAndSet ( scheduler ) ; if ( oldService != null && fileMonitors != null ) { for ( MonitorHolder mh : fileMonitors . values ( ) ) { mh . reschedule ( ) ; } } }
Inject a ServiceReference for the required/dynamic ScheduledExecutorService.
If the service is different than the previous value, we need to queue
established monitors to cancel their tasks with the old executor service,
and reschedule them with the new one.

@param schedulerRef ServiceReference for the required/dynamic ScheduledExcecutorService