01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.myfaces.context.servlet;
17:
18: import java.util.Enumeration;
19: import java.util.Map;
20:
21: import javax.servlet.ServletContext;
22:
23: import org.apache.myfaces.util.AbstractAttributeMap;
24:
25: /**
26: * ServletContext init parameters as Map.
27: *
28: * @author Anton Koinov (latest modification by $Author: mbr $)
29: * @version $Revision: 512417 $ $Date: 2007-02-27 22:22:36 +0100 (Di, 27 Feb 2007) $
30: */
31: public class InitParameterMap extends AbstractAttributeMap<String> {
32: final ServletContext _servletContext;
33:
34: InitParameterMap(ServletContext servletContext) {
35: _servletContext = servletContext;
36: }
37:
38: protected String getAttribute(String key) {
39: return _servletContext.getInitParameter(key);
40: }
41:
42: protected void setAttribute(String key, String value) {
43: throw new UnsupportedOperationException(
44: "Cannot set ServletContext InitParameter");
45: }
46:
47: protected void removeAttribute(String key) {
48: throw new UnsupportedOperationException(
49: "Cannot remove ServletContext InitParameter");
50: }
51:
52: @SuppressWarnings("unchecked")
53: protected Enumeration<String> getAttributeNames() {
54: return _servletContext.getInitParameterNames();
55: }
56:
57: public void putAll(Map t) {
58: throw new UnsupportedOperationException();
59: }
60:
61: public void clear() {
62: throw new UnsupportedOperationException();
63: }
64: }
|