001    /**
002     * Copyright (c) 2000-2013 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            @Override
040            public String getFilterName() {
041                    return _filterName;
042            }
043    
044            @Override
045            public String getInitParameter(String key) {
046                    return _initParameterMap.get(key);
047            }
048    
049            @Override
050            public Enumeration<String> getInitParameterNames() {
051                    return new Enumeration<String>() {
052    
053                            @Override
054                            public boolean hasMoreElements() {
055                                    return _keys.hasNext();
056                            }
057    
058                            @Override
059                            public String nextElement() {
060                                    return _keys.next();
061                            }
062    
063                            private Iterator<String> _keys =
064                                    _initParameterMap.keySet().iterator();
065    
066                    };
067            }
068    
069            @Override
070            public ServletContext getServletContext() {
071                    return _servletContext;
072            }
073    
074            private String _filterName;
075            private Map<String, String> _initParameterMap;
076            private ServletContext _servletContext;
077    
078    }