cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Configuration
Date Tue, 27 Jun 2006 14:05:32 GMT
A new document has been created.

Document ID: 1162
Branch: main
Language: default
Name: Configuration
Document Type: Cocoon Document
Created: 6/27/06 2:05:17 PM
Creator (owner): Carsten Ziegeler
State: publish


Mime type: text/xml
Size: 3220 bytes

<h1>Property Configuration</h1>

<p>Cocoon comes with a smart configuration mechanism based on property files.
The configuration of Cocoon (or more precisely of the components) is based on
XML files for the various components. To customize these configuration files
without changing the files itself you can define properties to which you can
refer to from within the configuration files (and sitemaps).</p>

<p>You can define as many property files and define your own properties as you
want. Store them in the WEB-INF/properties directory and Cocoon will read all of
them on startup in alphabetical order. If two files provide values for the same
property, the last definition wins. Please note that any changes you make to the
property files will not be reflected during runtime. The changes will take
effect, the next time you startup the Cocoon web application.</p>

<p>You can then refer to the values of a property by using the common
${PROPERTY_NAME} syntax in your configuration file or sitemap.</p>

<h1>Running modes</h1>

<p>Cocoon extends the property based configuration mechanism by "running
modes". You define a running mode when you start Cocoon (default is "dev"). The
name of the running mode is used to read additional property files on startup.
Cocoon reads first all property files from "WEB-INF/properties" and then from

<p>For example if you have different database connections during development and
in production, just put a properties file containing the connection information
for development in the "WEB-INF/properties/dev" directory and put another
property file with the production settings in "WEB-INF/properties/prod". (Of
course think about security issues regarding this information - you might not
want that a developer knows the database configuration of the production

<p>You can easily set the running mode by setting the system property
"org.apache.cocoon.mode" on startup of Cocoon, for example:<br/>

<p>Note, that "dev" and "prod" are not predefined modes, they are just names.
This means you can use any name you want, e.g. you can create a "myenv"
directory underneath the properties directory and set the running mode to
"myenv" etc.</p>

<h1>Properties and Sitemaps</h1>

<p>As explained above, you can simply refer to a value of a property within a
sitemap. In addition a sitemap can have a set of own properties which are only
available to this sitemap (and the components defined in this sitemap) and all
sub sitemaps. This mechanism is a replacement for the deprecated global

<p>By default each sitemap tries to read properties from within the directory
the sitemap is in, looking into these two directories: "config/properties" and
"config/properties/${RUNNING_MODE}. If you don't want to use these default
locations, you can specify the attribute "" with a value of "false" at the
map:components element in the sitemap.</p>

<h1>Properties and Java Code</h1>

<p>If you need access to the defined properties within your Java code, just
lookup the Settings bean. This bean provides access to all available properties.


The document belongs to the following collections: documentation

View raw message