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.PortalCache;
018    import com.liferay.portal.kernel.cache.PortalCacheManager;
019    import com.liferay.portal.kernel.cache.SingleVMPool;
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 SingleVMPoolImpl implements SingleVMPool {
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(
081                    PortalCache portalCache, String key, Object value, int timeToLive) {
082    
083                    portalCache.put(key, value, timeToLive);
084            }
085    
086            /**
087             * @deprecated
088             */
089            @Override
090            public void put(PortalCache portalCache, String key, Serializable value) {
091                    portalCache.put(key, value);
092            }
093    
094            /**
095             * @deprecated
096             */
097            @Override
098            public void put(
099                    PortalCache portalCache, String key, Serializable value,
100                    int timeToLive) {
101    
102                    portalCache.put(key, value, timeToLive);
103            }
104    
105            @Override
106            public void put(String name, String key, Object value) {
107                    PortalCache portalCache = getCache(name);
108    
109                    portalCache.put(key, value);
110            }
111    
112            @Override
113            public void put(String name, String key, Serializable value) {
114                    PortalCache portalCache = getCache(name);
115    
116                    portalCache.put(key, value);
117            }
118    
119            /**
120             * @deprecated
121             */
122            @Override
123            public void remove(PortalCache portalCache, String key) {
124                    portalCache.remove(key);
125            }
126    
127            @Override
128            public void remove(String name, String key) {
129                    PortalCache portalCache = getCache(name);
130    
131                    portalCache.remove(key);
132            }
133    
134            @Override
135            public void removeCache(String name) {
136                    _portalCacheManager.removeCache(name);
137            }
138    
139            public void setPortalCacheManager(PortalCacheManager portalCacheManager) {
140                    _portalCacheManager = portalCacheManager;
141            }
142    
143            private PortalCacheManager _portalCacheManager;
144    
145    }