001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.cache.keypool;
016    
017    import com.liferay.portal.kernel.cache.CacheListener;
018    import com.liferay.portal.kernel.cache.PortalCache;
019    
020    import java.io.Serializable;
021    
022    /**
023     * @author Edward Han
024     * @author Brian Wing Shun Chan
025     */
026    public class MultiVMKeyPoolCacheListener implements CacheListener {
027    
028            public MultiVMKeyPoolCacheListener(PortalCache localPortalCache) {
029                    _localPortalCache = localPortalCache;
030            }
031    
032            @Override
033            public void notifyEntryEvicted(
034                    PortalCache portalCache, Serializable key, Object value) {
035    
036                    _localPortalCache.remove(key);
037            }
038    
039            @Override
040            public void notifyEntryExpired(
041                    PortalCache portalCache, Serializable key, Object value) {
042    
043                    _localPortalCache.remove(key);
044            }
045    
046            @Override
047            public void notifyEntryPut(
048                    PortalCache portalCache, Serializable key, Object value) {
049    
050                    _localPortalCache.put(key, value);
051            }
052    
053            @Override
054            public void notifyEntryRemoved(
055                    PortalCache portalCache, Serializable key, Object value) {
056    
057                    _localPortalCache.remove(key);
058            }
059    
060            @Override
061            public void notifyEntryUpdated(
062                    PortalCache portalCache, Serializable key, Object value) {
063    
064                    _localPortalCache.put(key, value);
065            }
066    
067            @Override
068            public void notifyRemoveAll(PortalCache portalCache) {
069                    _localPortalCache.removeAll();
070            }
071    
072            private PortalCache _localPortalCache;
073    
074    }