[Major] Refactored StrolchConfiguration.xml to use environments

Now the agent requires an environment parameter to start, and the
configuration of that environment is used to load different sections of
the configuration file

Conflicts:
	src/main/java/li/strolch/tutorialwebapp/StartupListener.java
This commit is contained in:
Robert von Burg 2014-08-13 23:39:30 +02:00
parent a6341da79b
commit a05f6c10dd
2 changed files with 149 additions and 115 deletions

81
pom.xml
View File

@ -76,6 +76,15 @@
<build> <build>
<finalName>${warFinalName}</finalName> <finalName>${warFinalName}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/componentVersion.properties</include>
</includes>
</resource>
</resources>
<plugins> <plugins>
@ -90,33 +99,43 @@
<configuration> <configuration>
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${warFinalName}</warName> <warName>${warFinalName}</warName>
<webResources>
<resource>
<directory>src/main/non-packaged-resources</directory>
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>**/ENV.properties</include>
</includes>
</resource>
</webResources>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <!-- <plugin> -->
<artifactId>maven-dependency-plugin</artifactId> <!-- <artifactId>maven-dependency-plugin</artifactId> -->
<executions> <!-- <executions> -->
<execution> <!-- <execution> -->
<id>install-jar</id> <!-- <id>install-jar</id> -->
<phase>package</phase> <!-- <phase>package</phase> -->
<goals> <!-- <goals> -->
<goal>copy</goal> <!-- <goal>copy</goal> -->
</goals> <!-- </goals> -->
<configuration> <!-- <configuration> -->
<artifactItems> <!-- <artifactItems> -->
<artifactItem> <!-- <artifactItem> -->
<groupId>${project.groupId}</groupId> <!-- <groupId>${project.groupId}</groupId> -->
<artifactId>${project.artifactId}</artifactId> <!-- <artifactId>${project.artifactId}</artifactId> -->
<version>${project.version}</version> <!-- <version>${project.version}</version> -->
<type>war</type> <!-- <type>war</type> -->
<outputDirectory>${project.build.directory}</outputDirectory> <!-- <outputDirectory>${project.build.directory}</outputDirectory> -->
<destFileName>${project.artifactId}-${project.version}.war</destFileName> <!-- <destFileName>${project.artifactId}-${project.version}.war</destFileName> -->
</artifactItem> <!-- </artifactItem> -->
</artifactItems> <!-- </artifactItems> -->
</configuration> <!-- </configuration> -->
</execution> <!-- </execution> -->
</executions> <!-- </executions> -->
</plugin> <!-- </plugin> -->
<plugin> <plugin>
<!-- Publish to Tomcat7: mvn tomcat7:redeploy --> <!-- Publish to Tomcat7: mvn tomcat7:redeploy -->
@ -131,4 +150,18 @@
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>m2e</id>
<!-- This profile is only activated when building in Eclipse with m2e -->
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<strolch.env>dev</strolch.env>
</properties>
</profile>
</profiles>
</project> </project>

View File

@ -23,6 +23,7 @@ public class StartupListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) { public void contextInitialized(ServletContextEvent sce) {
String realPath = sce.getServletContext().getRealPath("/WEB-INF"); String realPath = sce.getServletContext().getRealPath("/WEB-INF");
File pathF = new File(realPath); File pathF = new File(realPath);
String environment = StrolchEnvironment.getEnvironmentFromEnvProperties(pathF); String environment = StrolchEnvironment.getEnvironmentFromEnvProperties(pathF);
logger.info("Starting Agent..."); logger.info("Starting Agent...");