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