Dear All,
Recently I discovered that Tomcat has support for using system properties in server.xml. This feature made deployment easier for me, since now I can use the exact same server.xml file on my test machines as on the production box.
Let me give one example of how this feature helped move to a single server.xml for all environment. I am sure that you can find many more. I use a mod_proxy_http connector to delegate the work from Apache to Tomcat. Here is what it used to look like:
Code:
<!-- Define an HTTP Apache mod_proxy_http connector -->
<Connector port="8081" proxyPort="80" proxyName="java-monitor.com" enableLookups="false" maxThreads="256" />
In the server.xml for my test machine I had the exact same definition, except that the proxyName was different. Just for this one little difference I had to maintain a separate server.xml for test and for production.
By using a system property instead I can now specify the domain to use for the proxyName from the command line. Server.xml now looks like this:
Code:
<!-- Define an HTTP Apache mod_proxy_http connector -->
<Connector port="8081" proxyPort="80" proxyName="${javamonitor.domain}" enableLookups="false" maxThreads="256" />
I was already using the system property javamonitor.domain for internal configuration of the Java-monitor monitoring system. So this properly has been set to the domain name for a long time already.
I can imagine many other uses for this, such as setting port numbers or specifying log folders for the access log valve. All things that typically change between test and production.
This feature is documented on the
Tomcat configuration reference page, as the second paragraph. No wonder I never read it.
It states:
Quote:
|
The Tomcat configuration files support Apache Ant style variable substitution. A system property with the name propname may be used in a configuration file using the syntax ${propname}. All system properties are available including those set using the -D syntax, those automatically made available by the JVM and those configured in the $CATALINA_BASE/conf/catalina.properties file.
|
Kees Jan