com.ecyrd.jspwiki
Class PropertyReader

java.lang.Object
  extended by com.ecyrd.jspwiki.PropertyReader

public final class PropertyReader
extends Object

Property Reader for the WikiEngine. Reads the properties for the WikiEngine and implements the feature of cascading properties and variable substitution, which come in handy in a multi wiki installation environment: It reduces the need for (shell) scripting in order to generate different jspwiki.properties to a minimum.

Since:
2.5.x
Author:
Christoph Sauer

Field Summary
static String DEFAULT_PROPERTYFILE
          Path to the default property file.
static String PARAM_PROPERTYFILE
          The servlet context parameter (from web.xml) that defines where the config file is to be found.
static String PARAM_PROPERTYFILE_CASCADEPREFIX
          The prefix when you are cascading properties.
 
Method Summary
static void expandVars(Properties properties)
          You define a property variable by using the prefix "var.x" as a property.
static Properties getDefaultProperties()
          Returns the default property set as a Properties object.
static Properties loadWebAppProps(ServletContext context)
          Loads the webapp properties based on servlet context information, or (if absent) based on teh Java System Property PARAM_PROPERTYFILE .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_PROPERTYFILE

public static final String PARAM_PROPERTYFILE
The servlet context parameter (from web.xml) that defines where the config file is to be found. If it is not defined, checks the Java System Property, if that is not defined either, uses the default as defined by DEFAULT_PROPERTYFILE. "/WEB-INF/jspwiki.properties"

See Also:
Constant Field Values

PARAM_PROPERTYFILE_CASCADEPREFIX

public static final String PARAM_PROPERTYFILE_CASCADEPREFIX
The prefix when you are cascading properties.

See Also:
loadWebAppProps(ServletContext), Constant Field Values

DEFAULT_PROPERTYFILE

public static final String DEFAULT_PROPERTYFILE
Path to the default property file. "/WEB-INF/jspwiki.properties"

See Also:
Constant Field Values
Method Detail

loadWebAppProps

public static Properties loadWebAppProps(ServletContext context)
Loads the webapp properties based on servlet context information, or (if absent) based on teh Java System Property PARAM_PROPERTYFILE . Returns a Properties object containing the settings, or null if unable to load it. (The default file is WEB-INF/jspwiki.properties, and can be overridden by setting PARAM_PROPERTYFILE in the server or webapp configuration.)

Cascading Properties

You can define additional property files and merge them into the default properties file in a similar process to how you define cascading style sheets; hence we call this cascading property files. This way you can overwrite the default values and only specify the properties you need to change in a multiple wiki environment.

You define a cascade in the context mapping of your servlet container.

  jspwiki.properties.cascade.1
  jspwiki.properties.cascade.2
  jspwiki.properties.cascade.3
  
and so on. You have to number your cascade in a descending way starting with "1". This means you cannot leave out numbers in your cascade. This method is based on an idea by Olaf Kaus, see [JSPWiki:MultipleWikis].

Parameters:
context - A Servlet Context which is used to find the properties
Returns:
A filled Properties object with all the cascaded properties in place

getDefaultProperties

public static final Properties getDefaultProperties()
Returns the default property set as a Properties object.

Returns:
The default property set.

expandVars

public static void expandVars(Properties properties)
You define a property variable by using the prefix "var.x" as a property. In property values you can then use the "$x" identifier to use this variable. For example you could declare a base directory for all your files like this and use it in all your other property definitions with a "$basedir". Note that it does not matter if you define the variable before its usage.
  var.basedir = /p/mywiki;
  jspwiki.fileSystemProvider.pageDir =         $basedir/www/
  jspwiki.basicAttachmentProvider.storageDir = $basedir/www/
  jspwiki.workDir =                            $basedir/wrk/
  

Parameters:
properties - - properties to expand;