Skip to content

Sources of the JWS tomcat extension properties Listener.

License

Notifications You must be signed in to change notification settings

web-servers/LoadExternalPropertiesListener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LoadExternalPropertiesListener

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.

building

mvn install
cp target/LoadExternalPropertiesListener-1.0-SNAPSHOT.jar ${CATALINA_BASE}/lib

Configuration in server.xml

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:

attribute name="file.N" required="true"

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>

attribute name="overwrite" required="false"

Controls if previously defined system properties may be ovewritten. The default behavior is true, allowing for overwriting system properties.

attribute name="loadFirst" required="false"

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.

example

  1. 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" />
  1. Add the following to conf/catalina.properties:
org.apache.tomcat.util.digester.REPLACE_SYSTEM_PROPERTIES=true
tomcat.http.port=8081
  1. Add the following to conf/test0.properties:
tomcat.ajp.port=8010
  1. Add the following to conf/test1.properties:
tomcat.http.port=8082
tomcat.ajp.port=8011
  1. Test tomcat it should run AJP on 8011 and HTTP/1.1 on 8082

About

Sources of the JWS tomcat extension properties Listener.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages