/
XML replacements
XML replacements
Definition
The XML replacements option allows you to modify XML files of your container's configuration using XPath statements.This feature is only available for standalone local containers, and does work with the Cargo Daemon since version 1.4.12.
Explanation
In some cases, it is necessary to modify XML files of your container. This can be done using Cargo's xmlReplacements
option, accessible via the Cargo APIs.
You might for example want to modify the defaultHost
for your Tomcat instance.
Example using the Java API
LocalContainer container = ...; StandaloneLocalConfiguration configuration = (StandaloneLocalConfiguration) getLocalContainer().getConfiguration(); XmlReplacement defaultHost = new XmlReplacement(); defaultHost.setFile("conf/server.xml"); defaultHost.setXpathExpression("//Server/Engine"); defaultHost.setAttributeName("defaultHost"); defaultHost.setValue("myhost"); configuration.addXmlReplacement(defaultHost);
Some notes:
- The
attributeName
parameter is optional -if you don't specify it, then Cargo will replace directly the value of the node - If the
value
corresponds to an existing configuration property (such ascargo.hostname
for example) then Cargo will reuse it from the configuration - Finally, there is another parameter
ignoreIfNonExisting
which, when set toTRUE
, will make the XML replacement tool ignore if that specific XPath doesn't exist in the XML file
Example using the ANT tasks
<cargo containerId="@{containerId}" action="@{action}"> <configuration home="${configuration.home}"> <xmlreplacement file="conf/server.xml" xpathexpression="//Server/Engine" attributename="defaultHost" value="myhost"/> </configuration> </cargo>
Example using the Maven 3 plugin
<plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven3-plugin</artifactId> <configuration> <container> [...] </container> <configuration> <type>standalone</type> [...] <xmlReplacements> <xmlReplacement> <file>conf/server.xml</file> <xpathExpression>//Server/Engine</xpathExpression> <attributeName>defaultHost</attributeName> <value>myhost</value> </xmlReplacement> </xmlReplacements> </configuration> </configuration> </plugin>
, multiple selections available,
Related content
Configuration files option
Configuration files option
More like this
Ant Tasks Reference Guide
Ant Tasks Reference Guide
More like this
Existing Local Configuration
Existing Local Configuration
More like this
Custom File Configurations
Custom File Configurations
More like this
Custom Configuration
Custom Configuration
More like this
Adding a container
Adding a container
More like this