SourceForge.net Logo

org.springframework.web.jsf
Class VariableResolverImpl

java.lang.Object
  extended byjavax.faces.el.VariableResolver
      extended byorg.springframework.web.jsf.VariableResolverImpl

public class VariableResolverImpl
extends VariableResolver

VariableResolver implementation that builds up a WebApplicationContext using the inner class VariableResolverImpl.FacesWebApplicationContext based on the typical faces configuration files:

This class trys to encapsulate the original JSF VariableResolver of the JSF implementation used with the following strategy:

  1. get the original VariableResolver via the FactoryFinder
  2. get the VariableResolver defined in the web.xml-file under the context initialization parameter org.springframework.web.jsf.VARIABLE_RESOLVER_CLASS
  3. if no VariableResolver found use an internal default implementation

The FacesWebApplicationContext delegates to the appropiate VariableResolver for bean-creation.
The resolveVariable(FacesContext, String) method of this class implements the following strategy:

This implementation trys to load a parent Spring context for the FacesWebApplicationContext in such a manner described in ContextLoader.

The FacesWebApplicationContext supports all the features described in WebApplicationContext, e.g.:

Note:
Example for integrating this VariableResolver:
WEB-INF/faces-config.xml
<application>
  <variable-resolver>org.springframework.web.jsf.VariableResolverImpl</variable-resolver>
</application>

Author:
Andreas Kuhrwahl, Thomas Jachmann
See Also:
WebApplicationContext

Nested Class Summary
protected  class VariableResolverImpl.FacesListableBeanFactory
           ConfigurableListableBeanFactory implementation used as internal bean factory for the VariableResolverImpl.FacesWebApplicationContext.
protected  class VariableResolverImpl.FacesWebApplicationContext
          WebApplicationContext implementation that takes configuration from a faces configuration XML document.
 
Field Summary
protected  org.apache.commons.logging.Log logger
           
static java.lang.String VARIABLE_RESOLVER_PARAM
           
 
Constructor Summary
VariableResolverImpl()
          Default constructor.
 
Method Summary
protected  java.lang.String configLocations(javax.servlet.ServletContext servletContext)
          Returns a comma delimited String with the faces configuration files resources
protected  VariableResolverImpl.FacesWebApplicationContext createFacesWebApplicationContext(javax.servlet.ServletContext servletContext, ApplicationContext parent)
          Creates and return a VariableResolverImpl.FacesWebApplicationContext.
protected  void finalize()
          Closes the faces WebApplicationContext.
protected  ApplicationContext loadParentContext(javax.servlet.ServletContext context)
          Loads and returns a root parent application context for the VariableResolverImpl.FacesWebApplicationContext (usually a xml context based on the "spring-beans" DTD).
 java.lang.Object resolveVariable(FacesContext context, java.lang.String name)
          Checks wether there is a bean with name name in the VariableResolverImpl.FacesWebApplicationContext and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VARIABLE_RESOLVER_PARAM

public static final java.lang.String VARIABLE_RESOLVER_PARAM
See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

VariableResolverImpl

public VariableResolverImpl()
Default constructor.

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Closes the faces WebApplicationContext.

Throws:
ApplicationContextException - if there were fatal errors closing the ApplicationContext
java.lang.Throwable

resolveVariable

public java.lang.Object resolveVariable(FacesContext context,
                                        java.lang.String name)
                                 throws EvaluationException
Checks wether there is a bean with name name in the VariableResolverImpl.FacesWebApplicationContext and returns it. Otherwise delegates to the encapsulated original VariableResolver.

Parameters:
context - context against which to resolve the bean name
name - name of the bean to be resolved
Throws:
EvaluationException - if an exception is thrown while resolving the variable name
java.lang.NullPointerException - if context or name is null
See Also:
VariableResolver.resolveVariable(javax.faces.context.FacesContext, java.lang.String), VariableResolverImpl.FacesWebApplicationContext

createFacesWebApplicationContext

protected VariableResolverImpl.FacesWebApplicationContext createFacesWebApplicationContext(javax.servlet.ServletContext servletContext,
                                                                                           ApplicationContext parent)
                                                                                    throws BeansException
Creates and return a VariableResolverImpl.FacesWebApplicationContext.

Parameters:
servletContext -
parent - parent application context
Returns:
FacesWebApplicationContext
Throws:
BeansException

configLocations

protected java.lang.String configLocations(javax.servlet.ServletContext servletContext)
Returns a comma delimited String with the faces configuration files resources


loadParentContext

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

Throws:
BeansException
See Also:
ContextLoader

SourceForge.net Logo