org.apache.activemq.web.filter
Class ApplicationContextFilter

java.lang.Object
  extended by org.apache.activemq.web.filter.ApplicationContextFilter
All Implemented Interfaces:
javax.servlet.Filter

public class ApplicationContextFilter
extends java.lang.Object
implements javax.servlet.Filter

Exposes Spring ApplicationContexts to JSP EL and other view technologies. Currently a variable is placed in application scope (by default called 'applicationContext') so that POJOs can be pulled out of Spring in a JSP page to render things using EL expressions.
e.g. ${applicationContext.cheese} would access the cheese POJO. Or ${applicationContext.cheese.name} would access the name property of the cheese POJO.
You can then use JSTL to work with these POJOs such as <c.set var="myfoo" value="${applicationContext.foo}"/>
In addition to applicationContext a 'requestContext' variable is created which will automatically bind any request parameters to the POJOs extracted from the applicationContext - which is ideal for POJOs which implement queries in view technologies.

Version:
$Revision: 426366 $

Constructor Summary
ApplicationContextFilter()
           
 
Method Summary
protected  java.lang.Object bindRequestBean(java.lang.Object bean, javax.servlet.ServletRequest request)
          Binds properties from the request parameters to the given POJO which is useful for POJOs which are configurable via request parameters such as for query/view POJOs
protected  java.util.Map createApplicationContextWrapper(org.springframework.web.context.WebApplicationContext context)
          Creates a wrapper around the web application context so that it can be accessed easily from inside JSP EL (or other expression languages in other view technologies).
protected  java.util.Map createRequestContextWrapper(javax.servlet.ServletRequest request)
          Creates a wrapper around the request context (e.g.
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
 java.lang.String getApplicationContextName()
           
protected  java.lang.String getInitParameter(javax.servlet.FilterConfig config, java.lang.String key, java.lang.String defaultValue)
           
 java.lang.String getRequestContextName()
           
 javax.servlet.ServletContext getServletContext()
           
 void init(javax.servlet.FilterConfig config)
           
 void setApplicationContextName(java.lang.String variableName)
           
 void setRequestContextName(java.lang.String requestContextName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationContextFilter

public ApplicationContextFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter

getServletContext

public javax.servlet.ServletContext getServletContext()

getApplicationContextName

public java.lang.String getApplicationContextName()

setApplicationContextName

public void setApplicationContextName(java.lang.String variableName)

getRequestContextName

public java.lang.String getRequestContextName()

setRequestContextName

public void setRequestContextName(java.lang.String requestContextName)

getInitParameter

protected java.lang.String getInitParameter(javax.servlet.FilterConfig config,
                                            java.lang.String key,
                                            java.lang.String defaultValue)

createApplicationContextWrapper

protected java.util.Map createApplicationContextWrapper(org.springframework.web.context.WebApplicationContext context)
Creates a wrapper around the web application context so that it can be accessed easily from inside JSP EL (or other expression languages in other view technologies).


createRequestContextWrapper

protected java.util.Map createRequestContextWrapper(javax.servlet.ServletRequest request)
Creates a wrapper around the request context (e.g. to allow POJOs to be auto-injected from request parameter values etc) so that it can be accessed easily from inside JSP EL (or other expression languages in other view technologies).


bindRequestBean

protected java.lang.Object bindRequestBean(java.lang.Object bean,
                                           javax.servlet.ServletRequest request)
Binds properties from the request parameters to the given POJO which is useful for POJOs which are configurable via request parameters such as for query/view POJOs



Copyright © 2010 Apache Software Foundation. All Rights Reserved.