ch.elca.el4j.core.context
Class ModuleApplicationContext

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.context.support.AbstractXmlApplicationContext
                      extended by ch.elca.el4j.core.context.ModuleApplicationContext
All Implemented Interfaces:
RefreshableModuleApplicationContext, BeanFactory, BeanNameAware, DisposableBean, HierarchicalBeanFactory, InitializingBean, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver

public class ModuleApplicationContext
extends AbstractXmlApplicationContext
implements RefreshableModuleApplicationContext

Class that loads the ApplicationContext given an array of config files and an array of exclusion config files. The files can be declared via classpath or filepath.

Classpath files can be declared by the following two patterns: "ch/elca/.../x.xml" or by "classpath:ch/elca/.../x.xml".

Filepath files have to be declared in the following way: "file:C:/folder/.../x.xml".

Classpath and filepath files can be declared via ant-style pattern. For instance "classpath:ch/elca/el4j/*.xml" will be resolved into all xml files in the specified classpath. If there is more than one file having the same classpath in two different jars, then you have to change classpath:folder/... into classpath*:folder/... Otherwise, only the file(s) from the first jar is loaded.

Additional features:

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

Field Summary
static String EL4J_DEBUGGING_LOGGER
          The common debugging logger for EL4J.
protected static org.slf4j.Logger s_el4jLogger
          This logger is used to print out some global debugging info.
 
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.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
ModuleApplicationContext(ModuleApplicationContextConfiguration config)
          Constructor to create a module application context by using the given configurations.
ModuleApplicationContext(String[] inclusiveConfigLocations, boolean allowBeanDefinitionOverriding)
           
ModuleApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, ApplicationContext parent)
           Merge with outer resources is set to true.
ModuleApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, ApplicationContext parent, boolean mergeWithOuterResources)
           Most specific resource last is set to false.
ModuleApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, ApplicationContext parent, boolean mergeWithOuterResources, boolean mostSpecificResourceLast, boolean mostSpecificBeanDefinitionCounts)
          With this constructor we use no app context creation listener.
ModuleApplicationContext(String[] inclusiveConfigLocations, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding, ApplicationContext parent, boolean mergeWithOuterResources, boolean mostSpecificResourceLast, boolean mostSpecificBeanDefinitionCounts, ModuleApplicationContextCreationListener creationListener)
          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".
ModuleApplicationContext(String[] inclusiveConfigLocations, String exclusiveConfigLocation, boolean allowBeanDefinitionOverriding)
           
ModuleApplicationContext(String inclusiveConfigLocation, boolean allowBeanDefinitionOverriding)
           
ModuleApplicationContext(String inclusiveConfigLocation, String[] exclusiveConfigLocations, boolean allowBeanDefinitionOverriding)
           
ModuleApplicationContext(String inclusiveConfigLocation, String exclusiveConfigLocation, boolean allowBeanDefinitionOverriding)
           
 
Method Summary
protected  DefaultListableBeanFactory createBeanFactory()
          Override method createBeanFactory() in class AbstractRefreshableApplicationContext.
protected  void finishRefresh()
          Notify all ModuleApplicationListeners that context has been refreshed.
 String[] getConfigLocations()
           
 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 postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          
protected  void prepareRefresh()
          
 
Methods inherited from class org.springframework.context.support.AbstractXmlApplicationContext
getConfigResources, initBeanDefinitionReader, loadBeanDefinitions, loadBeanDefinitions, setValidating
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableConfigApplicationContext
afterPropertiesSet, getDefaultConfigLocations, 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, onRefresh, prepareBeanFactory, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setParent, start, stop, toString
 
Methods inherited from class org.springframework.core.io.DefaultResourceLoader
getClassLoader, getResourceByPath, 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.core.io.ResourceLoader
getClassLoader
 

Field Detail

EL4J_DEBUGGING_LOGGER

public static final String EL4J_DEBUGGING_LOGGER
The common debugging logger for EL4J.

See Also:
Constant Field Values

s_el4jLogger

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

Constructor Detail

ModuleApplicationContext

public ModuleApplicationContext(String inclusiveConfigLocation,
                                boolean allowBeanDefinitionOverriding)
See Also:
ModuleApplicationContext( String[], boolean)

ModuleApplicationContext

public ModuleApplicationContext(String[] inclusiveConfigLocations,
                                boolean allowBeanDefinitionOverriding)
See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext)

ModuleApplicationContext

public ModuleApplicationContext(String inclusiveConfigLocation,
                                String exclusiveConfigLocation,
                                boolean allowBeanDefinitionOverriding)
See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext)

ModuleApplicationContext

public ModuleApplicationContext(String[] inclusiveConfigLocations,
                                String exclusiveConfigLocation,
                                boolean allowBeanDefinitionOverriding)
See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext)

ModuleApplicationContext

public ModuleApplicationContext(String inclusiveConfigLocation,
                                String[] exclusiveConfigLocations,
                                boolean allowBeanDefinitionOverriding)
See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext)

ModuleApplicationContext

public ModuleApplicationContext(String[] inclusiveConfigLocations,
                                String[] exclusiveConfigLocations,
                                boolean allowBeanDefinitionOverriding,
                                ApplicationContext parent)

See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext, boolean)

ModuleApplicationContext

public ModuleApplicationContext(String[] inclusiveConfigLocations,
                                String[] exclusiveConfigLocations,
                                boolean allowBeanDefinitionOverriding,
                                ApplicationContext parent,
                                boolean mergeWithOuterResources)

See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext, boolean, boolean, boolean, ModuleApplicationContextCreationListener)

ModuleApplicationContext

public ModuleApplicationContext(String[] inclusiveConfigLocations,
                                String[] exclusiveConfigLocations,
                                boolean allowBeanDefinitionOverriding,
                                ApplicationContext parent,
                                boolean mergeWithOuterResources,
                                boolean mostSpecificResourceLast,
                                boolean mostSpecificBeanDefinitionCounts)
With this constructor we use no app context creation listener.

See Also:
ModuleApplicationContext( String[], String[], boolean, ApplicationContext, boolean, boolean, boolean, ModuleApplicationContextCreationListener)

ModuleApplicationContext

public ModuleApplicationContext(String[] inclusiveConfigLocations,
                                String[] exclusiveConfigLocations,
                                boolean allowBeanDefinitionOverriding,
                                ApplicationContext parent,
                                boolean mergeWithOuterResources,
                                boolean mostSpecificResourceLast,
                                boolean mostSpecificBeanDefinitionCounts,
                                ModuleApplicationContextCreationListener creationListener)
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
parent - the parent context
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.
creationListener - Is the listener to hock in while creation of the application context.

ModuleApplicationContext

public ModuleApplicationContext(ModuleApplicationContextConfiguration config)
Constructor to create a module application context by using the given configurations.

Parameters:
config - Is the used configuration.
Method Detail

postProcessBeanFactory

protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)

Overrides:
postProcessBeanFactory in class AbstractApplicationContext

getConfigLocations

public String[] getConfigLocations()
Overrides:
getConfigLocations in class AbstractRefreshableConfigApplicationContext
Returns:
Returns the ConfigLocations.

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 AbstractApplicationContext

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.