001    /**
002     * Copyright (c) 2000-present 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.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 = new ConcurrentHashMap<>();
045            }
046    
047            private PortletContextBag _get(String servletContextName) {
048                    return _portletContextBagPool.get(servletContextName);
049            }
050    
051            private void _put(
052                    String servletContextName, PortletContextBag portletContextBag) {
053    
054                    _portletContextBagPool.put(servletContextName, portletContextBag);
055            }
056    
057            private PortletContextBag _remove(String servletContextName) {
058                    return _portletContextBagPool.remove(servletContextName);
059            }
060    
061            private static final PortletContextBagPool _instance =
062                    new PortletContextBagPool();
063    
064            private final Map<String, PortletContextBag> _portletContextBagPool;
065    
066    }