use of org.springframework.context.annotation.Primary in project mybatis.flying by limeng32.
the class SqlSessionFactory2Config method createSqlSessionFactory2Bean.
@Bean(name = "sqlSessionFactory2")
@Primary
public SqlSessionFactoryBean createSqlSessionFactory2Bean() throws IOException {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
/**
* 设置datasource
*/
sqlSessionFactoryBean.setDataSource(dataSource2);
VFS.addImplClass(SpringBootVFS.class);
/**
* 设置mybatis configuration 扫描路径
*/
sqlSessionFactoryBean.setConfigLocation(new ClassPathResource("Configuration.xml"));
/**
* 设置typeAlias 包扫描路径
*/
sqlSessionFactoryBean.setTypeAliasesPackage("indi.mybatis.flying");
/**
* 添加mapper 扫描路径
*/
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] ra1 = resolver.getResources("classpath*:indi/mybatis/flying/mapper*/*.xml");
// 扫描映射文件
sqlSessionFactoryBean.setMapperLocations(ra1);
return sqlSessionFactoryBean;
}
use of org.springframework.context.annotation.Primary in project esup-papercut by EsupPortail.
the class CasConfig method authenticationEntryPoint.
@Bean
@Primary
public AuthenticationEntryPoint authenticationEntryPoint(ServiceProperties sP) {
CasAuthenticationEntryPoint entryPoint = new CasAuthenticationEntryPoint();
entryPoint.setLoginUrl(url + "/login");
entryPoint.setServiceProperties(sP);
return entryPoint;
}
use of org.springframework.context.annotation.Primary in project CzechIdMng by bcvsolutions.
the class AsyncConfig method getAsyncExecutor.
/**
* Scaled for combination of computing (e.g. for automatic roles) and I/O operations (synchronization) tasks. Uses cpu count as default pool size,
* leaves some space for event thread pool, which has higher priority, see {@link #eventExecutor()}.
*/
@Primary
@Override
@Bean(name = SchedulerConfiguration.TASK_EXECUTOR_NAME)
public Executor getAsyncExecutor() {
int cpuCount = Runtime.getRuntime().availableProcessors();
//
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
int corePoolSize = env.getProperty(SchedulerConfiguration.PROPERTY_TASK_EXECUTOR_CORE_POOL_SIZE, Integer.class, cpuCount);
// ~4
executor.setCorePoolSize(corePoolSize);
int maxPoolSize = env.getProperty(SchedulerConfiguration.PROPERTY_TASK_EXECUTOR_MAX_POOL_SIZE, Integer.class, corePoolSize * 2);
// ~8
executor.setMaxPoolSize(maxPoolSize);
int queueCapacity = env.getProperty(SchedulerConfiguration.PROPERTY_TASK_EXECUTOR_QUEUE_CAPACITY, Integer.class, SchedulerConfiguration.DEFAULT_TASK_EXECUTOR_QUEUE_CAPACITY);
executor.setQueueCapacity(queueCapacity);
executor.setThreadPriority(env.getProperty(SchedulerConfiguration.PROPERTY_TASK_EXECUTOR_THREAD_PRIORITY, Integer.class, 5));
// MODE_INHERITABLETHREADLOCAL mode is not recommended in environment where thread pools are used (old SecurityContext can be reused in next thread using.).
// Instead that the DelegatingSecurityContextRunnable is used for delegating the SecurityContext to child the thread.
// Same is applies for TransactionContext. You have to use DelegatingTransactionContextRunnable for delegating to the child thread.
// Beware, you have to wrap every new Thread to this delegate objects (wrappers).
executor.setTaskDecorator(runnable -> new DelegatingSecurityContextRunnable(new DelegatingTransactionContextRunnable(runnable)));
executor.setThreadNamePrefix("base-task-executor-");
executor.initialize();
//
LOG.info("Task executor is initialized: corePoolSize [{}], maxPoolSize [{}], queueCapacity [{}]", corePoolSize, maxPoolSize, queueCapacity);
//
return executor;
}
use of org.springframework.context.annotation.Primary in project apollo by ctripcorp.
the class SkipAuthorizationConfiguration method permissionValidator.
@Primary
@Bean("permissionValidator")
public PermissionValidator permissionValidator() {
final PermissionValidator mock = mock(PermissionValidator.class);
when(mock.isSuperAdmin()).thenReturn(true);
return mock;
}
use of org.springframework.context.annotation.Primary in project apollo by ctripcorp.
the class SkipAuthorizationConfiguration method consumerAuthUtil.
@Primary
@Bean
public ConsumerAuthUtil consumerAuthUtil() {
final ConsumerAuthUtil mock = mock(ConsumerAuthUtil.class);
when(mock.getConsumerId(any())).thenReturn(1L);
return mock;
}
Aggregations