public static ScheduledExecutorService decorateExecutorService(Scheduler owner, ScheduledExecutorService original) {
		synchronized (DECORATORS) {
			for (BiFunction<Scheduler, ScheduledExecutorService, ScheduledExecutorService> decorator : DECORATORS.values()) {
				original = decorator.apply(owner, original);
			}
		}

		final ScheduledExecutorService beforeFactory = original;

		// Backward compatibility
		final String schedulerType;
		if (owner instanceof SingleScheduler) {
			schedulerType = Schedulers.SINGLE;
		}
		else if (owner instanceof ParallelScheduler) {
			schedulerType = Schedulers.PARALLEL;
		}
		else if (owner instanceof ElasticScheduler) {
			schedulerType = Schedulers.ELASTIC;
		}
		else if (owner instanceof DelegateServiceScheduler) {
			schedulerType = "ExecutorService";
		}
		else {
			schedulerType = owner.getClass().getName();
		}

		return factory.decorateExecutorService(schedulerType, () -> beforeFactory);
	}
public static ScheduledExecutorService decorateExecutorService(Scheduler owner, ScheduledExecutorService original) {
		synchronized (DECORATORS) {
			for (BiFunction<Scheduler, ScheduledExecutorService, ScheduledExecutorService> decorator : DECORATORS.values()) {
				original = decorator.apply(owner, original);
			}
		}

		final ScheduledExecutorService beforeFactory = original;

		
		final String schedulerType;
		if (owner instanceof SingleScheduler) {
			schedulerType = Schedulers.SINGLE;
		}
		else if (owner instanceof ParallelScheduler) {
			schedulerType = Schedulers.PARALLEL;
		}
		else if (owner instanceof ElasticScheduler) {
			schedulerType = Schedulers.ELASTIC;
		}
		else if (owner instanceof DelegateServiceScheduler) {
			schedulerType = "ExecutorService";
		}
		else {
			schedulerType = owner.getClass().getName();
		}

		return factory.decorateExecutorService(schedulerType, () -> beforeFactory);
	}
public static ScheduledExecutorService decorateExecutorService ( Scheduler owner , ScheduledExecutorService original ) { synchronized ( DECORATORS ) { for ( BiFunction < Scheduler , ScheduledExecutorService , ScheduledExecutorService > decorator : DECORATORS . values ( ) ) { original = decorator . apply ( owner , original ) ; } } final ScheduledExecutorService beforeFactory = original ; // Backward compatibility final String schedulerType ; if ( owner instanceof SingleScheduler ) { schedulerType = Schedulers . SINGLE ; } else if ( owner instanceof ParallelScheduler ) { schedulerType = Schedulers . PARALLEL ; } else if ( owner instanceof ElasticScheduler ) { schedulerType = Schedulers . ELASTIC ; } else if ( owner instanceof DelegateServiceScheduler ) { schedulerType = "ExecutorService" ; } else { schedulerType = owner . getClass ( ) . getName ( ) ; } return factory . decorateExecutorService ( schedulerType , ( ) -> beforeFactory ) ; }
This method is aimed at {@link Scheduler} implementors, enabling custom implementations
that are backed by a {@link ScheduledExecutorService} to also have said executors
decorated (ie. for instrumentation purposes).
<p>
It <strong>applies</strong> the decorators added via
{@link #addExecutorServiceDecorator(String, BiFunction)}, so it shouldn't be added
as a decorator. Note also that decorators are not guaranteed to be idempotent, so
this method should be called only once per executor.

@param owner a {@link Scheduler} that owns the {@link ScheduledExecutorService}
@param original the {@link ScheduledExecutorService} that the {@link Scheduler}
wants to use originally
@return the decorated {@link ScheduledExecutorService}, or the original if no decorator is set up
@see #addExecutorServiceDecorator(String, BiFunction)
@see #removeExecutorServiceDecorator(String)
This method is aimed at { @link Scheduler } implementors enabling custom implementations that are backed by a { @link ScheduledExecutorService } to also have said executors decorated ( ie . for instrumentation purposes ) . <p > It <strong > applies< / strong > the decorators added via { @link #addExecutorServiceDecorator ( String BiFunction ) } so it shouldn t be added as a decorator . Note also that decorators are not guaranteed to be idempotent so this method should be called only once per executor .