List of usage examples for org.springframework.context.support PropertySourcesPlaceholderConfigurer postProcessBeanFactory
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
If #setPropertySources is called, environment and local properties will be ignored.
From source file:de.thischwa.pmcms.conf.BasicConfigurator.java
private void init() { if (System.getProperty("data.dir") == null) throw new IllegalArgumentException("No data directory set!"); dataDir = new File(System.getProperty("data.dir")); if (!dataDir.exists()) throw new IllegalArgumentException( String.format("Data directory not found: %s", dataDir.getAbsolutePath())); // load and merge the properties loadProperties();/*from w ww . j ava 2s . c o m*/ // build special props String baseUrl = String.format("http://%s:%s/", props.get("pmcms.jetty.host"), props.get("pmcms.jetty.port")); props.setProperty("baseurl", baseUrl); props.setProperty("data.dir", dataDir.getAbsolutePath()); System.setProperty("content.types.user.table", new File(Constants.APPLICATION_DIR, "lib/content-types.properties").getAbsolutePath()); // init log4j LogManager.resetConfiguration(); PropertyConfigurator.configure(PropertiesTool.getProperties(props, "log4j")); Logger logger = Logger.getLogger(BasicConfigurator.class); logger.info("*** log4j initialized!"); // init the spring framework try { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.scan("de.thischwa.pmcms"); PropertySourcesPlaceholderConfigurer config = new PropertySourcesPlaceholderConfigurer(); config.setProperties(props); config.postProcessBeanFactory(ctx.getDefaultListableBeanFactory()); ctx.refresh(); context = ctx; logger.info("*** Spring initialized!"); PropertiesManager pm = context.getBean(PropertiesManager.class); pm.setProperties(props); } catch (Exception e) { throw new RuntimeException(e); } logger.info("*** Basic configuration successful done."); }