001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.portlet;
016    
017    import java.util.Map;
018    import java.util.concurrent.ConcurrentHashMap;
019    
020    /**
021     * @author Brian Wing Shun Chan
022     */
023    public class PortletBagPool {
024    
025            public static PortletBag get(String portletId) {
026                    return _instance._get(portletId);
027            }
028    
029            public static void put(String portletId, PortletBag portletBag) {
030                    _instance._put(portletId, portletBag);
031            }
032    
033            public static PortletBag remove(String portletId) {
034                    return _instance._remove(portletId);
035            }
036    
037            public static void reset() {
038                    _instance = new PortletBagPool();
039            }
040    
041            private PortletBagPool() {
042                    _portletBagPool = new ConcurrentHashMap<String, PortletBag>();
043            }
044    
045            private PortletBag _get(String portletId) {
046                    return _portletBagPool.get(portletId);
047            }
048    
049            private void _put(String portletId, PortletBag portletBag) {
050                    _portletBagPool.put(portletId, portletBag);
051            }
052    
053            private PortletBag _remove(String portletId) {
054                    return _portletBagPool.remove(portletId);
055            }
056    
057            private static PortletBagPool _instance = new PortletBagPool();
058    
059            private Map<String, PortletBag>_portletBagPool;
060    
061    }