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

Point of entry for Magnolia CMS, initializes the component providers, starts logging, triggers loading of properties and finally delegates to ConfigLoader for completing initialization.

Component providers

When Magnolia starts up the first thing that happens is the creation of the platform component provider. It contains the essential singletons that constitutes the platform on which the rest of the system builds. These components are defined in a file called platform-components.xml, it's on the classpath in package /info/magnolia/init.

The location can be customized using a servlet context parameter called magnolia.platform.components.config.location. It's specified as a list of comma-separated files on the classpath. The files are loaded in the specified order allowing definitions to override definitions from earlier files.

 <context-param>
   <param-name>magnolia.platform.components.config.location</param-name>
   <param-value>/info/magnolia/init/platform-components.xml,/com/mycompany/custom-platform-components.xml</param-value>
 </context-param>
 

The platform components include the ModuleManager which is called by this listener to load the descriptors of all the modules present. Modules define additional components that are loaded into a second component provider called system.

When ConfigLoader takes over the initialization procedure it will create a third component provider called main which contain components defined in modules as belonging to the main component provider.

Property loading

Properties are loaded by an implementation of MagnoliaConfigurationProperties. It's configured as a platform component and is called by this class to do initialization. See DefaultMagnoliaPropertiesResolver and DefaultMagnoliaInitPaths for details on how to customize the default behavior.

Version:
$Id$
See Also:
ModuleManager, MagnoliaInitPaths, MagnoliaPropertiesResolver, DefaultMagnoliaPropertiesResolver, DefaultMagnoliaConfigurationProperties, DefaultMagnoliaInitPaths, ConfigLoader, Log4jConfigurer

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)
           
 void contextInitialized(javax.servlet.ServletContextEvent sce, boolean startServer)
           
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

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent sce,
                               boolean startServer)

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-2012 Magnolia International Ltd.. All Rights Reserved.