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.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    }