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 java.io.Serializable;
018    
019    import java.util.List;
020    
021    /**
022     * @author Shuyang Zhou
023     */
024    public class PortalCacheWrapper<K extends Serializable, V>
025            implements PortalCache<K, V> {
026    
027            public PortalCacheWrapper(PortalCache<K, V> portalCache) {
028                    this.portalCache = portalCache;
029            }
030    
031            @Override
032            public V get(K key) {
033                    return portalCache.get(key);
034            }
035    
036            @Override
037            public List<K> getKeys() {
038                    return portalCache.getKeys();
039            }
040    
041            /**
042             * @deprecated As of 7.0.0
043             */
044            @Deprecated
045            @Override
046            public String getName() {
047                    return portalCache.getName();
048            }
049    
050            @Override
051            public PortalCacheManager<K, V> getPortalCacheManager() {
052                    return portalCache.getPortalCacheManager();
053            }
054    
055            @Override
056            public String getPortalCacheName() {
057                    return portalCache.getPortalCacheName();
058            }
059    
060            public PortalCache<K, V> getWrappedPortalCache() {
061                    return portalCache;
062            }
063    
064            @Override
065            public void put(K key, V value) {
066                    portalCache.put(key, value);
067            }
068    
069            @Override
070            public void put(K key, V value, int timeToLive) {
071                    portalCache.put(key, value, timeToLive);
072            }
073    
074            @Override
075            public void registerPortalCacheListener(
076                    PortalCacheListener<K, V> portalCacheListener) {
077    
078                    portalCache.registerPortalCacheListener(portalCacheListener);
079            }
080    
081            @Override
082            public void registerPortalCacheListener(
083                    PortalCacheListener<K, V> portalCacheListener,
084                    PortalCacheListenerScope portalCacheListenerScope) {
085    
086                    portalCache.registerPortalCacheListener(
087                            portalCacheListener, portalCacheListenerScope);
088            }
089    
090            @Override
091            public void remove(K key) {
092                    portalCache.remove(key);
093            }
094    
095            @Override
096            public void removeAll() {
097                    portalCache.removeAll();
098            }
099    
100            public void setPortalCache(PortalCache<K, V> portalCache) {
101                    this.portalCache = portalCache;
102            }
103    
104            @Override
105            public void unregisterPortalCacheListener(
106                    PortalCacheListener<K, V> portalCacheListener) {
107    
108                    portalCache.unregisterPortalCacheListener(portalCacheListener);
109            }
110    
111            @Override
112            public void unregisterPortalCacheListeners() {
113                    portalCache.unregisterPortalCacheListeners();
114            }
115    
116            protected PortalCache<K, V> portalCache;
117    
118    }