Search in sources :

Example 1 with DelegatingSecurityContextScheduledExecutorService

use of org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService in project irida by phac-nml.

the class AnalysisExecutionServiceTestConfig method analysisTaskExecutor.

/**
 * Builds a new Executor for analysis tasks.
 *
 * @return A new Executor for analysis tasks.
 */
@Profile({ "test", "it" })
@Bean
public Executor analysisTaskExecutor() {
    ScheduledExecutorService delegateExecutor = Executors.newSingleThreadScheduledExecutor();
    SecurityContext schedulerContext = createSchedulerSecurityContext();
    return new DelegatingSecurityContextScheduledExecutorService(delegateExecutor, schedulerContext);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DelegatingSecurityContextScheduledExecutorService(org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService) DelegatingSecurityContextScheduledExecutorService(org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService) SecurityContext(org.springframework.security.core.context.SecurityContext) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Example 2 with DelegatingSecurityContextScheduledExecutorService

use of org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService in project irida by phac-nml.

the class IridaApiServicesConfig method analysisTaskExecutor.

/**
 * Builds a new {@link Executor} for analysis tasks.
 *
 * @param userService
 *            a reference to the user service.
 *
 * @return A new {@link Executor} for analysis tasks.
 */
@Bean
@DependsOn("springLiquibase")
@Profile({ "prod", "dev" })
public Executor analysisTaskExecutor(UserService userService) {
    ScheduledExecutorService delegateExecutor = Executors.newScheduledThreadPool(4);
    SecurityContext schedulerContext = createAnalysisTaskSecurityContext(userService);
    return new DelegatingSecurityContextScheduledExecutorService(delegateExecutor, schedulerContext);
}
Also used : DelegatingSecurityContextScheduledExecutorService(org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DelegatingSecurityContextScheduledExecutorService(org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService) SecurityContext(org.springframework.security.core.context.SecurityContext) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 3 with DelegatingSecurityContextScheduledExecutorService

use of org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService in project irida by phac-nml.

the class IridaScheduledTasksConfig method taskExecutor.

/**
 * Builds a new Executor for scheduled tasks.
 *
 * @return A new Executor for scheduled tasks.
 */
private Executor taskExecutor() {
    ScheduledExecutorService delegateExecutor = Executors.newScheduledThreadPool(threadCount);
    SecurityContext schedulerContext = createSchedulerSecurityContext();
    return new DelegatingSecurityContextScheduledExecutorService(delegateExecutor, schedulerContext);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DelegatingSecurityContextScheduledExecutorService(org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService) DelegatingSecurityContextScheduledExecutorService(org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService) SecurityContext(org.springframework.security.core.context.SecurityContext)

Aggregations

ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 DelegatingSecurityContextScheduledExecutorService (org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService)3 SecurityContext (org.springframework.security.core.context.SecurityContext)3 Bean (org.springframework.context.annotation.Bean)1 Profile (org.springframework.context.annotation.Profile)1 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)1