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.portal.kernel.cache;
016    
017    import java.io.Serializable;
018    
019    import java.util.Collection;
020    import java.util.Collections;
021    import java.util.Map;
022    import java.util.concurrent.ConcurrentHashMap;
023    
024    /**
025     * @author Tina Tian
026     */
027    public class PortalCacheProvider {
028    
029            public static PortalCacheManager<? extends Serializable, ?>
030                    getPortalCacheManager(String portalCacheManagerName) {
031    
032                    return _portalCacheManagers.get(portalCacheManagerName);
033            }
034    
035            public static Collection<PortalCacheManager<? extends Serializable, ?>>
036                    getPortalCacheManagers() {
037    
038                    return Collections.unmodifiableCollection(
039                            _portalCacheManagers.values());
040            }
041    
042            public static void registerPortalCacheManager(
043                    PortalCacheManager<? extends Serializable, ?> portalCacheManager) {
044    
045                    _portalCacheManagers.put(
046                            portalCacheManager.getName(), portalCacheManager);
047            }
048    
049            public static void unregisterPortalCacheManager(
050                    String portalCacheManagerName) {
051    
052                    _portalCacheManagers.remove(portalCacheManagerName);
053            }
054    
055            private static final
056                    Map<String, PortalCacheManager<? extends Serializable, ?>>
057                            _portalCacheManagers =
058                                    new ConcurrentHashMap
059                                            <String, PortalCacheManager<? extends Serializable, ?>>();
060    
061    }