1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.util.bridges.jsf.sun;
16  
17  import java.util.AbstractMap;
18  import java.util.Set;
19  
20  import javax.servlet.ServletContext;
21  
22  /**
23   * <a href="LiferayApplicationMap.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Neil Griffin
26   */
27  public class LiferayApplicationMap extends AbstractMap<String, Object> {
28  
29      public LiferayApplicationMap(ServletContext servletContext) {
30          _servletContext = servletContext;
31      }
32  
33      public Set<Entry<String, Object>> entrySet() {
34          throw new UnsupportedOperationException();
35      }
36  
37      public Object get(Object key) {
38          return _servletContext.getAttribute(key.toString());
39      }
40  
41      public Object put(String key, Object value) {
42          Object previousValue = get(key);
43  
44          _servletContext.setAttribute(key.toString(), value);
45  
46          return previousValue;
47      }
48  
49      public Object remove(Object key) {
50          Object value = null;
51  
52          if (key != null) {
53              value = get(key);
54  
55              _servletContext.removeAttribute(key.toString());
56          }
57  
58          return value;
59      }
60  
61      private ServletContext _servletContext;
62  
63  }