001
014
015 package com.liferay.portal.kernel.portlet;
016
017 import com.liferay.portal.kernel.security.pacl.PACLConstants;
018 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019
020 import java.util.Map;
021 import java.util.concurrent.ConcurrentHashMap;
022
023
026 public class PortletBagPool {
027
028 public static PortletBag get(String portletId) {
029 PortalRuntimePermission.checkPortletBagPool(portletId);
030
031 return _instance._get(portletId);
032 }
033
034 public static void put(String portletId, PortletBag portletBag) {
035 PortalRuntimePermission.checkPortletBagPool(portletId);
036
037 _instance._put(portletId, portletBag);
038 }
039
040 public static PortletBag remove(String portletId) {
041 PortalRuntimePermission.checkPortletBagPool(portletId);
042
043 return _instance._remove(portletId);
044 }
045
046 public static void reset() {
047 PortalRuntimePermission.checkPortletBagPool(
048 PACLConstants.
049 PORTAL_RUNTIME_PERMISSION_PORTLET_BAG_POOL_ALL_PORTLETS);
050
051 _instance._reset();
052 }
053
054 private PortletBagPool() {
055 _portletBagPool = new ConcurrentHashMap<String, PortletBag>();
056 }
057
058 private PortletBag _get(String portletId) {
059 return _portletBagPool.get(portletId);
060 }
061
062 private void _put(String portletId, PortletBag portletBag) {
063 _portletBagPool.put(portletId, portletBag);
064 }
065
066 private PortletBag _remove(String portletId) {
067 return _portletBagPool.remove(portletId);
068 }
069
070 private void _reset() {
071 _portletBagPool.clear();
072 }
073
074 private static PortletBagPool _instance = new PortletBagPool();
075
076 private Map<String, PortletBag> _portletBagPool;
077
078 }