use of org.springframework.context.annotation.Primary in project xm-ms-entity by xm-online.
the class ProfileResourceIntTest method xmAuthenticationContextHolder.
@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
XmAuthenticationContext context = mock(XmAuthenticationContext.class);
when(context.hasAuthentication()).thenReturn(true);
when(context.isFullyAuthenticated()).thenReturn(true);
when(context.getUserKey()).thenReturn(Optional.of(DEFAULT_USER_KEY));
when(context.getRequiredUserKey()).thenReturn(DEFAULT_USER_KEY);
XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
when(holder.getContext()).thenReturn(context);
return holder;
}
use of org.springframework.context.annotation.Primary in project xm-ms-entity by xm-online.
the class CommentResourceIntTest method xmAuthenticationContextHolder.
@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
XmAuthenticationContext context = mock(XmAuthenticationContext.class);
when(context.hasAuthentication()).thenReturn(true);
when(context.getLogin()).thenReturn(Optional.of("testLogin"));
when(context.getUserKey()).thenReturn(Optional.of(DEFAULT_USER_KEY));
XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
when(holder.getContext()).thenReturn(context);
return holder;
}
use of org.springframework.context.annotation.Primary in project giftcard-demo-series by AxonIQ.
the class PrimaryJpaConfig method flyway.
/**
**********************************************************************
* Using Flyway to do the required schema creation/updates
***********************************************************************
*/
@Bean
@Primary
@ConfigurationProperties(prefix = "primary.flyway")
public Flyway flyway(DataSource dataSource) {
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
return flyway;
}
use of org.springframework.context.annotation.Primary in project Spring-Family by Sierou-Java.
the class DruidDBConfig method dataSource.
// 声明其为Bean实例
@Bean
// 在同样的DataSource中,首先使用被标注的DataSource
@Primary
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
// configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
use of org.springframework.context.annotation.Primary in project dhis2-core by dhis2.
the class AuthoritiesProviderConfig method systemAuthoritiesProvider.
@Primary
@Bean("org.hisp.dhis.security.SystemAuthoritiesProvider")
public SystemAuthoritiesProvider systemAuthoritiesProvider() {
SchemaAuthoritiesProvider schemaAuthoritiesProvider = new SchemaAuthoritiesProvider(schemaService);
AppsSystemAuthoritiesProvider appsSystemAuthoritiesProvider = new AppsSystemAuthoritiesProvider(appManager);
DetectingSystemAuthoritiesProvider detectingSystemAuthoritiesProvider = new DetectingSystemAuthoritiesProvider();
detectingSystemAuthoritiesProvider.setRequiredAuthoritiesProvider(requiredAuthoritiesProvider());
CompositeSystemAuthoritiesProvider provider = new CompositeSystemAuthoritiesProvider();
provider.setSources(ImmutableSet.of(new CachingSystemAuthoritiesProvider(detectingSystemAuthoritiesProvider), new CachingSystemAuthoritiesProvider(moduleSystemAuthoritiesProvider()), new CachingSystemAuthoritiesProvider(simpleSystemAuthoritiesProvider()), schemaAuthoritiesProvider, appsSystemAuthoritiesProvider));
return provider;
}
Aggregations