001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.servlet.filters.invoker;
016    
017    import java.util.Enumeration;
018    import java.util.Iterator;
019    import java.util.Map;
020    
021    import javax.servlet.FilterConfig;
022    import javax.servlet.ServletContext;
023    
024    /**
025     * @author Mika Koivisto
026     * @author Brian Wing Shun Chan
027     */
028    public class InvokerFilterConfig implements FilterConfig {
029    
030            public InvokerFilterConfig(
031                    ServletContext servletContext, String filterName,
032                    Map<String, String> initParameterMap) {
033    
034                    _servletContext = servletContext;
035                    _filterName = filterName;
036                    _initParameterMap = initParameterMap;
037            }
038    
039            public String getFilterName() {
040                    return _filterName;
041            }
042    
043            public String getInitParameter(String key) {
044                    return _initParameterMap.get(key);
045            }
046    
047            public Enumeration<String> getInitParameterNames() {
048                    return new Enumeration<String>() {
049    
050                            public boolean hasMoreElements() {
051                                    return _keys.hasNext();
052                            }
053    
054                            public String nextElement() {
055                                    return _keys.next();
056                            }
057    
058                            private Iterator<String> _keys =
059                                    _initParameterMap.keySet().iterator();
060    
061                    };
062            }
063    
064            public ServletContext getServletContext() {
065                    return _servletContext;
066            }
067    
068            private String _filterName;
069            private Map<String, String> _initParameterMap;
070            private ServletContext _servletContext;
071    
072    }