Search in sources :

Example 31 with Primary

use of org.springframework.context.annotation.Primary in project dhis2-core by dhis2.

the class DhisWebApiWebSecurityConfig method tokenServices.

@Bean("defaultTokenService")
@Primary
public DefaultTokenServices tokenServices() {
    final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore(tokenStore());
    defaultTokenServices.setSupportRefreshToken(true);
    return defaultTokenServices;
}
Also used : DefaultTokenServices(org.springframework.security.oauth2.provider.token.DefaultTokenServices) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 32 with Primary

use of org.springframework.context.annotation.Primary in project dhis2-core by dhis2.

the class WebMvcConfig method mvcContentNegotiationManager.

@Primary
@Bean
@Override
public ContentNegotiationManager mvcContentNegotiationManager() {
    CustomPathExtensionContentNegotiationStrategy pathExtensionNegotiationStrategy = new CustomPathExtensionContentNegotiationStrategy(mediaTypeMap);
    pathExtensionNegotiationStrategy.setUseRegisteredExtensionsOnly(true);
    return new ContentNegotiationManager(Arrays.asList(pathExtensionNegotiationStrategy, new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
}
Also used : ContentNegotiationManager(org.springframework.web.accept.ContentNegotiationManager) FixedContentNegotiationStrategy(org.springframework.web.accept.FixedContentNegotiationStrategy) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) CustomPathExtensionContentNegotiationStrategy(org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 33 with Primary

use of org.springframework.context.annotation.Primary in project grails-core by grails.

the class MimeTypesConfiguration method mimeTypes.

@Bean("mimeTypes")
@Primary
protected MimeType[] mimeTypes() {
    final Config config = grailsApplication.getConfig();
    final Map<CharSequence, Object> mimeConfig = getMimeConfig(config);
    MimeType[] mimeTypes;
    if (mimeConfig == null || mimeConfig.isEmpty()) {
        mimeTypes = MimeType.createDefaults();
        return mimeTypes;
    } else {
        List<MimeType> mimes = new ArrayList<>();
        for (Map.Entry<CharSequence, Object> entry : mimeConfig.entrySet()) {
            final String key = entry.getKey().toString();
            final Object v = entry.getValue();
            if (v instanceof List) {
                List list = (List) v;
                for (Object i : list) {
                    mimes.add(new MimeType(i.toString(), key));
                }
            } else {
                mimes.add(new MimeType(v.toString(), key));
            }
        }
        final List<MimeTypeProvider> mimeTypeProviders = this.mimeTypeProviders;
        processProviders(mimes, mimeTypeProviders);
        final Map<String, MimeTypeProvider> childTypes = applicationContext.getBeansOfType(MimeTypeProvider.class);
        processProviders(mimes, childTypes.values());
        mimeTypes = mimes.toArray(new MimeType[0]);
        return mimeTypes;
    }
}
Also used : Config(grails.config.Config) ArrayList(java.util.ArrayList) MimeType(grails.web.mime.MimeType) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) MimeTypeProvider(grails.web.mime.MimeTypeProvider) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 34 with Primary

use of org.springframework.context.annotation.Primary in project new-cloud by xie-summer.

the class ResourceServerConfiguration method tokenServices.

@Bean
@Primary
public DefaultTokenServices tokenServices() {
    final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore(tokenStore());
    defaultTokenServices.setTokenEnhancer(accessTokenConverter());
    return defaultTokenServices;
}
Also used : DefaultTokenServices(org.springframework.security.oauth2.provider.token.DefaultTokenServices) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 35 with Primary

use of org.springframework.context.annotation.Primary in project new-cloud by xie-summer.

the class DruidDbConfig method dataSource.

/**
 * @return 声明其为Bean实例
 * 在同样的DataSource中,首先使用被标注的DataSource
 */
@Bean
@Primary
public DataSource dataSource() {
    DruidDataSource datasource = new DruidDataSource();
    datasource.setUrl(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)

Aggregations

Primary (org.springframework.context.annotation.Primary)87 Bean (org.springframework.context.annotation.Bean)84 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)14 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