Hello folks,
i have a strange idea...
i would like define the used dao-implementation in a maven-profile ...
a example:
spring-dao.xml:
spring-services.xml:Code:<bean id="remoteDao" class="de.ahoehma.dao.Remote" scope="session"> <aop:scoped-proxy /> <property name="profile"value="${dao_profile}" /> </bean> <bean id="localDao" class="de.ahoehma.dao.Local" scope="session"> <aop:scoped-proxy /> <property name="profile" value="${dao_profile}"/> <property name="license" value="/db/123456.TXT"/> </bean>
imagine there are more dao-implementations possible ... so i would *not* include every possible dao-impl into my dao.xml.Code:<bean id="FoobarService" class="de.ahoehma.service.FoobarService"> <property name="dao" ref="${daoImpl}"/> </bean>
so how can i define "dynamic" the real bean for "${daoImpl}"?
I want create the war-file (i have a j2ee app) with a simple maven-call:
mvn package -Pdao-local
or
mvn package -Pdao-remote
or
mvn package -Pdao-whatever
in the maven-profiles i would define the dao which should be used:
then maven can filter my propertie-files, e.g. a dao.properties:Code:<profile> <id>dao-local</id> <properties> <dao-impl>localDao</dao-impl> </properties> </profile> <profile> <id>dao-remote</id> <properties> <dao-impl>remoteDao</dao-impl> </properties> </profile>
so a spring PropertyPlaceholderConfigurer can read the property "daoImpl".Code:daoImpl=${dao-impl}
but here is the problem "i can use a placeholder for a bean-ref" :-(
ref="${daoImpl}" is not possible
any ideas?
regards
andreas


...
Reply With Quote

