List of usage examples for org.springframework.beans.factory.config PropertyPlaceholderConfigurer PropertyPlaceholderConfigurer
PropertyPlaceholderConfigurer
From source file:net.dfs.remote.main.ClientServicesStarter.java
public final void loadNode() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setProperties(props);/* w w w . ja va 2 s. c o m*/ context.addBeanFactoryPostProcessor(configurer); context.setConfigLocation("net\\dfs\\remote\\filestorage\\spring-client.xml"); context.refresh(); context.start(); /* FileLocationTrackerImpl hash = new FileLocationTrackerImpl(); hash.removeAll(); */ log.info("Client Started"); FileReceiverSupport receiveFile = (FileReceiverSupport) context.getBean("receiveFile"); receiveFile.connectJavaSpace(); receiveFile.retrieveFile(); }
From source file:org.drools.container.spring.beans.persistence.VariablePersistenceStrategyTest.java
@Before public void createSpringContext() { try {// ww w . j a v a 2 s.c om log.info("creating spring context"); PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); Properties properties = new Properties(); properties.setProperty("temp.dir", TMPDIR); configurer.setProperties(properties); ctx = new ClassPathXmlApplicationContext(); ctx.addBeanFactoryPostProcessor(configurer); ctx.setConfigLocation("org/drools/container/spring/beans/persistence/beansVarPersistence.xml"); ctx.refresh(); } catch (Exception e) { log.error("can't create spring context", e); throw new RuntimeException(e); } }
From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.TestListWrapper.java
protected void setUp() throws Exception { loadJdbcProps();//w w w . ja v a2 s. c o m ClassPathResource resource = new ClassPathResource("viewService.xml"); XmlBeanFactory factory = new XmlBeanFactory(resource); PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(); cfg.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_OVERRIDE"); cfg.setProperties(jdbcProps); cfg.postProcessBeanFactory(factory); repo = (RepositoryService) factory.getBean("repoService"); }
From source file:es.galvarez.rest.config.SpringConfiguration.java
@Bean public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); ppc.setLocation(new ClassPathResource(DATASOURCE_FILE)); return ppc;/* w ww . j a v a 2 s . co m*/ }
From source file:guru.qas.martini.jmeter.config.DefaultApplicationContextBuilder.java
protected void setEnvironment(ConfigurableApplicationContext context, Properties properties) { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setProperties(properties); configurer.setLocalOverride(true);//from w ww . jav a 2 s. c om configurer.setSearchSystemEnvironment(true); configurer.setSystemPropertiesMode(SYSTEM_PROPERTIES_MODE_FALLBACK); context.addBeanFactoryPostProcessor(configurer); }
From source file:com.logsniffer.app.CoreAppConfig.java
/** * Returns a general properties placeholder configurer based on * {@link #logSnifferProperties()}./*from w ww .j ava 2s.c om*/ * * @param props * autowired logSnifferProperties bean * @return A general properties placeholder configurer. * @throws IOException */ @Bean @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Autowired public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer( @Qualifier(BEAN_LOGSNIFFER_PROPS) final Properties props) throws IOException { final PropertyPlaceholderConfigurer c = new PropertyPlaceholderConfigurer(); c.setIgnoreResourceNotFound(true); c.setIgnoreUnresolvablePlaceholders(true); c.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE); c.setProperties(props); return c; }
From source file:org.drools.container.spring.beans.persistence.JPASingleSessionCommandServiceFactoryTest.java
@Before public void createSpringContext() { try {//from ww w . jav a 2s.c o m log.info("creating spring context"); PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); Properties properties = new Properties(); properties.setProperty("temp.dir", TMPDIR); configurer.setProperties(properties); ctx = new ClassPathXmlApplicationContext(); ctx.addBeanFactoryPostProcessor(configurer); ctx.setConfigLocation("org/drools/container/spring/beans/persistence/beans.xml"); ctx.refresh(); } catch (Exception e) { log.error("can't create spring context", e); throw new RuntimeException(e); } }
From source file:com.miserablemind.butter.bootstrap.RootContext.java
/** * PropertyPlaceholderConfigurer is required to make {@code @Value} annotations work. * {@code @Value} annotations are used to wire data from .properties files. * * @return {@link PropertyPlaceholderConfigurer}. *//*from w w w . ja va2s . c o m*/ @Bean public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); Resource[] propertiesFiles = new Resource[] { new ClassPathResource("system.properties"), new ClassPathResource("butterApp/butterApp.properties") }; configurer.setLocations(propertiesFiles); return configurer; }
From source file:org.activiti.crystalball.simulator.TwoEnginesWithoutProcessTest.java
@Test public void test() throws Exception { String tempDir = "target"; FileUtils.copyFile(//from w w w.j a v a 2 s . c o m FileUtils.getFile( new String[] { (new StringBuilder()).append(LIVE_DB).append(".h2.db").toString() }), FileUtils.getFile( new String[] { (new StringBuilder()).append(tempDir).append("/simulationRunDB-aaa-") .append(Thread.currentThread().getId()).append(".h2.db").toString() })); System.setProperty("_SIM_DB_PATH", (new StringBuilder()).append(tempDir).append("/simulationRunDB-aaa-") .append(Thread.currentThread().getId()).toString()); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( "/org/activiti/crystalball/simulator/SimRun-h2-context.xml"); PropertyPlaceholderConfigurer propConfig = new PropertyPlaceholderConfigurer(); Properties properties = new Properties(); properties.put("simulationRunId", "simulationRunDB-aaa-" + Thread.currentThread().getId()); propConfig.setProperties(properties); appContext.addBeanFactoryPostProcessor(propConfig); appContext.refresh(); SimulationRun simRun = (SimulationRun) appContext.getBean(SimulationRun.class); String userId = "user1"; TaskService taskService = (TaskService) appContext.getBean("taskService"); TaskService simTaskService = (TaskService) appContext.getBean("simTaskService"); List<Task> liveTaskList = ((TaskQuery) taskService.createTaskQuery().taskCandidateUser(userId) .orderByTaskPriority().desc()).listPage(0, 1); List<Task> execTaskList = ((TaskQuery) simTaskService.createTaskQuery().taskCandidateUser(userId) .orderByTaskPriority().desc()).listPage(0, 1); Assert.assertTrue(liveTaskList.size() == execTaskList.size()); IdentityService identityService = (IdentityService) appContext.getBean("identityService"); IdentityService simIdentityService = (IdentityService) appContext.getBean("simIdentityService"); List<User> users = identityService.createUserQuery().list(); List<User> simUsers = simIdentityService.createUserQuery().list(); Assert.assertTrue(users.size() == simUsers.size()); simRun.execute(new Date(), null); appContext.close(); }
From source file:org.openspaces.itest.persistency.cassandra.archive.CassandaraArchiveOperationHandlerTest.java
private void xmlTest(String relativeXmlName) { final boolean refreshNow = false; final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { relativeXmlName }, refreshNow); PropertyPlaceholderConfigurer propertyConfigurer = new PropertyPlaceholderConfigurer(); Properties properties = new Properties(); properties.put("cassandra.keyspace", server.getKeySpaceName()); properties.put("cassandra.hosts", server.getHost()); properties.put("cassandra.port", "" + server.getPort()); properties.put("cassandra.write-consistency", "ALL"); propertyConfigurer.setProperties(properties); context.addBeanFactoryPostProcessor(propertyConfigurer); context.refresh();//from w ww . ja v a 2s . c o m try { final CassandraArchiveOperationHandler archiveHandler = context .getBean(CassandraArchiveOperationHandler.class); Assert.assertEquals(CassandraConsistencyLevel.ALL, archiveHandler.getWriteConsistency()); final GigaSpace gigaSpace = context.getBean(org.openspaces.core.GigaSpace.class); test(archiveHandler, gigaSpace); } finally { context.close(); } }