001    /**
002     * Copyright (c) 2000-2013 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.cache;
016    
017    import com.liferay.portal.kernel.cache.MultiVMPool;
018    import com.liferay.portal.kernel.cache.PortalCache;
019    import com.liferay.portal.kernel.cache.PortalCacheManager;
020    import com.liferay.portal.kernel.security.pacl.DoPrivileged;
021    
022    import java.io.Serializable;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     * @author Michael Young
027     */
028    @DoPrivileged
029    public class MultiVMPoolImpl implements MultiVMPool {
030    
031            @Override
032            public void clear() {
033                    _portalCacheManager.clearAll();
034            }
035    
036            @Override
037            public void clear(String name) {
038                    PortalCache portalCache = getCache(name);
039    
040                    portalCache.removeAll();
041            }
042    
043            /**
044             * @deprecated
045             */
046            @Override
047            public Object get(PortalCache portalCache, String key) {
048                    return portalCache.get(key);
049            }
050    
051            @Override
052            public Object get(String name, String key) {
053                    PortalCache portalCache = getCache(name);
054    
055                    return portalCache.get(key);
056            }
057    
058            @Override
059            public PortalCache getCache(String name) {
060                    return _portalCacheManager.getCache(name);
061            }
062    
063            @Override
064            public PortalCache getCache(String name, boolean blocking) {
065                    return _portalCacheManager.getCache(name, blocking);
066            }
067    
068            /**
069             * @deprecated
070             */
071            @Override
072            public void put(PortalCache portalCache, String key, Object value) {
073                    portalCache.put(key, value);
074            }
075    
076            /**
077             * @deprecated
078             */
079            @Override
080            public void put(PortalCache portalCache, String key, Serializable value) {
081                    portalCache.put(key, value);
082            }
083    
084            @Override
085            public void put(String name, String key, Object value) {
086                    PortalCache portalCache = getCache(name);
087    
088                    portalCache.put(key, value);
089            }
090    
091            @Override
092            public void put(String name, String key, Serializable value) {
093                    PortalCache portalCache = getCache(name);
094    
095                    portalCache.put(key, value);
096            }
097    
098            /**
099             * @deprecated
100             */
101            @Override
102            public void remove(PortalCache portalCache, String key) {
103                    portalCache.remove(key);
104            }
105    
106            @Override
107            public void remove(String name, String key) {
108                    PortalCache portalCache = getCache(name);
109    
110                    portalCache.remove(key);
111            }
112    
113            @Override
114            public void removeCache(String name) {
115                    _portalCacheManager.removeCache(name);
116            }
117    
118            public void setPortalCacheManager(PortalCacheManager portalCacheManager) {
119                    _portalCacheManager = portalCacheManager;
120            }
121    
122            private PortalCacheManager _portalCacheManager;
123    
124    }