loading table of contents...

4.1.3.3. Application Artifacts

An application artifact is a WAR (web application) file that is ready to be deployed in a servlet container. It consists of one or more component and library artifacts as well as a small layer of code or configuration that glues the components together. Web resources such as image or CSS files might be either directly contained in application artifacts or might be bundled below /META-INF/resources inside a shared library or component artifact.

Application artifacts may contain the following files to configure its components:

  • /WEB-INF/web.xml: Servlet 3.0 web application deployment descriptor, may declare a load order for component web fragments and additional servlet filters, listeners, etc.

  • /WEB-INF/application.xml: Contains additional Spring configuration which is required by the application and not provided by components.

  • /WEB-INF/application.properties: Configures components packaged with the application. Values set here override any default application and component configuration in /WEB-INF/application.xml and /META-INF/coremedia/component-<componentname>.properties.

  • /WEB-INF/logback.xml: Logback configuration file for this application. If this file is present, it will override the default log configuration. Any custom log configuration file should include logging-common.xml, which defines appenders "file" and "console" and sets the name and location of the log file:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <configuration scan="true" scanPeriod="30 seconds">
    
      <include resource="logging-common.xml"/>
    
      <!-- define loggers here, for example: -->
    
      <logger name="com.coremedia" additivity="false" level="info">
        <appender-ref ref="file"/>
      </logger>
    
      <root level="warn">
        <appender-ref ref="file"/>
      </root>
    
    </configuration>

    Example 4.2. Including logback-common.xml


    See Section 4.3.7.1, “The Logging Component” for additional information.

You can specify additional properties files by defining a comma-separated list of paths in a System or JNDI property with the name propertieslocations.

Application properties are loaded from the following sources, from the highest to the lowest precedence:

  • System properties: Useful for overriding a property value on the command-line. The actual property name must be prefixed with "coremedia.application." when set as a system property:

    $ mvn '-Dcoremedia.application.management.server.remote.url=
                  service:jmx:jmxmp://localhost:6666' tomcat7:run

  • JNDI context: Allows deployers to override application properties without modifying the WAR artifact. Object names must be prefixed with "coremedia/application/". For instance, to set the property management.server.remote.url via the JNDI context, its value may be added to the application environment in the application's /WEB-INF/web.xml or in Tomcat's context configuration:

    <env-entry>
      <env-entry-name>
        coremedia/application/management.server.remote.url
      </env-entry-name>
      <env-entry-value>
        service:jmx:jmxmp://localhost:6666
      </env-entry-value>
      <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

    Example 4.3. Setting an environment property in web.xml


    <Context>
      <!-- ... -->
    
      <Environment
        name="coremedia/application/management.server.remote.url"
        value="service:jmx:jmxmp://localhost:6666"
        type="java.lang.String"
        override="true"/>
    
      <!-- ... -->
    </Context>

    Example 4.4. Setting an environment property in the context configuration


  • /WEB-INF/application.properties: Build-time configuration of application properties.

  • /WEB-INF/component-*.properties: Like application.properties, but allows grouping of properties by component.

  • classpath:/META-INF/coremedia/component-*.properties: Default component configurations provided by the author of the component. These files should not be modified to configure components for use in a particular application. Instead, their values should be overridden in the application artifact in the files /WEB-INF/component-*.properties or /WEB-INF/application.properties.