Sources of the JWS tomcat extension properties Listener.
The Load External Properties Lifecycle Listener loads
properties files specified by the listener's file.N
attributes
in the server.xml.
mvn install
cp target/LoadExternalPropertiesListener-1.0-SNAPSHOT.jar ${CATALINA_BASE}/lib
Load External Properties Lifecycle Listen
The listener must be nested within a Server
element, and it is recommended that this listener be the first nested element in the Server
.
XML is processed in the order it appears, and defining this listener first allows properties to
be defined and used later in the file.
The following additional attributes are supported by the Load External Properties Lifecycle Listener:
External files to include. This is a special attribute that uses a dynamic name, allowing for up to 100 files include with values for N ranging from 0 to 99. Any values beyond 99 will result in files not being included and a warning being logged. These files will be loaded in order based on the index, N.
For example, you could add two file attributes to the listener such as:
<code>file.0="/path/to/file1.properties"
file.1="/path/to/file2.properties"</code>
Controls if previously defined system properties may be ovewritten. The default behavior is true
, allowing for overwriting system properties.
Determines if any specified external files will be loaded before the rest of server.xml
. The default is false
,
indicating that the contents of server.xml
will be loaded and procesed before external files.
- Configure the following in server.xml:
<Listener className="org.apache.catalina.core.LoadExternalPropertiesListener"
file.0="${catalina.base}/conf/test0.properties"
file.1="${catalina.base}/conf/test1.properties"
overwrite="true" loadFirst="true"/>
...
<Connector port="${tomcat.http.port}" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="${tomcat.ajp.port}" protocol="AJP/1.3" redirectPort="8443" />
- Add the following to conf/catalina.properties:
org.apache.tomcat.util.digester.REPLACE_SYSTEM_PROPERTIES=true
tomcat.http.port=8081
- Add the following to conf/test0.properties:
tomcat.ajp.port=8010
- Add the following to conf/test1.properties:
tomcat.http.port=8082
tomcat.ajp.port=8011
- Test tomcat it should run AJP on 8011 and HTTP/1.1 on 8082