001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.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 PortletContextBagPool {
024    
025            public static void clear() {
026                    _instance._portletContextBagPool.clear();
027            }
028    
029            public static PortletContextBag get(String servletContextName) {
030                    return _instance._get(servletContextName);
031            }
032    
033            public static void put(
034                    String servletContextName, PortletContextBag portletContextBag) {
035    
036                    _instance._put(servletContextName, portletContextBag);
037            }
038    
039            public static PortletContextBag remove(String servletContextName) {
040                    return _instance._remove(servletContextName);
041            }
042    
043            private PortletContextBagPool() {
044                    _portletContextBagPool =
045                            new ConcurrentHashMap<String, PortletContextBag>();
046            }
047    
048            private PortletContextBag _get(String servletContextName) {
049                    return _portletContextBagPool.get(servletContextName);
050            }
051    
052            private void _put(
053                    String servletContextName, PortletContextBag portletContextBag) {
054    
055                    _portletContextBagPool.put(servletContextName, portletContextBag);
056            }
057    
058            private PortletContextBag _remove(String servletContextName) {
059                    return _portletContextBagPool.remove(servletContextName);
060            }
061    
062            private static PortletContextBagPool _instance =
063                    new PortletContextBagPool();
064    
065            private Map<String, PortletContextBag>_portletContextBagPool;
066    
067    }