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.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
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                    getMultiVMPool().clear();
031            }
032    
033            public static <K extends Serializable, V extends Serializable>
034                    PortalCache<K, V> getCache(String portalCacheName) {
035    
036                    return (PortalCache<K, V>)getMultiVMPool().getCache(portalCacheName);
037            }
038    
039            public static <K extends Serializable, V extends Serializable>
040                    PortalCache<K, V> getCache(String portalCacheName, boolean blocking) {
041    
042                    return (PortalCache<K, V>)getMultiVMPool().getCache(
043                            portalCacheName, blocking);
044            }
045    
046            public static <K extends Serializable, V extends Serializable>
047                    PortalCacheManager<K, V> getCacheManager() {
048    
049                    return (PortalCacheManager<K, V>)getMultiVMPool().getCacheManager();
050            }
051    
052            public static MultiVMPool getMultiVMPool() {
053                    PortalRuntimePermission.checkGetBeanProperty(MultiVMPoolUtil.class);
054    
055                    return _multiVMPool;
056            }
057    
058            public static void removeCache(String portalCacheName) {
059                    getMultiVMPool().removeCache(portalCacheName);
060            }
061    
062            public void setMultiVMPool(MultiVMPool multiVMPool) {
063                    PortalRuntimePermission.checkSetBeanProperty(getClass());
064    
065                    _multiVMPool = multiVMPool;
066            }
067    
068            private static MultiVMPool _multiVMPool;
069    
070    }