Can I use property placeholders in Jetty-env.xml?

maven-3, maven-jetty-plugin, spring

Solution

You can define environment variables and use the Env tag as a placeholder.

<New id="dsDatasource" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg>jdbc/dsProtWb</Arg>
    <Arg>
        <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">net.sourceforge.jtds.jdbc.Driver</Set>
            <Set name='url'>jdbc:jtds:sqlserver://ROPFDN812Q:4900/dlmp_proteomics_wb_dev;instance=FDNDEV18;domain=mfad</Set>
            <Set name="username"><Env name="LANID"/></Set>
            <Set name="password"><Env name="LANPW"/></Set>
        </New>
    </Arg>
</New>

Problem

I am working on a project that uses jetty-env.xml to define some resources in the test environment. It requires that I hijack it and put in my username and password for the resources. Is there a way to define my credentials in an external way and use a property placeholder instead? Like in the Spring applicationConfig.xml I can use ${username} as defined in my system properties. ``` <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure id="wac" class="org.mortbay.jetty.webapp.WebAppContext"> <New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>mail/exampleMail</Arg> <Arg> <New class="org.mortbay.naming.factories.MailSessionReference"> <Set name="user"></Set> <Set name="password"></Set> <Set name="properties"> <New class="java.util.Properties"> <Put name="mail.smtp.host">mail.example.edu</Put> </New> </Set> </New> </Arg> </New> <New id="datasource" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jdbc/DataSource</Arg> <Arg> <New class="com.sybase.jdbc3.jdbc.SybDataSource"> <Set name="databaseName">example</Set> <Set name="serverName">testip.example.edu:2025</Set> <Set name="portNumber">2025</Set> <Set name="user">username</Set> <!-- put username here --> <Set name="password">password</Set> <!-- put password here --> </New> </Arg> </New> ``` I new to these tools so I might be closer to an answer than I think. Any help would be appreciated. Enviroment: Spring Tool Suite 3.4.0 RELEASE Maven 3 Jetty Plugin 6.1 Spring 3

Original source