Sono consapevole del fatto che la seguente implementazione di un PropertyPlaceholderConfigurer è possibile:Primavera: livello di programmazione utilizzare PropertyPlaceholderConfigurer su nessuno Fagioli singelton
public class SpringStart {
public static void main(String[] args) throws Exception {
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
Properties properties = new Properties();
properties.setProperty("first.prop", "first value");
properties.setProperty("second.prop", "second value");
configurer.setProperties(properties);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
context.addBeanFactoryPostProcessor(configurer);
context.setConfigLocation("spring-config.xml");
context.refresh();
TestClass testClass = (TestClass)context.getBean("testBean");
System.out.println(testClass.getFirst());
System.out.println(testClass.getSecond());
}}
Con questo nel file di configurazione:
<?xml version="1.0" encoding="UTF-8"?>
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd ">
<bean id="testBean" class="com.spring.ioc.TestClass">
<property name="first" value="${first.prop}"/>
<property name="second" value="${second.prop}"/>
</bean>
Tuttavia, questo mi sembra che le modifiche apportate al testBean verranno visualizzate su tutti i bean di test.
Come si utilizza propertyPlaceHolderCongfigurer in modo tale che sia possibile applicarlo a singole istanze del bean e avere accesso a ciascuna di queste istanze?
Spero che la domanda abbia un senso. Qualsiasi aiuto sarebbe molto apprezzato.
Prima festeggio voglio solo confermare che premendo il pulsante context.refresh solito aggiornare le istanze passate di questo fagiolo? – Babyangle86
Sì, non lo farebbe. – axtavt
Brillante. Grazie. – Babyangle86