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 = SingleVMPoolUtil.class)
027    public class SingleVMPoolUtil {
028    
029            public static void clear() {
030                    getSingleVMPool().clear();
031            }
032    
033            public static <K extends Serializable, V> PortalCache<K, V> getCache(
034                    String portalCacheName) {
035    
036                    return (PortalCache<K, V>)getSingleVMPool().getCache(portalCacheName);
037            }
038    
039            public static <K extends Serializable, V> PortalCache<K, V> getCache(
040                    String portalCacheName, boolean blocking) {
041    
042                    return (PortalCache<K, V>)getSingleVMPool().getCache(
043                            portalCacheName, blocking);
044            }
045    
046            public static <K extends Serializable, V> PortalCacheManager<K, V>
047                    getCacheManager() {
048    
049                    return (PortalCacheManager<K, V>)getSingleVMPool().getCacheManager();
050            }
051    
052            public static SingleVMPool getSingleVMPool() {
053                    PortalRuntimePermission.checkGetBeanProperty(SingleVMPoolUtil.class);
054    
055                    return _singleVMPool;
056            }
057    
058            public static void removeCache(String portalCacheName) {
059                    getSingleVMPool().removeCache(portalCacheName);
060            }
061    
062            public void setSingleVMPool(SingleVMPool singleVMPool) {
063                    PortalRuntimePermission.checkSetBeanProperty(getClass());
064    
065                    _singleVMPool = singleVMPool;
066            }
067    
068            private static SingleVMPool _singleVMPool;
069    
070    }