]> git.mxchange.org Git - jcore-utils.git/blob - src/org/mxchange/jcoreee/filter/servlet/BaseServletFilter.java
More cleanup
[jcore-utils.git] / src / org / mxchange / jcoreee / filter / servlet / BaseServletFilter.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcoreee.filter.servlet;
18
19 import java.text.MessageFormat;
20 import javax.servlet.Filter;
21 import javax.servlet.FilterConfig;
22 import javax.servlet.ServletException;
23 import org.mxchange.jcoree.BaseEeSystem;
24
25 /**
26  * A general servlet filter class. If you need to override init() or
27  * destroy() please always call the super method first and handle over all
28  * parameter.
29  *
30  * @author Roland Haeder
31  */
32 public abstract class BaseServletFilter extends BaseEeSystem implements Filter {
33         /**
34          * Configuration instance
35          */
36         private FilterConfig config;
37
38         /**
39          * Destroys this filter
40          */
41         @Override
42         public void destroy () {
43                 // Unset config instance
44                 this.setConfig(null);
45         }
46
47         /**
48          * Initializes this filter
49          *
50          * @param filterConfig Filter configuration
51          * @throws ServletException 
52          */
53         @Override
54         public void init (final FilterConfig filterConfig) throws ServletException {
55                 // Trace message
56                 this.getLogger().logTrace(MessageFormat.format("filterConfig={0} - CALLED!", filterConfig)); //NOI18N
57
58                 // Set config instance
59                 this.setConfig(filterConfig);
60
61                 // Trace message
62                 this.getLogger().logTrace("EXIT!"); //NOI18N
63         }
64
65         /**
66          * Configuration instance
67          * @return the config
68          */
69         protected FilterConfig getConfig () {
70                 return this.config;
71         }
72
73         /**
74          * Configuration instance
75          * @param config the config to set
76          */
77         private void setConfig (final FilterConfig config) {
78                 this.config = config;
79         }
80 }