001    /**
002     * Copyright (c) 2000-2010 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.util.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            public String getInitParameter(String name) {
037                    return _params.get(name);
038            }
039    
040            public Enumeration<String> getInitParameterNames() {
041                    return Collections.enumeration(_params.keySet());
042            }
043    
044            public ServletContext getServletContext() {
045                    return _servletConfig.getServletContext();
046            }
047    
048            public String getServletName() {
049                    return _servletConfig.getServletName();
050            }
051    
052            private ServletConfig _servletConfig;
053            private Map<String, String> _params;
054    
055    }