Carsten Ziegeler wrote:
So my idea was to start simple and extend the functionality if needed.
First step was to always include all configurations, the next step will
be to disable this. I'll update the code today.
Ok, forget most of the stuff I said above, you can disable the inclusion
by specifying the "readFromClasspath" attribute on the settings element:
<configurator:settings readFromClasspath="false"/>
I was thinking about something different:
1. Sometimes I do not need to automatically include all application
contexts from META-INF/cocoon/spring/*, because I do specify them
manually...
2. ... Still I would like to use property overrider and it's running modes.
Example: unit tests, I do not need any cocoon components (even do not
want to instantiate them because of prolonged test runs). Even so my
beans need properties and running profiles.
I am using a separate context file outside META-INF/cocoon/spring for
unit tests:
<?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.0.xsd">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations"
value="classpath*:META-INF/cocoon/properties/*.properties"/>
</bean>
</beans>
I cannot use running mode like this, and even trying to emulate it:
<?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.0.xsd">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations"
value="classpath*:META-INF/cocoon/properties/*.properties"/>
</bean>
<bean id="placeholderConfigDev"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations"
value="classpath*:META-INF/cocoon/properties/dev/*.properties"/>
</bean>
</beans>
simply does not work. Spring behaves like the second
PropertyPlaceholderConfigurer is not there.
The perfect situation for me would be to have a
ProfileAwarePropertyPlaceholderConfigurer that could be used like that:
<bean id="placeholderConfig"
class="org.apache.cocoon.spring.ProfileAwarePropertyPlaceholderConfigurer">
<property name="runningMode" value="${org.apache.cocoon.mode}"/>
</bean>
and running the application with -Dorg.apache.cocoon.mode=dev
Is there any chance that this functionality could be separated? It would
be even better if this code was directly ported to spring framework.
--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.