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;
016    
017    import java.util.Collections;
018    import java.util.Enumeration;
019    import java.util.Map;
020    
021    import javax.servlet.ServletConfig;
022    import javax.servlet.ServletContext;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class DynamicServletConfig implements ServletConfig {
028    
029            public DynamicServletConfig(
030                    ServletConfig servletConfig, Map<String, String> params) {
031    
032                    _servletConfig = servletConfig;
033                    _params = params;
034            }
035    
036            @Override
037            public String getInitParameter(String name) {
038                    return _params.get(name);
039            }
040    
041            @Override
042            public Enumeration<String> getInitParameterNames() {
043                    return Collections.enumeration(_params.keySet());
044            }
045    
046            @Override
047            public ServletContext getServletContext() {
048                    return _servletConfig.getServletContext();
049            }
050    
051            @Override
052            public String getServletName() {
053                    return _servletConfig.getServletName();
054            }
055    
056            private Map<String, String> _params;
057            private ServletConfig _servletConfig;
058    
059    }