001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }