JSF-Spring

de.mindmatters.faces.context
Class ServletExternalContextFake

java.lang.Object
  extended by javax.faces.context.ExternalContext
      extended by de.mindmatters.faces.context.ServletExternalContextFake
All Implemented Interfaces:
DisposableBean

public class ServletExternalContextFake
extends ExternalContext
implements DisposableBean

This class allows the Faces API to be unaware of the nature of its containing application environment.

Note: documentation copied from specification

This class implements the nature of a servlet applicaton environment. As it's name says this class fakes the behavior described in the specifications. This class implements the specified behavior which delegates to the ServletContext. Specified behavior which delegates to the ServletRequest or ServletResponse is not implemented (In fact a UnsupportedOperationException will be thrown).

This class is used on startup time to preinstantiate singletons declared in any Spring-based configuration context which needs a FacesContext for instantiation.

Author:
andreas.kuhrwahl

Field Summary
protected  org.apache.commons.logging.Log logger
          For logging.
 
Fields inherited from class javax.faces.context.ExternalContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
ServletExternalContextFake(javax.servlet.ServletContext servletContext)
          Constructs an ExternalContext with the given ServletContext servletContext.
 
Method Summary
 void destroy()
          Invoked by a BeanFactory on destruction of a singleton.
 void dispatch(java.lang.String path)
          
 java.lang.String encodeActionURL(java.lang.String url)
          
 java.lang.String encodeNamespace(java.lang.String name)
          
 java.lang.String encodeResourceURL(java.lang.String url)
          
 java.util.Map getApplicationMap()
          
 java.lang.String getAuthType()
          
 java.lang.Object getContext()
          
 java.lang.String getInitParameter(java.lang.String name)
          
 java.util.Map getInitParameterMap()
          
 java.lang.String getRemoteUser()
          
 java.lang.Object getRequest()
          
 java.lang.String getRequestContextPath()
          
 java.util.Map getRequestCookieMap()
          
 java.util.Map getRequestHeaderMap()
          
 java.util.Map getRequestHeaderValuesMap()
          
 java.util.Locale getRequestLocale()
          
 java.util.Iterator getRequestLocales()
          
 java.util.Map getRequestMap()
          
 java.util.Map getRequestParameterMap()
          
 java.util.Iterator getRequestParameterNames()
          
 java.util.Map getRequestParameterValuesMap()
          
 java.lang.String getRequestPathInfo()
          
 java.lang.String getRequestServletPath()
          
 java.net.URL getResource(java.lang.String path)
          
 java.io.InputStream getResourceAsStream(java.lang.String path)
          
 java.util.Set getResourcePaths(java.lang.String path)
          
 java.lang.Object getResponse()
          
protected  javax.servlet.ServletContext getServletContext()
          Returns the ServletContext.
 java.lang.Object getSession(boolean create)
          
 java.util.Map getSessionMap()
          
 java.security.Principal getUserPrincipal()
          
 boolean isUserInRole(java.lang.String role)
          
 void log(java.lang.String message)
          
 void log(java.lang.String message, java.lang.Throwable exception)
          
 void redirect(java.lang.String url)
          
 
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.

Constructor Detail

ServletExternalContextFake

public ServletExternalContextFake(javax.servlet.ServletContext servletContext)
Constructs an ExternalContext with the given ServletContext servletContext.

Parameters:
servletContext - the context of the application environment
Method Detail

dispatch

public void dispatch(java.lang.String path)
              throws java.io.IOException

Specified by:
dispatch in class ExternalContext
Throws:
java.io.IOException

encodeActionURL

public java.lang.String encodeActionURL(java.lang.String url)

Specified by:
encodeActionURL in class ExternalContext

encodeNamespace

public java.lang.String encodeNamespace(java.lang.String name)

Specified by:
encodeNamespace in class ExternalContext

encodeResourceURL

public java.lang.String encodeResourceURL(java.lang.String url)

Specified by:
encodeResourceURL in class ExternalContext

getApplicationMap

public java.util.Map getApplicationMap()

Specified by:
getApplicationMap in class ExternalContext

getAuthType

public java.lang.String getAuthType()

Specified by:
getAuthType in class ExternalContext

getContext

public java.lang.Object getContext()

Specified by:
getContext in class ExternalContext

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)

Specified by:
getInitParameter in class ExternalContext

getInitParameterMap

public java.util.Map getInitParameterMap()

Specified by:
getInitParameterMap in class ExternalContext

getRemoteUser

public java.lang.String getRemoteUser()

Specified by:
getRemoteUser in class ExternalContext

getRequest

public java.lang.Object getRequest()

Specified by:
getRequest in class ExternalContext

getRequestContextPath

public java.lang.String getRequestContextPath()

Specified by:
getRequestContextPath in class ExternalContext

getRequestCookieMap

public java.util.Map getRequestCookieMap()

Specified by:
getRequestCookieMap in class ExternalContext

getRequestHeaderMap

public java.util.Map getRequestHeaderMap()

Specified by:
getRequestHeaderMap in class ExternalContext

getRequestHeaderValuesMap

public java.util.Map getRequestHeaderValuesMap()

Specified by:
getRequestHeaderValuesMap in class ExternalContext

getRequestLocale

public java.util.Locale getRequestLocale()

Specified by:
getRequestLocale in class ExternalContext

getRequestLocales

public java.util.Iterator getRequestLocales()

Specified by:
getRequestLocales in class ExternalContext

getRequestMap

public java.util.Map getRequestMap()

Specified by:
getRequestMap in class ExternalContext

getRequestParameterMap

public java.util.Map getRequestParameterMap()

Specified by:
getRequestParameterMap in class ExternalContext

getRequestParameterNames

public java.util.Iterator getRequestParameterNames()

Specified by:
getRequestParameterNames in class ExternalContext

getRequestParameterValuesMap

public java.util.Map getRequestParameterValuesMap()

Specified by:
getRequestParameterValuesMap in class ExternalContext

getRequestPathInfo

public java.lang.String getRequestPathInfo()

Specified by:
getRequestPathInfo in class ExternalContext

getRequestServletPath

public java.lang.String getRequestServletPath()

Specified by:
getRequestServletPath in class ExternalContext

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException

Specified by:
getResource in class ExternalContext
Throws:
java.net.MalformedURLException

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)

Specified by:
getResourceAsStream in class ExternalContext

getResourcePaths

public java.util.Set getResourcePaths(java.lang.String path)

Specified by:
getResourcePaths in class ExternalContext

getResponse

public java.lang.Object getResponse()

Specified by:
getResponse in class ExternalContext

getSession

public java.lang.Object getSession(boolean create)

Specified by:
getSession in class ExternalContext

getSessionMap

public java.util.Map getSessionMap()

Specified by:
getSessionMap in class ExternalContext

getUserPrincipal

public java.security.Principal getUserPrincipal()

Specified by:
getUserPrincipal in class ExternalContext

isUserInRole

public boolean isUserInRole(java.lang.String role)

Specified by:
isUserInRole in class ExternalContext

log

public void log(java.lang.String message)

Specified by:
log in class ExternalContext

log

public void log(java.lang.String message,
                java.lang.Throwable exception)

Specified by:
log in class ExternalContext

redirect

public void redirect(java.lang.String url)
              throws java.io.IOException

Specified by:
redirect in class ExternalContext
Throws:
java.io.IOException

destroy

public void destroy()
             throws java.lang.Exception
Invoked by a BeanFactory on destruction of a singleton.

Specified by:
destroy in interface DisposableBean
Throws:
java.lang.Exception - in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources too.

getServletContext

protected final javax.servlet.ServletContext getServletContext()
Returns the ServletContext.

Returns:
The ServletContext

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG