Package org.apache.activemq.web.filter
Class ApplicationContextFilter
- java.lang.Object
-
- org.apache.activemq.web.filter.ApplicationContextFilter
-
- All Implemented Interfaces:
Filter
public class ApplicationContextFilter extends Object implements 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.
-
-
Constructor Summary
Constructors Constructor Description ApplicationContextFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
bindRequestBean(Object bean, 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 POJOsprotected 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 Map
createRequestContextWrapper(ServletRequest request)
Creates a wrapper around the request context (e.g.void
destroy()
void
doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
String
getApplicationContextName()
protected String
getInitParameter(FilterConfig config, String key, String defaultValue)
String
getRequestContextName()
ServletContext
getServletContext()
void
init(FilterConfig config)
void
setApplicationContextName(String variableName)
void
setRequestContextName(String requestContextName)
-
-
-
Method Detail
-
init
public void init(FilterConfig config) throws ServletException
- Specified by:
init
in interfaceFilter
- Throws:
ServletException
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- Specified by:
doFilter
in interfaceFilter
- Throws:
IOException
ServletException
-
getServletContext
public ServletContext getServletContext()
-
getApplicationContextName
public String getApplicationContextName()
-
setApplicationContextName
public void setApplicationContextName(String variableName)
-
getRequestContextName
public String getRequestContextName()
-
setRequestContextName
public void setRequestContextName(String requestContextName)
-
getInitParameter
protected String getInitParameter(FilterConfig config, String key, String defaultValue)
-
createApplicationContextWrapper
protected 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 Map createRequestContextWrapper(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 Object bindRequestBean(Object bean, 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
-
-