Good evening,
I am running Jetty on CentOS 7 Linux with the following command:
/usr/bin/java -Djdbc.drivers=org.postgresql.Driver -jar /usr/share/java/jetty-distribution-9.4.18.v20190429/start.jar jetty.home=/usr/share/java/jetty-distribution-9.4.18.v20190429 jetty.base=/var/www/jetty-base-ru jetty.http.host=127.0.0.1 jetty.http.port=8080
It serves a Wordpress web site + a small WAR servlet programmed by me:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "
http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/ws</Set>
<Set name="virtualHosts">
<Array type="java.lang.String">
<Item>
blah.com</Item>
<Item>
www.blah.com</Item>
</Array>
</Set>
<Set name="war"><SystemProperty name="jetty.base"/>/webapps/ws-servlet-0.1-SNAPSHOT.war</Set>
</Configure>
This works well for since over a year, thank you so much.
However now a need has emerged to run several instances of the WAR configured with different values at the runtime (like database credentials and FCM/Amazon ids and secrets).
I understand that I could pass them as environment variables before starting Jetty with the above command and then read them with System.getenv(...).
However I would prefer a "less global" way to configure just my servlet during the runtime...
What would be the XML syntax please and how to access those values from Java source code?
Best regards
Alex