SourceForge.net Logo

de.mindmatters.faces.spring.config
Class ConfigLoader

java.lang.Object
  extended byde.mindmatters.faces.spring.config.ConfigLoader

public class ConfigLoader
extends java.lang.Object

Performs the actual initialization work for the jsf-spring-config root application context. Called by ConfigLoaderListener and ConfigLoaderServlet.

Looks for the context-param faces.spring.configClass to determine the context class type, falling back to the default implementation of (ConfigWebApplicationContext if not found. With the default ConfigLoader implementation, any context class specified needs to implement ConfigWebApplicationContext.

Passes the context-param faces.spring.CONFIG_FILES to the context instance, parsing it into potentially multiple file paths which can be separated by any number of commas and spaces, like "applicationContext1.xml, applicationContext2.xml". If not explicitly specified, the context implementation is supposed to use a default location ("/WEB-INF/faces-spring-config.xml").

Above and beyond loading the faces root application context, this class tries to obtain and hook up a shared parent context to the faces root application context. See the loadParentContext(ServletContext) method for more information.

Author:
Andreas Kuhrwahl
See Also:
ContextLoaderListener, ContextLoaderServlet, DefaultFacesWebApplicationContext

Field Summary
static java.lang.String CONFIG_CLASS_PARAM
          Config param for the JSF configuration application context implementation class ConfigWebApplicationContext to use: faces.spring.configClass.
static java.lang.String CONFIG_LOCATION_PARAM
          Context initialization parameter name for a comma delimited list of context-relative resource paths (which is loaded automatically if it exists) containing faces-spring-config configuration information: faces.spring.CONFIG_FILES.
protected  org.apache.commons.logging.Log logger
          For logging.
 
Constructor Summary
ConfigLoader()
           
 
Method Summary
 void closeConfigWebApplicationContext(javax.servlet.ServletContext servletContext)
          Closes the jsf-spring-config web application context for the given servlet context.
protected  void closeParentApplicationContext(javax.servlet.ServletContext servletContext, ApplicationContext parent)
          Closes the parent web application context of jsf-spring-config web application context for the given servlet context.
protected  ConfigWebApplicationContext createConfigWebApplicationContext(javax.servlet.ServletContext servletContext, ApplicationContext parent)
          Creates and returns a ConfigWebApplicationContext.
protected  java.lang.Class determineContextClass(javax.servlet.ServletContext servletContext)
          Returns the WebApplicationContext implementation class to use, either the default ConfigWebApplicationContext or a custom context class if specified.
 ConfigWebApplicationContext initConfigWebApplicationContext(javax.servlet.ServletContext servletContext)
          Initialize jsf-spring-config web application context for the given servlet context, regarding the faces.spring.configClass and faces.spring.CONFIG_FILES context-params.
protected  ApplicationContext loadParentContext(javax.servlet.ServletContext servletContext)
          Loads and returns a root parent application context for the ConfigWebApplicationContext (usually an xml context based on the "spring-beans" DTD).
protected  java.lang.String[] resolveConfigLocations(ResourceLoader resourceLoader, javax.servlet.ServletContext servletContext)
          Returns a list with Strings identifying the faces-spring-config configuration file resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
For logging.


CONFIG_CLASS_PARAM

public static final java.lang.String CONFIG_CLASS_PARAM
Config param for the JSF configuration application context implementation class ConfigWebApplicationContext to use: faces.spring.configClass.

See Also:
Constant Field Values

CONFIG_LOCATION_PARAM

public static final java.lang.String CONFIG_LOCATION_PARAM
Context initialization parameter name for a comma delimited list of context-relative resource paths (which is loaded automatically if it exists) containing faces-spring-config configuration information: faces.spring.CONFIG_FILES.

See Also:
Constant Field Values
Constructor Detail

ConfigLoader

public ConfigLoader()
Method Detail

initConfigWebApplicationContext

public final ConfigWebApplicationContext initConfigWebApplicationContext(javax.servlet.ServletContext servletContext)
Initialize jsf-spring-config web application context for the given servlet context, regarding the faces.spring.configClass and faces.spring.CONFIG_FILES context-params.

Parameters:
servletContext - current servlet context
Returns:
the new ConfigWebApplicationContext
Throws:
BeansException - if the context couldn't be initialized
See Also:
CONFIG_CLASS_PARAM, CONFIG_LOCATION_PARAM

loadParentContext

protected ApplicationContext loadParentContext(javax.servlet.ServletContext servletContext)
Loads and returns a root parent application context for the ConfigWebApplicationContext (usually an xml context based on the "spring-beans" DTD).

Parameters:
servletContext - the servlet context
Returns:
a parent ApplicationContext
Throws:
BeansException - in cases of errors
See Also:
ContextLoader

createConfigWebApplicationContext

protected ConfigWebApplicationContext createConfigWebApplicationContext(javax.servlet.ServletContext servletContext,
                                                                        ApplicationContext parent)
Creates and returns a ConfigWebApplicationContext.

Parameters:
servletContext - the servlet context
parent - parent application context
Returns:
a new ConfigWebApplicationContext
Throws:
BeansException - in cases of errors

determineContextClass

protected final java.lang.Class determineContextClass(javax.servlet.ServletContext servletContext)
Returns the WebApplicationContext implementation class to use, either the default ConfigWebApplicationContext or a custom context class if specified.

Parameters:
servletContext - current servlet context
Returns:
the WebApplicationContext implementation class to use
Throws:
ApplicationContextException - if the context class couldn't be loaded
See Also:
CONFIG_CLASS_PARAM

resolveConfigLocations

protected final java.lang.String[] resolveConfigLocations(ResourceLoader resourceLoader,
                                                          javax.servlet.ServletContext servletContext)
Returns a list with Strings identifying the faces-spring-config configuration file resources.

Parameters:
resourceLoader - the ResourceLoader to use for loading config locations
servletContext - the servlet context
Returns:
the resolved config locations
Throws:
BeansException - in cases of errors
See Also:
CONFIG_LOCATION_PARAM

closeConfigWebApplicationContext

public final void closeConfigWebApplicationContext(javax.servlet.ServletContext servletContext)
Closes the jsf-spring-config web application context for the given servlet context.

Parameters:
servletContext - the servlet context

closeParentApplicationContext

protected void closeParentApplicationContext(javax.servlet.ServletContext servletContext,
                                             ApplicationContext parent)
Closes the parent web application context of jsf-spring-config web application context for the given servlet context. If overriding loadParentContext(ServletContext), you may have to override this method as well.

Parameters:
servletContext - the servlet context
parent - parent ApplicationContext

SourceForge.net Logo

Copyright © 2002 mindmatters GmbH & Co. KG