Hi Thanks for sharing this. Nice to see improvements in 3.1 and 3.2 of Spring in regard to property placeholders and environment settings and whatnot. And hopefully someday they open up so this is accessible for 3rd party namespace handlers. So we can have seamless Spring property placeholder integration.
People can vote on this. But don't write something about Camel, it's a competitor project to their own Spring projects. http://jira.springframework.org/browse/SPR-4466 On Thu, Nov 8, 2012 at 11:35 PM, pberkman <[email protected]> wrote: > I found a reasonable solution: > > 1) upgrade to Spring 3.1.3.RELEASE > > 2) Implement a Context Initializer Class: > a) create a wrapper for your properties file (mine is just a static > singleton for a PropertiesFile). > b) create SpringContextInitializer: > > public class SpringContextInitializer implements > ApplicationContextInitializer<ConfigurableWebApplicationContext> { > > private static final transient Logger LOG = > LoggerFactory.getLogger(SpringContextInitializer.class); > > public void initialize(ConfigurableWebApplicationContext ctx) { > > LOG.trace("SpringContextInitializer: initialize"); > > ctx.getEnvironment().getPropertySources().addFirst(new > SpringContextInitializerPropertySource("NGMSPropertiesRoute")); > } > } > > c) Implement a SpringContextInitializerPropertySource: > > public class SpringContextInitializerPropertySource extends > PropertySource<NGMSPropertiesRoute> { > > private static final transient Logger LOG = > LoggerFactory.getLogger(SpringContextInitializerPropertySource.class); > > public SpringContextInitializerPropertySource(String name) { > super(name); > } > > @Override > public Object getProperty(String name) { > > String val = > PropertiesFactory.getPropertiesFactory().getRouteProperties().getProperty(name, > null); > > LOG.trace("Spring asked for property: {}, returning: {}", > name, val); > > return val; > } > } > > 3) Configure the web.xml file to use your context initializer: > > <context-param> > <param-name>contextInitializerClasses</param-name> > <param-value>com.mycompany.SpringContextInitializer</param-value> > </context-param> > > > and, now I can use property placeholder ANYWHERE - including the <import > resource="${myvariable.name}" /> > > The writeup on this from Spring is at: > http://blog.springsource.org/2011/02/15/spring-3-1-m1-unified-property-management/ > > Thanks! > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Bridge-Property-Loading-Order-tp5722306p5722378.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
