JSF-Spring

de.mindmatters.faces.spring.context.support
Class DefaultFacesWebApplicationContext

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.web.context.support.AbstractRefreshableWebApplicationContext
                  extended by org.springframework.web.context.support.XmlWebApplicationContext
                      extended by de.mindmatters.faces.spring.context.support.DefaultFacesWebApplicationContext
All Implemented Interfaces:
FacesWebApplicationContext, BeanFactory, DisposableBean, HierarchicalBeanFactory, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver, ThemeSource, ConfigurableWebApplicationContext, WebApplicationContext

public class DefaultFacesWebApplicationContext
extends XmlWebApplicationContext
implements FacesWebApplicationContext

Default implementation of the FacesWebApplicationContext interface.

Uses the ManagedBeanDefinitionDocumentReader for loading the configured BeanDefinitions.

Uses and enables DelegatingVariableResolver as JSF VariableResolver. The DelegatingVariableResolver cares about bean resolution from a view (e.g. a jsp resource).

Author:
Andreas Kuhrwahl
See Also:
ContextLoader, ContextLoaderListener, ContextLoaderServlet, ManagedBeanDefinitionDocumentReader, ManagedBeanFactory

Field Summary
 
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, logger, MESSAGE_SOURCE_BEAN_NAME
 
Fields inherited from interface de.mindmatters.faces.spring.context.FacesWebApplicationContext
ROOT_FACES_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_APPLICATION, SCOPE_NONE
 
Fields inherited from interface org.springframework.web.context.ConfigurableWebApplicationContext
CONFIG_LOCATION_DELIMITERS
 
Fields inherited from interface org.springframework.web.context.WebApplicationContext
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_GLOBAL_SESSION, SCOPE_REQUEST, SCOPE_SESSION
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
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
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
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
DefaultFacesWebApplicationContext()
          Standard constructor in JavaBeans-style.
 
Method Summary
protected  DefaultListableBeanFactory createBeanFactory()
          Create an internal bean factory for this context.
protected  ManagedBeanFactory createManagedBeanFactory()
          Create an internal managed bean factory for this context.
protected  java.lang.String[] getDefaultConfigLocations()
          The default location for the root context is "/WEB-INF/applicationContext.xml", and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").
protected  java.lang.String[] getDefaultFacesSpringConfigLocations()
          The default location for jsf-spring config files is "/WEB-INF/faces-spring-context.xml", and all "/META-INF/faces-spring-context.xml".
protected  java.lang.String[] getFacesSpringConfigLocations()
          Returns the locations of the jsf-spring configuration files.
protected  void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader)
          Sets the document-reader class of the beanDefinitionReader to the ManagedBeanDefinitionDocumentReader class.
protected  void loadBeanDefinitions(XmlBeanDefinitionReader reader)
          Load the bean definitions with the given XmlBeanDefinitionReader.
protected  void onPostProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Hook method for postprocessing the internal bean factory.
protected  void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Register ServletContextAwareProcessor.
 void refresh()
          Sets a default config location if no explicit config location specified.
 void setFacesSpringConfigLocations(java.lang.String[] locations)
          Sets the config locations.
 
Methods inherited from class org.springframework.web.context.support.XmlWebApplicationContext
loadBeanDefinitions
 
Methods inherited from class org.springframework.web.context.support.AbstractRefreshableWebApplicationContext
getConfigLocations, getNamespace, getResourceByPath, getResourcePatternResolver, getServletConfig, getServletContext, getTheme, onRefresh, resolvePath, setConfigLocations, setNamespace, setServletConfig, setServletContext, toString
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
closeBeanFactory, getBeanFactory, refreshBeanFactory
 
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, doClose, getAliases, getAutowireCapableBeanFactory, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getInternalParentBeanFactory, getInternalParentMessageSource, getLifecycleBeans, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResources, getStartupDate, getType, isActive, isRunning, isSingleton, isTypeMatch, onClose, publishEvent, registerShutdownHook, setDisplayName, setParent, start, stop
 
Methods inherited from class org.springframework.core.io.DefaultResourceLoader
getClassLoader, getResource, setClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.web.context.ConfigurableWebApplicationContext
setConfigLocations, setNamespace, setServletConfig, setServletContext
 
Methods inherited from interface org.springframework.web.context.WebApplicationContext
getServletContext
 
Methods inherited from interface org.springframework.context.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, getParent, getStartupDate
 
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, isSingleton, isTypeMatch
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, 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.support.ResourcePatternResolver
getResources
 
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader, getResource
 
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext
addBeanFactoryPostProcessor, close, getBeanFactory, isActive, registerShutdownHook, setParent
 
Methods inherited from interface org.springframework.context.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, getParent, getStartupDate
 
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, isSingleton, isTypeMatch
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, 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.support.ResourcePatternResolver
getResources
 
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader, getResource
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 

Constructor Detail

DefaultFacesWebApplicationContext

public DefaultFacesWebApplicationContext()
Standard constructor in JavaBeans-style.

Method Detail

createBeanFactory

protected final DefaultListableBeanFactory createBeanFactory()
Create an internal bean factory for this context. Called for each refresh attempt.

The default implementation creates a DefaultListableBeanFactory with the internal bean factory of this context's parent as parent bean factory. Can be overridden in subclasses.

Overrides:
createBeanFactory in class AbstractRefreshableApplicationContext
Returns:
the bean factory for this context
See Also:
DefaultListableBeanFactory, AbstractApplicationContext.refresh(), AbstractApplicationContext.getInternalParentBeanFactory()

createManagedBeanFactory

protected ManagedBeanFactory createManagedBeanFactory()
Create an internal managed bean factory for this context.

The default implementation creates a ManagedBeanFactory with the internal bean factory of this context's parent as parent bean factory. Can be overridden in subclasses.

Returns:
the bean factory for this context

initBeanDefinitionReader

protected final void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader)
Sets the document-reader class of the beanDefinitionReader to the ManagedBeanDefinitionDocumentReader class.

Overrides:
initBeanDefinitionReader in class XmlWebApplicationContext
Parameters:
beanDefinitionReader - the reader to initialize
See Also:
#initBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader), ManagedBeanDefinitionDocumentReader

setFacesSpringConfigLocations

public final void setFacesSpringConfigLocations(java.lang.String[] locations)
Sets the config locations. Should be config files compatible with the "spring-beans.dtd", "spring-beans-2.0.dtd" respectively the schema "spring-beans-2.0.xsd".

Specified by:
setFacesSpringConfigLocations in interface FacesWebApplicationContext
Parameters:
locations - the config locations

getFacesSpringConfigLocations

protected final java.lang.String[] getFacesSpringConfigLocations()
Returns the locations of the jsf-spring configuration files.

Returns:
The locations of the jsf-spring configuration files

loadBeanDefinitions

protected final void loadBeanDefinitions(XmlBeanDefinitionReader reader)
                                  throws java.io.IOException
Load the bean definitions with the given XmlBeanDefinitionReader.

The lifecycle of the bean factory is handled by the refreshBeanFactory method; therefore this method is just supposed to load and/or register bean definitions.

Delegates to a ResourcePatternResolver for resolving location patterns into Resource instances.

Overrides:
loadBeanDefinitions in class XmlWebApplicationContext
Throws:
java.io.IOException - if the required XML document isn't found
See Also:
AbstractRefreshableApplicationContext.refreshBeanFactory(), AbstractRefreshableWebApplicationContext.getConfigLocations(), AbstractApplicationContext.getResources(java.lang.String), AbstractRefreshableWebApplicationContext.getResourcePatternResolver()

postProcessBeanFactory

protected final void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Register ServletContextAwareProcessor.

Overrides:
postProcessBeanFactory in class AbstractRefreshableWebApplicationContext
Parameters:
beanFactory - the bean factory used by the application context
See Also:
ServletContextAwareProcessor

onPostProcessBeanFactory

protected void onPostProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Hook method for postprocessing the internal bean factory.

Parameters:
beanFactory - the bean factory used by this application context
Throws:
BeansException - in case of errors

getDefaultConfigLocations

protected final java.lang.String[] getDefaultConfigLocations()
The default location for the root context is "/WEB-INF/applicationContext.xml", and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").

Overrides:
getDefaultConfigLocations in class XmlWebApplicationContext
See Also:
AbstractRefreshableWebApplicationContext.setConfigLocations(java.lang.String[])

getDefaultFacesSpringConfigLocations

protected final java.lang.String[] getDefaultFacesSpringConfigLocations()
The default location for jsf-spring config files is "/WEB-INF/faces-spring-context.xml", and all "/META-INF/faces-spring-context.xml".

Returns:
The locations.

refresh

public void refresh()
Sets a default config location if no explicit config location specified.

Specified by:
refresh in interface ConfigurableApplicationContext
Overrides:
refresh in class AbstractRefreshableWebApplicationContext
See Also:
AbstractRefreshableWebApplicationContext.getDefaultConfigLocations(), AbstractRefreshableWebApplicationContext.setConfigLocations(java.lang.String[])

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG