Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.PropertyOverrideConfigurer


public class SpringConfiguration {
  private static final Logger log = LoggerFactory.getLogger(SpringConfiguration.class);

  @Bean
  public static PropertyOverrideConfigurer propertyOverride() {
    final PropertyOverrideConfigurer properties = new PropertyOverrideConfigurer();

    final String config = System.getProperty("config");
    if (config == null || config.isEmpty()) {
      log.error("No 'config' system property detected - ${artifactId} cannot start up.");
      throw new RuntimeException("No 'config' system property detected - ${artifactId} cannot start up.");
    }

    final File configFile = new File(config, "${artifactId}.properties");
    if (!configFile.exists() || !configFile.canRead()) {
      log.error("Attempted to load the ${artifactId} configuration file from {}/${artifactId}.properties, but either it does not exist or is not readable.", config);
      throw new RuntimeException(String.format("Attempted to load the ${artifactId} configuration file from %s/app.properties, but either it does not exist or is not readable.", config));
    }

    Resource location = new FileSystemResource(configFile);
    properties.setLocation(location);

    return properties;
  }
View Full Code Here


      }

      if (inputStream != null) {
        Properties properties = new Properties();
        properties.load(inputStream);
        PropertyOverrideConfigurer propertyOverrideConfigurer = new PropertyOverrideConfigurer();
        propertyOverrideConfigurer.setProperties(properties);
        kurentoApplicationContextInternalReference
            .addBeanFactoryPostProcessor(propertyOverrideConfigurer);
        inputStream.close();
      }
View Full Code Here

    runner.process();
    Thread.currentThread().setContextClassLoader(classLoader);
  }

  public GenericXmlApplicationContext createSpringContext(Properties props, ClassLoader classLoader) {
    PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
    poc.setIgnoreInvalidKeys(true);
    poc.setProperties(props);
    GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    context.getBeanFactory().setBeanClassLoader(classLoader);
    // System.out.println("Context class loader: " +
    // context.getClass().getClassLoader());
    context.setClassLoader(classLoader);
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.PropertyOverrideConfigurer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.