The properties Module
Table of Contents
Introduction
The properties
module provides a service (InputModule) to configure
publications using properties. The idea is to have a fallback of properties.
Sample
<properties> <property name="pubs.default.author" value="Miguel de Cervantes Saavedra"/> </properties>
Order of precedence
note
The first values set get precedence, as in AntProperties
- Publication (lazy loaded in loadPublicationPropertiesIfNotDone())
- Lenya local
- Modules (all modules, not only the ones referenced in the publication)
- Lenya
Locations
- {pubDir}/lenya.properties.xml
- $LENYA_HOME/src/webapp/local.lenya.properties.xml
- {module}/lenya.properties.xml
- $LENYA_HOME/src/webapp/lenya.properties.xml
Usage
To activate your properties you need to save the above sample file in one of the above locations.
- Publication - on a publication level you are able to implement all properties and override all possible default ones.
- Lenya local - use this for global properties for all your lenya based pubs
- Modules - modules can use properties to allow user to override module specific properties.
- Lenya - global default properties
sitemap.xmap
Since the properties module is a cocoon input module, you can use it as any other input module.
... <map:transform src="cocoon:/getDoctypeXSLT/{4}"> <map:parameter name="author" value="{properties:pubs.default.author}"/> ... </map:transform>
java
In your custom cocoon components use like follows.
InputModule inputModule = null; ServiceSelector selector = null; String propKey = "pubs.default.author"; try { selector = (ServiceSelector) m_manager.lookup(InputModule.ROLE + "Selector"); inputModule = (InputModule) selector.select("properties"); String propValue = (String) inputModule.getAttribute(propKey, null, objectModel) ...