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 com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
018    import com.liferay.portal.kernel.util.ProxyFactory;
019    
020    import java.io.Serializable;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     * @author Michael Young
025     */
026    @OSGiBeanProperties(service = SingleVMPoolUtil.class)
027    public class SingleVMPoolUtil {
028    
029            public static void clear() {
030                    _singleVMPool.clear();
031            }
032    
033            /**
034             * @deprecated As of 7.0.0, replaced by {@link #getPortalCache(String)}
035             */
036            @Deprecated
037            public static <K extends Serializable, V> PortalCache<K, V> getCache(
038                    String portalCacheName) {
039    
040                    return getPortalCache(portalCacheName);
041            }
042    
043            /**
044             * @deprecated As of 7.0.0, replaced by {@link #getPortalCache(String,
045             *             boolean)}
046             */
047            @Deprecated
048            public static <K extends Serializable, V> PortalCache<K, V> getCache(
049                    String portalCacheName, boolean blocking) {
050    
051                    return getPortalCache(portalCacheName, blocking);
052            }
053    
054            /**
055             * @deprecated As of 7.0.0, replaced by {@link #getPortalCacheManager()}
056             */
057            @Deprecated
058            public static <K extends Serializable, V> PortalCacheManager<K, V>
059                    getCacheManager() {
060    
061                    return getPortalCacheManager();
062            }
063    
064            public static <K extends Serializable, V> PortalCache<K, V> getPortalCache(
065                    String portalCacheName) {
066    
067                    return (PortalCache<K, V>)_singleVMPool.getPortalCache(portalCacheName);
068            }
069    
070            public static <K extends Serializable, V> PortalCache<K, V> getPortalCache(
071                    String portalCacheName, boolean blocking) {
072    
073                    return (PortalCache<K, V>)_singleVMPool.getPortalCache(
074                            portalCacheName, blocking);
075            }
076    
077            public static <K extends Serializable, V> PortalCacheManager<K, V>
078                    getPortalCacheManager() {
079    
080                    return (PortalCacheManager<K, V>)_singleVMPool.getPortalCacheManager();
081            }
082    
083            /**
084             * @deprecated As of 7.0.0, replaced by {@link #removePortalCache(String)}
085             */
086            @Deprecated
087            public static void removeCache(String portalCacheName) {
088                    removePortalCache(portalCacheName);
089            }
090    
091            public static void removePortalCache(String portalCacheName) {
092                    _singleVMPool.removePortalCache(portalCacheName);
093            }
094    
095            private static final SingleVMPool _singleVMPool =
096                    ProxyFactory.newServiceTrackedInstance(SingleVMPool.class);
097    
098    }