1 /**
2 * Copyright 2003-2006 Greg Luck
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 package net.sf.ehcache.event;
18
19 /**
20 * Allows implementers to register callback methods that will be executed when a <code>CacheManager</code> event occurs.
21 * The events include:
22 * <ol>
23 * <li>adding a <code>Cache</code>
24 * <li>removing a <code>Cache</code>
25 * </ol>
26 * <p/>
27 * Callbacks to these methods are synchronous and unsynchronized. It is the responsibility of the implementer
28 * to safely handle the potential performance and thread safety issues depending on what their listener is doing.
29 * @author Greg Luck
30 * @version $Id: CacheManagerEventListener.java 28 2006-04-15 05:12:32Z gregluck $
31 * @since 1.2
32 * @see CacheEventListener
33 */
34 public interface CacheManagerEventListener {
35
36
37 /**
38 * Called immediately after a cache has been added and activated.
39 * <p/>
40 * Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized
41 * method on CacheManager from this method will cause a deadlock.
42 * <p/>
43 * Note that activation will also cause a CacheEventListener status change notification from
44 * {@link net.sf.ehcache.Status#STATUS_UNINITIALISED} to {@link net.sf.ehcache.Status#STATUS_ALIVE}. Care should be
45 * taken on processing that notification because:
46 * <ul>
47 * <li>the cache will not yet be accessible from the CacheManager.
48 * <li>the addCaches methods whih cause this notification are synchronized on the CacheManager. An attempt to call
49 * {@link net.sf.ehcache.CacheManager#getCache(String)} will cause a deadlock.
50 * </ul>
51 * The calling method will block until this method returns.
52 * <p/>
53 * @param cacheName the name of the <code>Cache</code> the operation relates to
54 * @see CacheEventListener
55 */
56 void notifyCacheAdded(String cacheName);
57
58 /**
59 * Called immediately after a cache has been disposed and removed. The calling method will block until
60 * this method returns.
61 * <p/>
62 * Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized
63 * method on CacheManager from this method will cause a deadlock.
64 * <p/>
65 * Note that a {@link CacheEventListener} status changed will also be triggered. Any attempt from that notification
66 * to access CacheManager will also result in a deadlock.
67 * @param cacheName the name of the <code>Cache</code> the operation relates to
68 */
69 void notifyCacheRemoved(String cacheName);
70
71 }