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 = MultiVMPoolUtil.class)
027    public class MultiVMPoolUtil {
028    
029            public static void clear() {
030                    _multiVMPool.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 extends Serializable>
038                    PortalCache<K, V> getCache(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 extends Serializable>
049                    PortalCache<K, V> getCache(
050                            String portalCacheName, boolean blocking) {
051    
052                    return getPortalCache(portalCacheName, blocking);
053            }
054    
055            /**
056             * @deprecated As of 7.0.0, replaced by {@link #getPortalCacheManager()}
057             */
058            @Deprecated
059            public static <K extends Serializable, V extends Serializable>
060                    PortalCacheManager<K, V> getCacheManager() {
061    
062                    return getPortalCacheManager();
063            }
064    
065            public static <K extends Serializable, V extends Serializable>
066                    PortalCache<K, V> getPortalCache(String portalCacheName) {
067    
068                    return (PortalCache<K, V>)_multiVMPool.getPortalCache(portalCacheName);
069            }
070    
071            public static <K extends Serializable, V extends Serializable>
072                    PortalCache<K, V> getPortalCache(
073                            String portalCacheName, boolean blocking) {
074    
075                    return (PortalCache<K, V>)_multiVMPool.getPortalCache(
076                            portalCacheName, blocking);
077            }
078    
079            public static <K extends Serializable, V extends Serializable>
080                    PortalCacheManager<K, V> getPortalCacheManager() {
081    
082                    return (PortalCacheManager<K, V>)_multiVMPool.getPortalCacheManager();
083            }
084    
085            /**
086             * @deprecated As of 7.0.0, replaced by {@link #removePortalCache(String)}
087             */
088            @Deprecated
089            public static void removeCache(String portalCacheName) {
090                    removePortalCache(portalCacheName);
091            }
092    
093            public static void removePortalCache(String portalCacheName) {
094                    _multiVMPool.removePortalCache(portalCacheName);
095            }
096    
097            private static final MultiVMPool _multiVMPool =
098                    ProxyFactory.newServiceTrackedInstance(MultiVMPool.class);
099    
100    }