KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > context > servlet > HttpServletContextMap


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package org.springframework.webflow.context.servlet;
17
18 import java.util.Iterator JavaDoc;
19
20 import javax.servlet.ServletContext JavaDoc;
21
22 import org.springframework.binding.collection.SharedMap;
23 import org.springframework.binding.collection.StringKeyedMapAdapter;
24 import org.springframework.webflow.core.collection.CollectionUtils;
25
26 /**
27  * Map backed by the Servlet context for accessing application scoped
28  * attributes.
29  *
30  * @author Keith Donald
31  */

32 public class HttpServletContextMap extends StringKeyedMapAdapter implements SharedMap {
33
34     /**
35      * The wrapped servlet context.
36      */

37     private ServletContext JavaDoc context;
38
39     /**
40      * Create a map wrapping given servlet context.
41      */

42     public HttpServletContextMap(ServletContext JavaDoc context) {
43         this.context = context;
44     }
45
46     protected Object JavaDoc getAttribute(String JavaDoc key) {
47         return context.getAttribute(key);
48     }
49
50     protected void setAttribute(String JavaDoc key, Object JavaDoc value) {
51         context.setAttribute(key, value);
52     }
53
54     protected void removeAttribute(String JavaDoc key) {
55         context.removeAttribute(key);
56     }
57
58     protected Iterator JavaDoc getAttributeNames() {
59         return CollectionUtils.toIterator(context.getAttributeNames());
60     }
61
62     public Object JavaDoc getMutex() {
63         return context;
64     }
65 }
Popular Tags