I would like to update the content of my context.xml and web.xml files based on the value of property files. I want to setup database connections the can be used by my web app. Is it possible to add thhis content in a dynamic way?
I currently have some updating going on using the following build section in my POM
<build>
<finalName>ROOT</finalName>
<filters>
<filter>src/main/resources/environmentProperties/env1.properties</filter>
<filter>src/main/resources/environmentProperties/env2.properties</filter>
<filter>src/main/resources/environmentProperties/env3.properties</filter>
<filter>src/main/resources/environmentProperties/env4.properties</filter>
</filters>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin-version}</version>
<configuration>
<webResources>
<resource>
<directory>${basedir}\src\main\resources\META-INF</directory>
<filtering>true</filtering>
<targetPath>META-INF</targetPath>
<includes>
<include>**\context.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
In my web.xml file I have the following
<resource-ref>
<description>Env1 Database Connection</description>
<res-ref-name>jdbc/Env1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Env2 Database Connection</description>
<res-ref-name>jdbc/Env2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Env3 Database Connection</description>
<res-ref-name>jdbc/Env3</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Env4 Database Connection</description>
<res-ref-name>jdbc/Env4</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I would really prefer to be able to have as many properties files as required in the environmentProperties folder and then update the web.xml (and context.xml) files to add the appropriate entries for each environment. Is this possible.
I have seen Apache Velocity do looping constructs, but don't know if there is a Maven plugin to allow me to utilise this.
Thanks, Paul