public class WroFilter extends Object implements javax.servlet.Filter
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTRIBUTE_PASSED_THROUGH_FILTER
Attribute indicating that the request was passed through
WroFilter. |
| Constructor and Description |
|---|
WroFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain) |
protected void |
doInit(javax.servlet.FilterConfig config)
Custom filter initialization - can be used for extended classes.
|
WroConfiguration |
getConfiguration() |
protected MBeanServer |
getMBeanServer()
Override this method if you want to provide a different MBeanServer.
|
WroManagerFactory |
getWroManagerFactory() |
void |
init(javax.servlet.FilterConfig config) |
static boolean |
isPassedThroughyWroFilter(javax.servlet.http.HttpServletRequest request) |
protected String |
newMBeanName() |
protected RequestHandlerFactory |
newRequestHandlerFactory() |
protected ResponseHeadersConfigurer |
newResponseHeadersConfigurer() |
protected ObjectFactory<WroConfiguration> |
newWroConfigurationFactory(javax.servlet.FilterConfig filterConfig) |
protected WroManagerFactory |
newWroManagerFactory()
Factory method for
WroManagerFactory. |
protected void |
onException(Exception e,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
Invoked when a
Exception is thrown. |
protected void |
onRequestProcessed()
Useful for unit tests to check the post processing.
|
void |
setConfiguration(WroConfiguration config)
Once set, this configuration will be used, instead of the one built by the factory.
|
void |
setEnable(boolean enable)
Sets the enable flag used to toggle filter.
|
void |
setRequestHandlerFactory(RequestHandlerFactory requestHandlerFactory)
Sets the RequestHandlerFactory used to create the collection of requestHandlers
|
protected void |
setResponseHeaders(javax.servlet.http.HttpServletResponse response)
Method called for each request and responsible for setting response headers, used mostly for cache control.
|
void |
setWroConfigurationFactory(ObjectFactory<WroConfiguration> wroConfigurationFactory) |
void |
setWroManagerFactory(WroManagerFactory wroManagerFactory)
Allows external configuration of
WroManagerFactory (ex: using spring IoC). |
public static final String ATTRIBUTE_PASSED_THROUGH_FILTER
WroFilter. This is required to allow identify
requests for wro resources (example: async resourceWatcher which cannot be executed asynchronously unless a wro
resource was requested).public static boolean isPassedThroughyWroFilter(javax.servlet.http.HttpServletRequest request)
WroFilterpublic final void init(javax.servlet.FilterConfig config)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionprotected String newMBeanName()
protected MBeanServer getMBeanServer()
MBeanServer to use for JMX.protected ResponseHeadersConfigurer newResponseHeadersConfigurer()
ResponseHeadersConfigurer.protected RequestHandlerFactory newRequestHandlerFactory()
RequestHandlerFactoryprotected void doInit(javax.servlet.FilterConfig config)
throws javax.servlet.ServletException
javax.servlet.ServletExceptionFilter.init(FilterConfig).public final void doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOExceptionjavax.servlet.ServletExceptionprotected void onException(Exception e, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
Exception is thrown. Allows custom exception handling. The default implementation proceeds
with filter chaining when exception is thrown.e - Exception thrown during request processing.protected void setResponseHeaders(javax.servlet.http.HttpServletResponse response)
response - HttpServletResponse object.public void setWroManagerFactory(WroManagerFactory wroManagerFactory)
WroManagerFactory (ex: using spring IoC). When this value is set, the
default WroManagerFactory initialization won't work anymore.
Note: call this method before init(FilterConfig) is invoked.wroManagerFactory - the wroManagerFactory to setpublic final WroManagerFactory getWroManagerFactory()
WroManagerFactory instance.public void setRequestHandlerFactory(RequestHandlerFactory requestHandlerFactory)
requestHandlerFactory - to setprotected WroManagerFactory newWroManagerFactory()
WroManagerFactory.
Creates a WroManagerFactory configured in WroConfiguration using reflection. When no configuration
is found a default implementation is used.
Note: this method is not invoked during initialization if a WroManagerFactory is set using
setWroManagerFactory(WroManagerFactory).WroManagerFactory instance.protected ObjectFactory<WroConfiguration> newWroConfigurationFactory(javax.servlet.FilterConfig filterConfig)
ObjectFactory used to create a WroConfiguration object.public void setWroConfigurationFactory(ObjectFactory<WroConfiguration> wroConfigurationFactory)
public final WroConfiguration getConfiguration()
WroConfiguration associated with this filter instance.public final void setConfiguration(WroConfiguration config)
config - a not null WroConfiguration to set.public void setEnable(boolean enable)
enable - flag for enabling the WroFilter.protected void onRequestProcessed()
public void destroy()
destroy in interface javax.servlet.FilterCopyright © 2008-2014. All Rights Reserved.