001
014
015 package com.liferay.portal.util;
016
017 import java.util.Map;
018 import java.util.concurrent.ConcurrentHashMap;
019
020
023 public class WebAppPool {
024
025 public static Object get(String webAppId, String key) {
026 return _instance._get(webAppId, key);
027 }
028
029 public static void put(String webAppId, String key, Object obj) {
030 _instance._put(webAppId, key, obj);
031 }
032
033 public static Object remove(String webAppId, String key) {
034 return _instance._remove(webAppId, key);
035 }
036
037 private WebAppPool() {
038 _webAppPool = new ConcurrentHashMap<String, Map<String, Object>>();
039 }
040
041 private Object _get(String webAppId, String key) {
042 Map<String, Object> map = _webAppPool.get(webAppId);
043
044 if (map == null) {
045 return null;
046 }
047 else {
048 return map.get(key);
049 }
050 }
051
052 private void _put(String webAppId, String key, Object obj) {
053 Map<String, Object> map = _webAppPool.get(webAppId);
054
055 if (map == null) {
056 map = new ConcurrentHashMap<String, Object>();
057
058 _webAppPool.put(webAppId, map);
059 }
060
061 map.put(key, obj);
062 }
063
064 private Object _remove(String webAppId, String key) {
065 Map<String, Object> map = _webAppPool.get(webAppId);
066
067 if (map == null) {
068 return null;
069 }
070 else {
071 return map.remove(key);
072 }
073 }
074
075 private static WebAppPool _instance = new WebAppPool();
076
077 private Map<String, Map<String, Object>> _webAppPool;
078
079 }