2
* Copyright 2003-2010 Terracotta, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package net.sf.ehcache.event;
19
import net.sf.ehcache.CacheException;
20
import net.sf.ehcache.Ehcache;
21
import net.sf.ehcache.Element;
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
29
* A Null Object Pattern implementation of CacheEventListener. It simply logs the calls made.
32
* @version $Id: NullCacheEventListener.java 2154 2010-04-06 02:45:52Z cdennis $
35
public class NullCacheEventListener implements CacheEventListener {
37
private static final Logger LOG = LoggerFactory.getLogger(NullCacheEventListener.class.getName());
43
public void notifyElementRemoved(final Ehcache cache, final Element element) {
44
if (LOG.isDebugEnabled()) {
45
LOG.debug("notifyElementRemoved called for cache " + cache + " for element with key " + element.getObjectKey());
52
public void notifyElementPut(final Ehcache cache, final Element element) {
55
if (element != null) {
56
key = element.getObjectKey();
58
if (LOG.isDebugEnabled()) {
59
LOG.debug("notifyElementPut called for cache " + cache.getName() + " for element with key " + key);
64
* Called immediately after an element has been put into the cache and the element already
65
* existed in the cache. This is thus an update.
67
* The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method
68
* will block until this method returns.
70
* Implementers may wish to have access to the Element's fields, including value, so the element is provided.
71
* Implementers should be careful not to modify the element. The effect of any modifications is undefined.
73
* @param cache the cache emitting the notification
74
* @param element the element which was just put into the cache.
76
public void notifyElementUpdated(final Ehcache cache, final Element element) throws CacheException {
79
if (element != null) {
80
key = element.getObjectKey();
82
if (LOG.isDebugEnabled()) {
83
LOG.debug("notifyElementUpdated called for cache " + cache.getName() + " for element with key " + key);
90
public void notifyElementExpired(final Ehcache cache, final Element element) {
91
if (LOG.isDebugEnabled()) {
92
LOG.debug("notifyElementExpired called for cache " + cache.getName() + " for element with key " + element.getObjectKey());
99
public void notifyElementEvicted(final Ehcache cache, final Element element) {
106
public void notifyRemoveAll(final Ehcache cache) {
111
* Give the replicator a chance to cleanup and free resources when no longer needed
113
public void dispose() {
118
* Creates a clone of this listener. This method will only be called by ehcache before a cache is initialized.
120
* This may not be possible for listeners after they have been initialized. Implementations should throw
121
* CloneNotSupportedException if they do not support clone.
124
* @throws CloneNotSupportedException if the listener could not be cloned.
126
public Object clone() throws CloneNotSupportedException {
127
return super.clone();