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.cache.ehcache;
016    
017    import com.liferay.portal.kernel.cache.CacheManagerListener;
018    
019    import net.sf.ehcache.Status;
020    import net.sf.ehcache.event.CacheManagerEventListener;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class PortalCacheManagerEventListener
026            implements CacheManagerEventListener {
027    
028            public PortalCacheManagerEventListener(
029                    CacheManagerListener cacheManagerListener) {
030    
031                    _cacheManagerListener = cacheManagerListener;
032            }
033    
034            @Override
035            public void dispose() {
036                    _cacheManagerListener.dispose();
037            }
038    
039            @Override
040            public boolean equals(Object obj) {
041                    if (this == obj) {
042                            return true;
043                    }
044    
045                    if (!(obj instanceof PortalCacheManagerEventListener)) {
046                            return false;
047                    }
048    
049                    PortalCacheManagerEventListener portalCacheManagerEventListener =
050                            (PortalCacheManagerEventListener)obj;
051    
052                    return _cacheManagerListener.equals(
053                            portalCacheManagerEventListener._cacheManagerListener);
054            }
055    
056            public CacheManagerListener getCacheManagerListener() {
057                    return _cacheManagerListener;
058            }
059    
060            @Override
061            public Status getStatus() {
062                    return Status.STATUS_ALIVE;
063            }
064    
065            @Override
066            public int hashCode() {
067                    return _cacheManagerListener.hashCode();
068            }
069    
070            @Override
071            public void init() {
072                    _cacheManagerListener.init();
073            }
074    
075            @Override
076            public void notifyCacheAdded(String name) {
077                    _cacheManagerListener.notifyCacheAdded(name);
078            }
079    
080            @Override
081            public void notifyCacheRemoved(String name) {
082                    _cacheManagerListener.notifyCacheRemoved(name);
083            }
084    
085            private final CacheManagerListener _cacheManagerListener;
086    
087    }