Search in sources :

Example 86 with Primary

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;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) XmAuthenticationContextHolder(com.icthh.xm.commons.security.XmAuthenticationContextHolder) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 87 with Primary

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;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) XmAuthenticationContextHolder(com.icthh.xm.commons.security.XmAuthenticationContextHolder) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 88 with Primary

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;
}
Also used : Flyway(org.flywaydb.core.Flyway) Primary(org.springframework.context.annotation.Primary) ConfigurationProperties(org.springframework.boot.context.properties.ConfigurationProperties) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 89 with Primary

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;
}
Also used : SQLException(java.sql.SQLException) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 90 with Primary

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;
}
Also used : DetectingSystemAuthoritiesProvider(org.hisp.dhis.security.authority.DetectingSystemAuthoritiesProvider) CompositeSystemAuthoritiesProvider(org.hisp.dhis.security.authority.CompositeSystemAuthoritiesProvider) AppsSystemAuthoritiesProvider(org.hisp.dhis.security.authority.AppsSystemAuthoritiesProvider) CachingSystemAuthoritiesProvider(org.hisp.dhis.security.authority.CachingSystemAuthoritiesProvider) SchemaAuthoritiesProvider(org.hisp.dhis.security.authority.SchemaAuthoritiesProvider) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Aggregations

Primary (org.springframework.context.annotation.Primary)93 Bean (org.springframework.context.annotation.Bean)90 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)15 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)13 SQLException (java.sql.SQLException)10 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)10 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)7 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)6 DefaultTokenServices (org.springframework.security.oauth2.provider.token.DefaultTokenServices)6 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)4 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)4 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)3 LocalDateSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer)3 LocalDateTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer)3 LocalTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer)3 XmAuthenticationContext (com.icthh.xm.commons.security.XmAuthenticationContext)3 XmAuthenticationContextHolder (com.icthh.xm.commons.security.XmAuthenticationContextHolder)3 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)3