I am trying to achieve the following use case:
* Each configuration for a module is located in a default location (e.g. META-INF/foo/project-core-beans.xml)
* If the configuration needs external settings, a default value is provided
* The application configuration can override some of these settings if the defaulting does not work (quite handy if defaulting works).
So far I have this for my project-core-beans.xml
In com/foo/project-core-config.properties I have thisCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/com/foo/project-core-config.properties</value> </list> </property> <property name="ignoreUnresolvablePlaceholders" value="true"/> </bean> <bean name="fooManager" class="com.foo.FooManagerImpl"> <property name="dataSource" ref="dataSource"/> <property name="incrementer" ref="stagingItemIncrementer"/> </bean> <bean id="stagingItemIncrementer" parent="incrementerParent"> <property name="incrementerName" value="STAGING_ITEM_SEQ"/> </bean> <!-- Structure to define the right incrementer based on the target database --> <bean id="sequenceIncrementerParent" class="${batch.database.incrementer.class}" abstract="true"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="columnIncrementerParent" class="${batch.database.incrementer.class}" abstract="true" parent="sequenceIncrementerParent"> <property name="columnName" value="OBJECTID"/> </bean> <bean id="incrementerParent" parent="${batch.database.incrementer.parent}"> <property name="incrementerName" value="DUMMY"/> </bean> </beans>
The idea is that if I start the component without any config, it starts up with H2. but if in my main _applicationContext.xml_ I can do something like:Code:batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.H2SequenceMaxValueIncrementer batch.database.incrementer.parent=sequenceIncrementerParent
and use the same config with explicit config (and not the default values anymore)Code:<context:property-placeholder location="classpath:/batch-mysql.properties"/>
how can I achieve this? I am using 2.5.6


Reply With Quote