ch.elca.el4j.web.context
Class ModuleWebApplicationContext

java.lang.Object
  extended by org.springframework.core.io.DefaultResourceLoader
      extended by org.springframework.context.support.AbstractApplicationContext
          extended by org.springframework.context.support.AbstractRefreshableApplicationContext
              extended by org.springframework.context.support.AbstractRefreshableConfigApplicationContext
                  extended by org.springframework.web.context.support.AbstractRefreshableWebApplicationContext
                      extended by org.springframework.web.context.support.XmlWebApplicationContext
                          extended by ch.elca.el4j.web.context.ModuleWebApplicationContext
All Implemented Interfaces:
RefreshableModuleApplicationContext, BeanFactory, BeanNameAware, DisposableBean, HierarchicalBeanFactory, InitializingBean, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver, ThemeSource, ConfigurableWebApplicationContext, WebApplicationContext

public class ModuleWebApplicationContext
extends XmlWebApplicationContext
implements RefreshableModuleApplicationContext

This web application context behaves exactly the same way as Spring's XmlWebApplicationContext but uses a ResourcePatternResolver that preserves the order defined by the EL4J's module hierarchy. Further, it allows to define configuration locations that have to be included and those, that have to be excluded. This allows removing individual configuration files that are included using using wildcard notation.

Author:
Andreas Bur (ABU), Martin Zeltner (MZE)
See Also:
ModuleApplicationContext
File-location:
ModuleWebApplicationContext
Last check-in date:
2010-11-02 11:44:37 +0100 (Di, 02. Nov 2010) by swisswheel for revision 4204

Field Summary
protected static org.slf4j.Logger s_loggerEl4j
          This logger is used to print out some global debugging info.
 
Fields inherited from class org.springframework.web.context.support.XmlWebApplicationContext
DEFAULT_CONFIG_LOCATION, DEFAULT_CONFIG_LOCATION_PREFIX, DEFAULT_CONFIG_LOCATION_SUFFIX
 
Fields inherited from class org.springframework.context.support.AbstractApplicationContext
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME
 
Fields inherited from interface org.springframework.web.context.ConfigurableWebApplicationContext
APPLICATION_CONTEXT_ID_PREFIX, SERVLET_CONFIG_BEAN_NAME
 
Fields inherited from interface org.springframework.web.context.WebApplicationContext
CONTEXT_ATTRIBUTES_BEAN_NAME, CONTEXT_PARAMETERS_BEAN_NAME, ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_APPLICATION, SCOPE_GLOBAL_SESSION, SCOPE_REQUEST, SCOPE_SESSION, SERVLET_CONTEXT_BEAN_NAME
 
Fields inherited from interface org.springframework.context.ConfigurableApplicationContext
CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Constructor Summary
ModuleWebApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, javax.servlet.ServletContext servletContext, boolean mergeWithOuterResources)
          There is no parent app context.
ModuleWebApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, javax.servlet.ServletContext servletContext, boolean mergeWithOuterResources, ApplicationContext parent)
           Most specific resource last is set to false.
ModuleWebApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, javax.servlet.ServletContext servletContext, boolean mergeWithOuterResources, boolean mostSpecificResourceLast, boolean mostSpecificBeanDefinitionCounts)
          There is no parent app context.
ModuleWebApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, javax.servlet.ServletContext servletContext, boolean mergeWithOuterResources, boolean mostSpecificResourceLast, boolean mostSpecificBeanDefinitionCounts, ApplicationContext parent)
          Create a new ModuleApplicationContext with the given parent, loading the definitions from the given XML files in "inclusiveConfigLocations" excluded the XML files defined in "exclusiveConfigLocations".
 
Method Summary
protected  DefaultListableBeanFactory createBeanFactory()
          Override method createBeanFactory() in class AbstractRefreshableApplicationContext.
protected  void finishRefresh()
          Notify all ModuleApplicationListeners that context has been refreshed.
 String[] getExclusiveConfigLocations()
           
 String[] getInclusiveConfigLocations()
           
 Resource getResource(String location)
          
protected  ResourcePatternResolver getResourcePatternResolver()
          
 Resource[] getResources(String locationPattern)
          
protected  void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory)
          Not just method BeanFactoryPostProcessor.postProcessBeanFactory( ConfigurableListableBeanFactory) is invoked ordered but also the creation of the factory post processor beans!
 boolean isAllowBeanDefinitionOverriding()
           
 boolean isMergeWithOuterResources()
           
 boolean isMostSpecificBeanDefinitionCounts()
           
 boolean isMostSpecificResourceLast()
           
 boolean isRefreshed()
          
protected  void prepareRefresh()
          
 
Methods inherited from class org.springframework.web.context.support.XmlWebApplicationContext
getDefaultConfigLocations, initBeanDefinitionReader, loadBeanDefinitions, loadBeanDefinitions
 
Methods inherited from class org.springframework.web.context.support.AbstractRefreshableWebApplicationContext
getConfigLocations, getNamespace, getResourceByPath, getServletConfig, getServletContext, getTheme, onRefresh, postProcessBeanFactory, setNamespace, setServletConfig, setServletContext
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableConfigApplicationContext
afterPropertiesSet, resolvePath, setBeanName, setConfigLocation, setConfigLocations, setId
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
cancelRefresh, closeBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences
 
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, doClose, findAnnotationOnBean, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, prepareBeanFactory, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setParent, start, stop, toString
 
Methods inherited from class org.springframework.core.io.DefaultResourceLoader
getClassLoader, setClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.elca.el4j.core.context.RefreshableModuleApplicationContext
refresh
 
Methods inherited from interface org.springframework.web.context.ConfigurableWebApplicationContext
setConfigLocation, setConfigLocations
 
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, isActive, refresh, registerShutdownHook, setId, setParent
 
Methods inherited from interface org.springframework.context.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate
 
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch
 
Methods inherited from interface org.springframework.context.MessageSource
getMessage, getMessage, getMessage
 
Methods inherited from interface org.springframework.context.ApplicationEventPublisher
publishEvent
 
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 

Field Detail

s_loggerEl4j

protected static final org.slf4j.Logger s_loggerEl4j
This logger is used to print out some global debugging info. Consult it for info what is going on.

Constructor Detail

ModuleWebApplicationContext

public ModuleWebApplicationContext(String[] inclusiveConfigLocations,
                                   String[] exclusiveConfigLocations,
                                   boolean allowBeanDefinitionOverriding,
                                   javax.servlet.ServletContext servletContext,
                                   boolean mergeWithOuterResources)
There is no parent app context.

See Also:
#ModuleWebApplicationContext(String[], String[], boolean, ServletContext, boolean, ApplicationContext))

ModuleWebApplicationContext

public ModuleWebApplicationContext(String[] inclusiveConfigLocations,
                                   String[] exclusiveConfigLocations,
                                   boolean allowBeanDefinitionOverriding,
                                   javax.servlet.ServletContext servletContext,
                                   boolean mergeWithOuterResources,
                                   ApplicationContext parent)

See Also:
#ModuleWebApplicationContext(String[], String[], boolean, ServletContext, boolean, boolean, boolean))

ModuleWebApplicationContext

public ModuleWebApplicationContext(String[] inclusiveConfigLocations,
                                   String[] exclusiveConfigLocations,
                                   boolean allowBeanDefinitionOverriding,
                                   javax.servlet.ServletContext servletContext,
                                   boolean mergeWithOuterResources,
                                   boolean mostSpecificResourceLast,
                                   boolean mostSpecificBeanDefinitionCounts)
There is no parent app context.

See Also:
#ModuleWebApplicationContext(String[], String[], boolean, ServletContext, boolean, boolean, boolean))

ModuleWebApplicationContext

public ModuleWebApplicationContext(String[] inclusiveConfigLocations,
                                   String[] exclusiveConfigLocations,
                                   boolean allowBeanDefinitionOverriding,
                                   javax.servlet.ServletContext servletContext,
                                   boolean mergeWithOuterResources,
                                   boolean mostSpecificResourceLast,
                                   boolean mostSpecificBeanDefinitionCounts,
                                   ApplicationContext parent)
Create a new ModuleApplicationContext with the given parent, loading the definitions from the given XML files in "inclusiveConfigLocations" excluded the XML files defined in "exclusiveConfigLocations". If the parameter "allowBeanDefinitionOverriding" is set to true then the BeanFactory is allowed to override a bean if there is another one with the same name.

Parameters:
inclusiveConfigLocations - array of file paths
exclusiveConfigLocations - array of file paths which are excluded
allowBeanDefinitionOverriding - a boolean which defines if overriding of bean definitions is allowed
servletContext - the servlet context where this application context is used
mergeWithOuterResources - a boolean which defines if the resources retrieved by the configuration files section of the manifest files should be merged with resources found by searching in the file system.
mostSpecificResourceLast - Indicates if the most specific resource should be the last resource in the fetched resource array. If its value is set to true and only one resource is requested the least specific resource will be returned.
mostSpecificBeanDefinitionCounts - Indicates that the most specific bean definition is used.
parent - Is the parent application context.
Method Detail

getExclusiveConfigLocations

public String[] getExclusiveConfigLocations()
Returns:
Returns the exclusiveConfigLocations.

getInclusiveConfigLocations

public String[] getInclusiveConfigLocations()
Returns:
Returns the inclusiveConfigLocations.

isAllowBeanDefinitionOverriding

public boolean isAllowBeanDefinitionOverriding()
Returns:
Returns the allowBeanDefinitionOverriding.

isMergeWithOuterResources

public boolean isMergeWithOuterResources()
Returns:
Returns the mergeWithOuterResources.

isMostSpecificResourceLast

public boolean isMostSpecificResourceLast()
Returns:
Returns the mostSpecificResourceLast.

isMostSpecificBeanDefinitionCounts

public boolean isMostSpecificBeanDefinitionCounts()
Returns:
Returns the mostSpecificBeanDefinitionCounts.

getResource

public Resource getResource(String location)

Specified by:
getResource in interface ResourceLoader
Overrides:
getResource in class DefaultResourceLoader

getResources

public Resource[] getResources(String locationPattern)
                        throws IOException

Specified by:
getResources in interface ResourcePatternResolver
Overrides:
getResources in class AbstractApplicationContext
Throws:
IOException

createBeanFactory

protected DefaultListableBeanFactory createBeanFactory()
Override method createBeanFactory() in class AbstractRefreshableApplicationContext. The property m_allowBeanDefinitionOverriding can be set and is handed over to the DefaultListableBeanFactory which creates the BeanFactory.

Overrides:
createBeanFactory in class AbstractRefreshableApplicationContext
Returns:
the DefaultListableBeanFactory

getResourcePatternResolver

protected ResourcePatternResolver getResourcePatternResolver()

Overrides:
getResourcePatternResolver in class AbstractRefreshableWebApplicationContext

invokeBeanFactoryPostProcessors

protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory)
Not just method BeanFactoryPostProcessor.postProcessBeanFactory( ConfigurableListableBeanFactory) is invoked ordered but also the creation of the factory post processor beans!

Overrides:
invokeBeanFactoryPostProcessors in class AbstractApplicationContext

prepareRefresh

protected void prepareRefresh()

Overrides:
prepareRefresh in class AbstractApplicationContext

finishRefresh

protected void finishRefresh()
Notify all ModuleApplicationListeners that context has been refreshed.

Overrides:
finishRefresh in class AbstractApplicationContext

isRefreshed

public boolean isRefreshed()

Specified by:
isRefreshed in interface RefreshableModuleApplicationContext
Returns:
true if context is refreshed i.e. fully initialized


Copyright © 2005-2011 ELCA. All Rights Reserved.