~ubuntu-branches/ubuntu/trusty/ehcache/trusty

« back to all changes in this revision

Viewing changes to net/sf/ehcache/constructs/web/filter/Filter.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2008-07-14 02:08:53 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080714020853-37uz6uzh6mc5mcgx
Tags: 1.5.0-1
* New upstream release
* Add libjgroups-java to Build-Depends-Indep
* Bump Standards-Version to 3.8.0
* debian/copyright: remove the full text of Apache 2.0 license, as now
  is included in common licenses

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 * Participates in the Template Method pattern with {@link javax.servlet.Filter}.
40
40
 *
41
41
 * @author <a href="mailto:gluck@thoughtworks.com">Greg Luck</a>
42
 
 * @version $Id: Filter.java 519 2007-07-27 07:11:45Z gregluck $
 
42
 * @version $Id: Filter.java 604 2008-04-25 02:20:57Z gregluck $
43
43
 */
44
44
public abstract class Filter implements javax.servlet.Filter {
45
45
    /**
80
80
     * {@link #doFilter(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.FilterChain) } which does the filtering.
81
81
     * This method takes care of error reporting and handling.
82
82
     * Errors are reported at {@link Log#warn(Object)} level because http tends to produce lots of errors.
 
83
     *
83
84
     * @throws IOException if an IOException occurs during this method it will be rethrown and will not be wrapped
84
85
     */
85
86
    public final void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
184
185
    }
185
186
 
186
187
    /**
187
 
     * Initialises the filter.  Calls template method {@link #doInit()} to perform any filter specific initialisation.
 
188
     * Initialises the filter.
 
189
     * <p/>
 
190
     * Calls template method {@link #doInit(javax.servlet.FilterConfig)} to perform any filter specific initialisation.
188
191
     */
189
 
    public final void init(final FilterConfig config) throws ServletException {
 
192
    public final void init(final FilterConfig filterConfig) throws ServletException {
190
193
        try {
191
194
 
192
 
            this.filterConfig = config;
193
 
            processInitParams(config);
 
195
            this.filterConfig = filterConfig;
 
196
            processInitParams(filterConfig);
194
197
 
195
198
            // Attempt to initialise this filter
196
 
            doInit();
 
199
            doInit(filterConfig);
197
200
        } catch (final Exception e) {
198
201
            LOG.fatal("Could not initialise servlet filter.", e);
199
202
            throw new ServletException("Could not initialise servlet filter.", e);
200
203
        }
201
204
    }
202
205
 
203
 
    private void processInitParams(final FilterConfig config) throws ServletException {
 
206
    /**
 
207
     * Processes initialisation parameters. These are configured in web.xml in accordance with the
 
208
     * Servlet specification using the following syntax:
 
209
     * <pre>
 
210
     * <filter>
 
211
     *      ...
 
212
     *      <init-param>
 
213
     *          <param-name>blah</param-name>
 
214
     *          <param-value>blahvalue</param-value>
 
215
     *      </init-param>
 
216
     *      ...
 
217
     * </filter>
 
218
     * </pre>
 
219
     * @throws ServletException
 
220
     */
 
221
    protected void processInitParams(final FilterConfig config) throws ServletException {
204
222
        String exceptions = config.getInitParameter("exceptionsToLogDifferently");
205
223
        String level = config.getInitParameter("exceptionsToLogDifferentlyLevel");
206
224
        String suppressStackTracesString = config.getInitParameter("suppressStackTraces");
313
331
    /**
314
332
     * A template method that performs any Filter specific initialisation tasks.
315
333
     * Called from {@link #init(FilterConfig)}.
 
334
     * @param filterConfig
316
335
     */
317
 
    protected abstract void doInit() throws Exception;
 
336
    protected abstract void doInit(FilterConfig filterConfig) throws Exception;
318
337
 
319
338
    /**
320
339
     * Returns the filter config.