@Override protected DelegatingSecurityContextScheduledExecutorService create() { return new DelegatingSecurityContextScheduledExecutorService(delegate, securityContext); } }
public final <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { callable = wrap(callable); return getDelegate().schedule(callable, delay, unit); }
private ScheduledExecutorService getDelegate() { return (ScheduledExecutorService) getDelegateExecutor(); } }
@Test public void scheduleCallable() { when( (ScheduledFuture<Object>) delegate.schedule(wrappedCallable, 1, TimeUnit.SECONDS)).thenReturn(expectedResult); ScheduledFuture<Object> result = executor.schedule(callable, 1, TimeUnit.SECONDS); assertThat(result).isEqualTo(expectedResult); verify(delegate).schedule(wrappedCallable, 1, TimeUnit.SECONDS); }
@Test @SuppressWarnings("unchecked") public void scheduleAtFixedRate() { when( (ScheduledFuture<Object>) delegate.scheduleAtFixedRate(wrappedRunnable, 1, 2, TimeUnit.SECONDS)).thenReturn(expectedResult); ScheduledFuture<?> result = executor.scheduleAtFixedRate(runnable, 1, 2, TimeUnit.SECONDS); assertThat(result).isEqualTo(expectedResult); verify(delegate).scheduleAtFixedRate(wrappedRunnable, 1, 2, TimeUnit.SECONDS); }
@Test @SuppressWarnings("unchecked") public void scheduleWithFixedDelay() { when( (ScheduledFuture<Object>) delegate.scheduleWithFixedDelay( wrappedRunnable, 1, 2, TimeUnit.SECONDS)).thenReturn( expectedResult); ScheduledFuture<?> result = executor.scheduleWithFixedDelay(runnable, 1, 2, TimeUnit.SECONDS); assertThat(result).isEqualTo(expectedResult); verify(delegate).scheduleWithFixedDelay(wrappedRunnable, 1, 2, TimeUnit.SECONDS); }
@Test @SuppressWarnings("unchecked") public void scheduleRunnable() { when( (ScheduledFuture<Object>) delegate.schedule(wrappedRunnable, 1, TimeUnit.SECONDS)).thenReturn(expectedResult); ScheduledFuture<?> result = executor.schedule(runnable, 1, TimeUnit.SECONDS); assertThat(result).isEqualTo(expectedResult); verify(delegate).schedule(wrappedRunnable, 1, TimeUnit.SECONDS); }
public final ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { command = wrap(command); return getDelegate().scheduleAtFixedRate(command, initialDelay, period, unit); }
@Override protected DelegatingSecurityContextScheduledExecutorService create() { return new DelegatingSecurityContextScheduledExecutorService(delegate); }
private ScheduledExecutorService getDelegate() { return (ScheduledExecutorService) getDelegateExecutor(); } }
public final ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { command = wrap(command); return getDelegate().scheduleWithFixedDelay(command, initialDelay, delay, unit); }
@Bean public ScheduledExecutorService scheduledExecutorService() { return new DelegatingSecurityContextScheduledExecutorService(Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build())); }
private ScheduledExecutorService getDelegate() { return (ScheduledExecutorService) getDelegateExecutor(); } }
public final ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { command = wrap(command); return getDelegate().schedule(command, delay, unit); }
@Bean public ScheduledExecutorService scheduledExecutorService() { return new DelegatingSecurityContextScheduledExecutorService(Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build())); }
public final ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { command = wrap(command); return getDelegate().scheduleAtFixedRate(command, initialDelay, period, unit); }
/** * @return {@link ScheduledExecutorService} with security context * availability in thread execution. */ @Bean(destroyMethod = "shutdown") @ConditionalOnMissingBean public ScheduledExecutorService scheduledExecutorService() { return new DelegatingSecurityContextScheduledExecutorService( Executors.newScheduledThreadPool(asyncConfigurerProperties.getSchedulerThreads(), new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build())); }
public final ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { command = wrap(command); return getDelegate().schedule(command, delay, unit); }
/** * @return {@link ScheduledExecutorService} with security context * availability in thread execution. */ @Bean(destroyMethod = "shutdown") @ConditionalOnMissingBean public ScheduledExecutorService scheduledExecutorService() { return new DelegatingSecurityContextScheduledExecutorService( Executors.newScheduledThreadPool(asyncConfigurerProperties.getSchedulerThreads(), new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build())); }
public final <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { callable = wrap(callable); return getDelegate().schedule(callable, delay, unit); }