Search in sources :

Example 76 with Primary

use of org.springframework.context.annotation.Primary in project nifi-registry by apache.

the class IdentityProviderFactory method getIdentityProvider.

@Bean
@Primary
public IdentityProvider getIdentityProvider() throws Exception {
    if (identityProvider == null) {
        // look up the login identity provider to use
        final String loginIdentityProviderIdentifier = properties.getProperty(NiFiRegistryProperties.SECURITY_IDENTITY_PROVIDER);
        // ensure the login identity provider class name was specified
        if (StringUtils.isNotBlank(loginIdentityProviderIdentifier)) {
            final IdentityProviders loginIdentityProviderConfiguration = loadLoginIdentityProvidersConfiguration();
            // create each login identity provider
            for (final Provider provider : loginIdentityProviderConfiguration.getProvider()) {
                identityProviders.put(provider.getIdentifier(), createLoginIdentityProvider(provider.getIdentifier(), provider.getClazz()));
            }
            // configure each login identity provider
            for (final Provider provider : loginIdentityProviderConfiguration.getProvider()) {
                final IdentityProvider instance = identityProviders.get(provider.getIdentifier());
                instance.onConfigured(loadLoginIdentityProviderConfiguration(provider));
            }
            // get the login identity provider instance
            identityProvider = getIdentityProvider(loginIdentityProviderIdentifier);
            // ensure it was found
            if (identityProvider == null) {
                throw new Exception(String.format("The specified login identity provider '%s' could not be found.", loginIdentityProviderIdentifier));
            }
        }
    }
    return identityProvider;
}
Also used : IdentityProviders(org.apache.nifi.registry.security.authentication.generated.IdentityProviders) SensitivePropertyProtectionException(org.apache.nifi.registry.properties.SensitivePropertyProtectionException) JAXBException(javax.xml.bind.JAXBException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SAXException(org.xml.sax.SAXException) SensitivePropertyProvider(org.apache.nifi.registry.properties.SensitivePropertyProvider) Provider(org.apache.nifi.registry.security.authentication.generated.Provider) Primary(org.springframework.context.annotation.Primary) DisposableBean(org.springframework.beans.factory.DisposableBean) Bean(org.springframework.context.annotation.Bean)

Example 77 with Primary

use of org.springframework.context.annotation.Primary in project litemall by linlinjava.

the class JacksonConfig method objectMapper.

@Bean
@Primary
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
    JavaTimeModule javaTimeModule = new JavaTimeModule();
    javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
    javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
    ObjectMapper objectMapper = builder.createXmlMapper(false).build();
    objectMapper.registerModule(javaTimeModule);
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return objectMapper;
}
Also used : LocalTimeSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) LocalDateSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer) LocalDateTimeSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 78 with Primary

use of org.springframework.context.annotation.Primary in project litemall by linlinjava.

the class JacksonConfig method objectMapper.

@Bean
@Primary
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
    JavaTimeModule javaTimeModule = new JavaTimeModule();
    javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
    javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
    ObjectMapper objectMapper = builder.createXmlMapper(false).build();
    objectMapper.registerModule(javaTimeModule);
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return objectMapper;
}
Also used : LocalTimeSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) LocalDateSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer) LocalDateTimeSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 79 with Primary

use of org.springframework.context.annotation.Primary in project springBoot-learn-demo by nbfujx.

the class DruidOneConfig method SqlSessionFactoryOne.

// 创建Session
@Primary
@Bean
public SqlSessionFactory SqlSessionFactoryOne() throws Exception {
    final SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSourceOne());
    Resource[] resource = new PathMatchingResourcePatternResolver().getResources(DruidOneConfig.MAPPER_LOCATION);
    sqlSessionFactoryBean.setMapperLocations(resource);
    return sqlSessionFactoryBean.getObject();
}
Also used : Resource(org.springframework.core.io.Resource) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) Primary(org.springframework.context.annotation.Primary) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 80 with Primary

use of org.springframework.context.annotation.Primary in project goci by EBISPOT.

the class DepositionSyncApp method getObjectMapper.

@Bean(name = "JodaMapper")
@Primary
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule()).configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false).configure(SerializationFeature.INDENT_OUTPUT, true).setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) 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