1
14
15 package com.liferay.portal.util;
16
17 import java.util.Map;
18 import java.util.concurrent.ConcurrentHashMap;
19
20
25 public class WebAppPool {
26
27 public static Object get(String webAppId, String key) {
28 return _instance._get(webAppId, key);
29 }
30
31 public static void put(String webAppId, String key, Object obj) {
32 _instance._put(webAppId, key, obj);
33 }
34
35 public static Object remove(String webAppId, String key) {
36 return _instance._remove(webAppId, key);
37 }
38
39 private WebAppPool() {
40 _webAppPool = new ConcurrentHashMap<String, Map<String, Object>>();
41 }
42
43 private Object _get(String webAppId, String key) {
44 Map<String, Object> map = _webAppPool.get(webAppId);
45
46 if (map == null) {
47 return null;
48 }
49 else {
50 return map.get(key);
51 }
52 }
53
54 private void _put(String webAppId, String key, Object obj) {
55 Map<String, Object> map = _webAppPool.get(webAppId);
56
57 if (map == null) {
58 map = new ConcurrentHashMap<String, Object>();
59
60 _webAppPool.put(webAppId, map);
61 }
62
63 map.put(key, obj);
64 }
65
66 private Object _remove(String webAppId, String key) {
67 Map<String, Object> map = _webAppPool.get(webAppId);
68
69 if (map == null) {
70 return null;
71 }
72 else {
73 return map.remove(key);
74 }
75 }
76
77 private static WebAppPool _instance = new WebAppPool();
78
79 private Map<String, Map<String, Object>> _webAppPool;
80
81 }