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