info.magnolia.init
Class DefaultMagnoliaPropertiesResolver

java.lang.Object
  extended by info.magnolia.init.DefaultMagnoliaPropertiesResolver
All Implemented Interfaces:
MagnoliaPropertiesResolver

@Singleton
public class DefaultMagnoliaPropertiesResolver
extends Object
implements MagnoliaPropertiesResolver

Resolves the paths of the properties files to load. The name of the file can be defined as a context parameter in web.xml. Multiple paths, comma separated, are supported (the first existing file in the list will be used), and the following variables will be used:

If no magnolia.initialization.file context parameter is set, the following default is assumed:

 <context-param>
   <param-name>magnolia.initialization.file</param-name>
   <param-value>
      WEB-INF/config/${servername}/${webapp}/magnolia.properties,
      WEB-INF/config/${servername}/magnolia.properties,
      WEB-INF/config/${webapp}/magnolia.properties,
      WEB-INF/config/default/magnolia.properties,
      WEB-INF/config/magnolia.properties
   </param-value>
 </context-param>
 

Advanced usage: deployment service

Using the ${servername} and ${webapp} properties you can easily bundle in the same webapp different set of configurations which are automatically applied dependending on the server name (useful for switching between development, test and production instances where the repository configuration need to be different) or the webapp name (useful to bundle both the public and admin log4j/jndi/bootstrap configuration in the same war). By default the initializer will try to search for the file in different location with different combination of servername and webapp: the default fallback directory will be used if no other environment-specific directory has been added.

The variables are provided by MagnoliaInitPaths.


Field Summary
protected static String DEFAULT_INITIALIZATION_PARAMETER
          Default value for the MAGNOLIA_INITIALIZATION_FILE parameter.
protected static String MAGNOLIA_INITIALIZATION_FILE
          Context parameter name.
 
Constructor Summary
DefaultMagnoliaPropertiesResolver(javax.servlet.ServletContext context, MagnoliaInitPaths initPaths)
           
 
Method Summary
protected  String getInitParameter(javax.servlet.ServletContext ctx, String name, String defaultValue)
           
protected  List<String> getLocations()
          Used in tests, potentially in subclasses.
 List<PropertySource> getSources()
          Returns the paths to load, TODO: in which order ?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAGNOLIA_INITIALIZATION_FILE

protected static final String MAGNOLIA_INITIALIZATION_FILE
Context parameter name. Value should be a comma-separated list of paths to look for properties files. Defaults to "WEB-INF/config/${servername}/${contextPath}/magnolia.properties,WEB-INF/config/${servername}/${webapp}/magnolia.properties,WEB-INF/config/${servername}/magnolia.properties,WEB-INF/config/${contextPath}/magnolia.properties,WEB-INF/config/${webapp}/magnolia.properties,WEB-INF/config/default/magnolia.properties,WEB-INF/config/magnolia.properties"

See Also:
Constant Field Values

DEFAULT_INITIALIZATION_PARAMETER

protected static final String DEFAULT_INITIALIZATION_PARAMETER
Default value for the MAGNOLIA_INITIALIZATION_FILE parameter.

See Also:
Constant Field Values
Constructor Detail

DefaultMagnoliaPropertiesResolver

@Inject
public DefaultMagnoliaPropertiesResolver(javax.servlet.ServletContext context,
                                                MagnoliaInitPaths initPaths)
Method Detail

getInitParameter

protected String getInitParameter(javax.servlet.ServletContext ctx,
                                  String name,
                                  String defaultValue)

getLocations

protected List<String> getLocations()
Used in tests, potentially in subclasses.


getSources

public List<PropertySource> getSources()
Description copied from interface: MagnoliaPropertiesResolver
Returns the paths to load, TODO: in which order ?

Specified by:
getSources in interface MagnoliaPropertiesResolver


Copyright © 2003-2014 Magnolia International Ltd.. All Rights Reserved.