info.magnolia.init
Class MagnoliaServletContextListener

java.lang.Object
  extended by info.magnolia.init.MagnoliaServletContextListener
All Implemented Interfaces:
EventListener, javax.servlet.ServletContextListener
Direct Known Subclasses:
MgnlServletContextListener

@Singleton
public class MagnoliaServletContextListener
extends Object
implements javax.servlet.ServletContextListener

Magnolia main listener: reads initialization parameter from a properties file. The name of the file can be defined as a context parameter in web.xml. Multiple path, 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>
 

The ${servername} variable will be resolved to the full name obtained by using InetAddress.getLocalHost().getHostName(), which may also contain the server domain, depending on your server configuration/operating system. You can set the optional context parameter "magnolia.unqualified.server.name" to true if you prefer using the unqualified name (the server "server.domain.com" will be simply resolved as "server")

 <context-param>
   <param-name>magnolia.unqualified.server.name</param-name>
   <param-value>true</param-value>
 </context-param>
 
The following parameters are needed in the properties file:

Advance use: 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.

Author:
Fabrizio Giustina TODO : javadoc - update javadoc to reflect current code and point to references instead of duplicating.

Field Summary
static String DEFAULT_PLATFORM_COMPONENTS_CONFIG_LOCATION
           
static String PLATFORM_COMPONENTS_CONFIG_LOCATION_NAME
           
 
Constructor Summary
MagnoliaServletContextListener()
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent sce)
           
 void contextInitialized(javax.servlet.ServletContextEvent sce)
           
protected  ComponentProviderConfiguration getPlatformComponents()
           
protected  List<String> getPlatformComponentsResources()
          Returns a list of resources that contain platform components.
protected  ComponentProviderConfiguration getSystemComponents()
           
protected  String initRootPath(javax.servlet.ServletContext context)
          Deprecated. since 4.5, use or subclass MagnoliaInitPaths.
protected  String initServername(boolean unqualified)
          Deprecated. since 4.5, use or subclass MagnoliaInitPaths.
protected  String initWebappName(String rootPath)
          Deprecated. since 4.5, use or subclass MagnoliaInitPaths.
protected  void startServer()
           
protected  void stopServer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLATFORM_COMPONENTS_CONFIG_LOCATION_NAME

public static final String PLATFORM_COMPONENTS_CONFIG_LOCATION_NAME
See Also:
Constant Field Values

DEFAULT_PLATFORM_COMPONENTS_CONFIG_LOCATION

public static final String DEFAULT_PLATFORM_COMPONENTS_CONFIG_LOCATION
See Also:
Constant Field Values
Constructor Detail

MagnoliaServletContextListener

public MagnoliaServletContextListener()
Method Detail

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent sce)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent sce)
Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener

getPlatformComponents

protected ComponentProviderConfiguration getPlatformComponents()

getPlatformComponentsResources

protected List<String> getPlatformComponentsResources()
Returns a list of resources that contain platform components. Definitions for the same type will override giving preference to the last read definition. Checks for an init parameter in web.xml for an overridden location Subclasses can override this method to provide alternative strategies. The returned locations are used to find the resource on the class path.


getSystemComponents

protected ComponentProviderConfiguration getSystemComponents()

startServer

protected void startServer()

stopServer

protected void stopServer()

initWebappName

protected String initWebappName(String rootPath)
Deprecated. since 4.5, use or subclass MagnoliaInitPaths.


initRootPath

protected String initRootPath(javax.servlet.ServletContext context)
Deprecated. since 4.5, use or subclass MagnoliaInitPaths.


initServername

protected String initServername(boolean unqualified)
Deprecated. since 4.5, use or subclass MagnoliaInitPaths.



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