Search in sources :

Example 11 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project kylo by Teradata.

the class Inspections method inspect.

public Object inspect(String path, String inspectionsPath, String isDevMode, String projectVersion) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    Configuration config = new DefaultConfiguration(path, inspectionsPath, isDevMode, projectVersion);
    PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setLocation(new FileSystemResource(config.getServicesConfigLocation()));
    ppc.setIgnoreUnresolvablePlaceholders(true);
    ppc.setIgnoreResourceNotFound(false);
    ppc.postProcessBeanFactory(ctx.getBeanFactory());
    ppc.setEnvironment(ctx.getEnvironment());
    PropertySources sources = ppc.getAppliedPropertySources();
    sources.forEach(source -> ctx.getEnvironment().getPropertySources().addLast(source));
    ctx.scan("com.thinkbiganalytics.install.inspector.inspection", "com.thinkbiganalytics.hive.config", "com.thinkbiganalytics.spring");
    ctx.refresh();
    InspectionService service = ctx.getBean(InspectionService.class);
    return service.inspect(config);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PropertySources(org.springframework.core.env.PropertySources) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) FileSystemResource(org.springframework.core.io.FileSystemResource)

Example 12 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project kylo by Teradata.

the class JcrTestConfig method placeHolderConfigurer.

@Bean
public PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    final Properties properties = new Properties();
    properties.setProperty("security.entity.access.controlled", "true");
    final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setProperties(properties);
    return configurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Properties(java.util.Properties) Bean(org.springframework.context.annotation.Bean)

Example 13 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project kylo by Teradata.

the class TestSpringConfiguration method properties.

@Bean
public static PropertySourcesPlaceholderConfigurer properties() throws Exception {
    final PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    Properties properties = new Properties();
    properties.setProperty("nifi.remove.inactive.versioned.feeds", "true");
    propertySourcesPlaceholderConfigurer.setProperties(properties);
    return propertySourcesPlaceholderConfigurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) SpringEnvironmentProperties(com.thinkbiganalytics.spring.SpringEnvironmentProperties) Properties(java.util.Properties) Bean(org.springframework.context.annotation.Bean)

Example 14 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project alf.io by alfio-event.

the class ApplicationPropertiesConfiguration method propertyPlaceholder.

@Bean
@Profile("!" + Initializer.PROFILE_SPRING_BOOT)
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setLocation(new ClassPathResource("application.properties"));
    return configurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Example 15 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project alf.io by alfio-event.

the class BaseTestConfiguration method propConfig.

@Bean
public static PropertySourcesPlaceholderConfigurer propConfig() {
    Properties properties = new Properties();
    properties.put("alfio.version", "2.0-SNAPSHOT");
    properties.put("alfio.build-ts", ZonedDateTime.now(ZoneId.of("UTC")).minusDays(1).toString());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(out, true, Charset.defaultCharset());
    properties.list(pw);
    pw.flush();
    var configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setLocation(new ByteArrayResource(out.toByteArray()));
    return configurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Properties(java.util.Properties) PrintWriter(java.io.PrintWriter) Bean(org.springframework.context.annotation.Bean)

Aggregations

PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)29 Bean (org.springframework.context.annotation.Bean)18 ClassPathResource (org.springframework.core.io.ClassPathResource)7 Properties (java.util.Properties)5 YamlPropertiesFactoryBean (org.springframework.beans.factory.config.YamlPropertiesFactoryBean)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Resource (org.springframework.core.io.Resource)3 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)2 MutablePropertySources (org.springframework.core.env.MutablePropertySources)2 FileSystemResource (org.springframework.core.io.FileSystemResource)2 JndiPropertySource (org.springframework.jndi.JndiPropertySource)2 ArchaiusSpringPropertySource (com.kixeye.chassis.bootstrap.spring.ArchaiusSpringPropertySource)1 SpringEnvironmentProperties (com.thinkbiganalytics.spring.SpringEnvironmentProperties)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 lombok.val (lombok.val)1 CasServerProperties (org.apereo.cas.configuration.model.core.CasServerProperties)1 ReloadablePropertySource (org.finra.herd.dao.ReloadablePropertySource)1 Test (org.junit.jupiter.api.Test)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1