cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Updated: Basic Configuration
Date Thu, 11 Jan 2007 08:49:06 GMT
A document has been updated:

Document ID: 1303
Branch: main
Language: default
Name: Basic Configuration (previously The Spring Configurator)
Document Type: Cocoon Document (unchanged)
Updated on: 1/11/07 8:48:53 AM
Updated by: Carsten Ziegeler

A new version has been created, state: publish


This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 1495 bytes (previous version: 10710 bytes)
Content diff:
--- <h1>The Cocoon Spring Configurator</h1>
--- <p>The Spring Configurator is a useful component providing support in common
--- configuration issues when using the Spring framework. Although this product has
--- been developed inside the Cocoon project, it is aimed at making easier the usage
--- of Spring in each and every web application; it is not tied to the famous Cocoon
--- web application framework and can be used standalone. The impact on your code is
--- nearly zero and the Spring Configurator as only Spring itself as a dependency.
--- </p>
--- <h2>Motivation</h2>
--- <p>When using a framework like Spring there are always the same problems to
--- solve, like</p>
--- <ul>
--- <li>Where do I store my bean configurations?</li>
--- <li>How can I parameterize them dynamically?</li>
--- <li>Where do I store these extra information?</li>
--- <li>How can I handle different environments like a testing environment, a
--- development environment and a production environment?</li>
--- <li>How can I distribute not only code but also corresponding configurations?
--- </li>
--- <li>How can I distribute partial web applications?</li>
--- <li>How do I manage hierarchial web application contexts?</li>
--- </ul>
--- <p>Of course Spring is flexible enough to enable solutions to the above
--- problems, but you have to do it and implement it for your solution. And there is
--- more than one way of doing this and each and every project ends up developing
--- its own "proprietary" solution. A best practice and a standardized way of doing
--- these things would be great. And guess what, the Spring Configurator is the
--- answer to your problems. Like Maven has standardized the build process, the
--- Spring Configurator standardizes the way of dealing with various configuration
--- issues with Spring. Ok, enough motivation, let's see what the Spring
--- configurator can provide for your work.</p>
--- <h2>Requirements</h2>
--- <p>The Spring Configurator requires</p>
--- <ul>
--- <li>the Spring Framework Version 2.0.1 (or above)</li>
--- <li>JDK 1.4 (or above)</li>
--- <li>Servlet API 2.3 (or above)</li>
--- </ul>
--- <p>The Spring Configuration requires two additional jar files, the Cocoon
--- Configuration API and the Cocoon Spring Configurator, which you can either
--- download here or from a public Maven repository by adding the Spring
--- Configurator as a dependency to your project:</p>
--- <p><strong>TODO - Show dependency configuration</strong></p>
    <p>The Spring Configurator uses the Spring the
(24 equal lines skipped)
    <p>And then...</p>
--- <h2>Running Modes</h2>
--- <p>The configurator provides the support of <em>running modes</em>.
A running
--- mode defines the environment the application is currently running in. For
--- example this can be during development, a test setup or production. As you will
--- see in just some paragraphs, the configurator can use different configurations
--- and settings depending on the running mode.</p>
--- <p>A running mode is just a unique text key, like <tt>dev</tt>, <tt>test</tt>
--- or <tt>prod</tt>. This key is used to determine the correct configuration
--- runtime. Although you can use any text key, it is advisable to use one of the
--- standard keys (dev, test or prod).</p>
--- <p>The running mode can be set in two ways: you can either set it in your
--- <tt>applicationContext.xml</tt> as a configuration for the <tt>settings
--- </tt>element:</p>
--- <pre>   &lt;!-- Activate Cocoon Spring Configurator --&gt;
---    &lt;configurator:settings runningMode="test"/&gt;
--- </pre>
--- <p>Or you can define the running mode by setting the system property
--- <tt>org.apache.cocoon.mode</tt> on startup of your web application, usually
--- do this by specifying <tt>-Dorg.apache.cocoon.mode=test</tt> when starting
--- application server. The system property has precedence over the value from the
--- application context. The default running mode is <tt>prod</tt>.</p>
--- <h2>Property Configurations</h2>
--- <p>For using properties in your configuration files, Spring provides the
--- <a href="">property
--- placeholder configurer</a> which you have to configure in your application
--- context. The Spring Configurator has already built-in support for replacing
--- property values in configuration files, so there is no additional work required
--- anymore. In addition the Configurator reads properties from various standard
--- locations.</p>
--- <p>In general, the Configurator works with directories containing property files
--- and supports two areas where these directories can be located: somewhere in the
--- classpath or in some directory in your web application. While the first area is
--- very convenient for distributing properties within libraries, the second area is
--- very easy to edit by administrators or developers.</p>
--- <p>Let's start with the full list of actions taken by the Spring Configurator to
--- read in properties. During this process, various property files are read. If
--- there is more than one definiton for a property, the last definition wins!</p>
--- <ol>
--- <li>The classpath is scanned for property files inside jar files located at
--- <tt>/META-INF/cocoon/properties/*.properties.</tt> Usually these property
--- are default values for beans distributed with the jar the property files are
--- contained in. All these property files are read in alphabetical order.</li>
--- <li>All property files located at
--- <tt>/WEB-INF/classes/META-INF/cocoon/properties/*.properties</tt> are read
--- alphabetical order.</li>
--- <li>The classpath is scanned for property files inside jar files located at
--- <tt>/META-INF/cocoon/properties/[RUNNING_MODE]/*.properties.</tt> Usually
--- property files are default values in the given running mode for beans
--- distributed with the jar the property files are contained in. All these property
--- files are read in alphabetical order.</li>
--- <li>All property files located at
--- <tt>/WEB-INF/classes/META-INF/cocoon/properties/[RUNNING_MODE]/*.properties</tt>
--- are read in alphabetical order.</li>
--- <li>All property files from <tt>/WEB-INF/cocoon/properties/*.properties</tt>
--- are read in alphabetical order.</li>
--- <li>All property files from
--- <tt>/WEB-INF/cocoon/properties/[RUNNING_MODE]/*.properties</tt> are read in
--- alphabetical order.</li>
--- <li>If the home directory of the current user contains a
--- <tt>.cocoon/</tt> file, this is read next.</li>
--- <li>If the system property <tt>org.apache.cocoon.settings</tt> is specified
--- points to a property file, this is read. If the system property points to a
--- directory all property files from this directory are read in alphabetical order
--- and all property files from the sub directory named [RUNNING_MODE] are read in
--- alphabetical order.</li>
--- <li>If a property provider (see below) is configured in the application context,
--- it is queried for a set of properties.</li>
--- <li>Read additional configured properties from the settings configuration in the
--- application context.</li>
--- <li>Apply additional configured properties from the settigns configuration in
--- the application context.</li>
--- <li>Apply system properties.</li>
--- </ol>
--- <p>Although this list might look very scary, it is in fact a very simple but
--- powerful approach:</p>
--- <ul>
--- <li>If you want to use properties within your configurations, make sure to
--- supply a default value through a property file which is stored in the jar
--- containing your components.</li>
--- <li>If you want to provide default values for different running modes, add these
--- configurations to your jar as well.</li>
--- <li>If you want to override default configurations, put them either in your own
--- jar file and make sure that the name of your property file comes after the
--- default configuration file in alphabetical order, or put your property file in
--- /<tt>WEB-INF/classes/META-INF/cocoon/properties.</tt></li>
--- <li>If you want to override a default configuration depending on a running mode,
--- add a property file at the same location as before but put it in a sub directory
--- with the name of the running mode.</li>
--- <li>To override properties globally, e.g. through an administrator, put the
--- properties at <tt>/WEB-INF/cocoon/properties</tt> or
--- <tt>/WEB-INF/cocoon/[RUNNING_MODE]/properties</tt>.</li>
--- <li>If you want to change a configuration value during development you can just
--- set it as a system property. (You can also add a property file with the values
--- or define your own running mode of course.)</li>
--- <li>If you have special requirements for property handling, you can add a
--- property provider bean which is a Spring managed bean conforming to the
--- <tt>org.apache.cocoon.configuration.PropertyProvider</tt> interface. For
--- example, if you want to store your configurations inside a database or configure
--- them through a jndi context, you can provide these values through a custom
--- implementation.</li>
--- </ul>
--- <h2>Configuring Log4j</h2>
--- <p>You can use the Configurator to
--- configure <a href="">Log4j</a> through an
--- configuration file:</p>
--- <pre>  &lt;bean name="org.apache.cocoon.spring.configurator.log4j"
---         class="org.apache.cocoon.spring.configurator.log4j.Log4JConfigurator"
---         scope="singleton"&gt;
---     &lt;property name="resource" value="/WEB-INF/cocoon/log4j.xconf"/&gt;
---   &lt;/bean&gt;
--- </pre>
--- <p>The property <tt>resource</tt> should point to a valid Log4j XML
--- configuration file. You can use all properties configured through the
--- Configurator in the XML configuration and reference the actual values.</p>

View raw message