ro.isdc.wro.http
Class WroFilter

java.lang.Object
  extended by ro.isdc.wro.http.WroFilter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
ConfigurableWroFilter

public class WroFilter
extends Object
implements javax.servlet.Filter

Main entry point. Perform the request processing by identifying the type of the requested resource. Depending on the way it is configured.

Author:
Alex Objelean

Field Summary
static String API_RELOAD_CACHE
          API - reload cache method call
static String API_RELOAD_MODEL
          API - reload model method call
static String PATH_API
          wro API mapping path.
 
Constructor Summary
WroFilter()
           
 
Method Summary
 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.
protected  MBeanServer getMBeanServer()
          Override this method if you want to provide a different MBeanServer.
 WroConfiguration getWroConfiguration()
           
protected  WroManagerFactory getWroManagerFactory()
          Factory method for WroManagerFactory.
 void init(javax.servlet.FilterConfig config)
          
protected  String newMBeanName()
           
protected  ObjectFactory<WroConfiguration> newWroConfigurationFactory()
           
protected  WroManagerFactory newWroManagerFactory()
           
protected  void onRequestProcessed()
          Useful for unit tests to check the post processing.
protected  void onRuntimeException(RuntimeException e, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
          Invoked when a RuntimeException is thrown.
protected  void setResponseHeaders(javax.servlet.http.HttpServletResponse response)
          Method called for each request and responsible for setting response headers, used mostly for cache control.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_API

public static final String PATH_API
wro API mapping path. If request uri contains this, exposed API method will be invoked.

See Also:
Constant Field Values

API_RELOAD_CACHE

public static final String API_RELOAD_CACHE
API - reload cache method call

See Also:
Constant Field Values

API_RELOAD_MODEL

public static final String API_RELOAD_MODEL
API - reload model method call

See Also:
Constant Field Values
Constructor Detail

WroFilter

public WroFilter()
Method Detail

newWroConfigurationFactory

protected ObjectFactory<WroConfiguration> newWroConfigurationFactory()
Returns:
implementation of WroConfigurationFactory used to create a WroConfiguration object.

init

public final void init(javax.servlet.FilterConfig config)
                throws javax.servlet.ServletException

Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

newMBeanName

protected String newMBeanName()
Returns:
the name of MBean to be used by JMX to configure wro4j.

getMBeanServer

protected MBeanServer getMBeanServer()
Override this method if you want to provide a different MBeanServer.

Returns:
MBeanServer to use for JMX.

doInit

protected void doInit(javax.servlet.FilterConfig config)
               throws javax.servlet.ServletException
Custom filter initialization - can be used for extended classes.

Throws:
javax.servlet.ServletException
See Also:
Filter.init(FilterConfig).

doFilter

public final void doFilter(javax.servlet.ServletRequest req,
                           javax.servlet.ServletResponse res,
                           javax.servlet.FilterChain chain)
                    throws IOException,
                           javax.servlet.ServletException

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
IOException
javax.servlet.ServletException

onRequestProcessed

protected void onRequestProcessed()
Useful for unit tests to check the post processing.


onRuntimeException

protected void onRuntimeException(RuntimeException e,
                                  javax.servlet.http.HttpServletResponse response,
                                  javax.servlet.FilterChain chain)
Invoked when a RuntimeException is thrown. Allows custom exception handling. The default implementation redirects to 404 for a specific WroRuntimeException exception when in DEPLOYMENT mode.

Parameters:
e - RuntimeException thrown during request processing.

setResponseHeaders

protected void setResponseHeaders(javax.servlet.http.HttpServletResponse response)
Method called for each request and responsible for setting response headers, used mostly for cache control. Override this method if you want to change the way headers are set.

Parameters:
response - HttpServletResponse object.

getWroManagerFactory

protected WroManagerFactory getWroManagerFactory()
Factory method for WroManagerFactory. Override this method, in order to change the way filter use factory.

Returns:
WroManagerFactory object.

newWroManagerFactory

protected WroManagerFactory newWroManagerFactory()
Returns:
default implementation of WroManagerFactory when none is provided explicitly through wroConfiguration option.

getWroConfiguration

public final WroConfiguration getWroConfiguration()
Returns:
the WroConfiguration associated with this filter instance.

destroy

public void destroy()

Specified by:
destroy in interface javax.servlet.Filter


Copyright © 2008-2011. All Rights Reserved.