Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

TODO

Definition

Excerpt

The configuration files are the files to add to your container's configuration. It is internally used by some containers and is accessible for you can to add extra files.

Info

This feature is only available for local containers (i.e., not for remote containers nor any kind of deployers).

Explanation

In some cases, it is necessary to enrich your container configuration with extra files. This can be done using Cargo's configFiles option, accessible via the Cargo APIs.

The advantage of using this option is that it can replace configuration properties in your files: simply use, for example, @cargo.servlet.port@ to have it replaced with the port on which the Servlet/JSP container is listening to.

Note
titleCareful with binary files!

If you want to inject binary configuration files (JAR files, for example), you should use setFileProperty (instead of setConfigFileProperty) with the Java API and <files> and <file> (instead of <configfiles> and <configfile>) with the Maven2/Maven3 plugin.

You might for example want to add the advanced login configuration to your JBoss instance.

Example using the Java API

Info

The method's name is setConfigFileProperty rather than addConfigFileProperty; but it actually adds files to the configFiles list.

Code Block
languagejava
LocalContainer container = ...;
StandaloneLocalConfiguration configuration = (StandaloneLocalConfiguration) getLocalContainer().getConfiguration();

FileConfig loginConfigXml = new FileConfig();
loginConfigXml.setConfigfile("src/main/jboss5/login-config.xml");
loginConfigXml.setToDir("conf");
configuration.setConfigFileProperty(loginConfigXml);

FileConfig sampleRolesProperties = new FileConfig();
sampleRolesProperties.setConfigfile("src/main/jboss5/sample-roles.properties");
sampleRolesProperties.setToDir("conf");
configuration.setConfigFileProperty(sampleRolesProperties);

FileConfig sampleUsersProperties = new FileConfig();
sampleUsersProperties.setConfigfile("src/main/jboss5/sample-users.properties");
sampleUsersProperties.setToDir("conf");
configuration.setConfigFileProperty(sampleUsersProperties);

Example using the ANT tasks

Code Block
languagehtml/xml
<cargo containerId="@{containerId}" action="@{action}">
  <configuration home="${configuration.home}">
    <configfile file="${basedir}/src/main/jboss5/login-config.xml" todir="conf"/>
    <configfile file="${basedir}/src/main/jboss5/sample-roles.properties" todir="conf/props"/>
    <configfile file="${basedir}/src/main/jboss5/sample-users.properties" todir="conf/props"/>
  </configuration>
</cargo>

Example using the Maven 2 plugin

Code Block
languagehtml/xml
<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <configuration>
    <container>
      [...]
    </container>
    <configuration>
      <type>standalone</type>
      [...]
      <configfiles>
        <configfile>
          <file>${project.basedir}/src/main/jboss5/login-config.xml</file>
          <todir>conf</todir>
        </configfile>
        <configfile>
          <file>${project.basedir}/src/main/jboss5/sample-roles.properties</file>
          <todir>conf/props</todir>
        </configfile>
        <configfile>
          <file>${project.basedir}/src/main/jboss5/sample-users.properties</file>
          <todir>conf/props</todir>
        </configfile>
      </configfiles>
    </configuration>
  </configuration>
</plugin>