View Javadoc

1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.services.cache;
16  
17  /**
18   * Interface defining a manager of 3rd level (ie. application level) caches.
19   * This allow us to later define implementations that are encapsulation of
20   * market existing Cache provider (EHCache, JBossTree, SwarmCache, ...).
21   * <br/>
22   * Our manager only needs to have basic methods for startup, retrieval and
23   * shutdown of caches.
24   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
25   * @version $Revision: 1.2 $
26   */
27  public interface CacheManager{
28  
29     // Public -------------------------------------------------------------------
30  
31     /**
32      * Clear (ie. flush) all managed caches. They should now be empty
33      * after this method call. If a cache cannot be cleared, best effort
34      * should be done to clear all other caches.
35      * @throws CacheException if at least one of the caches cannot be cleared 
36      */
37     public abstract void clearCaches() throws CacheException;
38  
39     /**
40      * Create all managed caches. This method should be called during
41      * Join application initialization phase. Typically, implementation shall :
42      * read its configuration, build its manager and caches (& fetch some data ?).
43      * @throws CacheException if at least one of the caches cannot be created
44      */
45     public abstract void createCaches() throws CacheException;
46  
47  
48     /**
49      * Retrieve a Cache using its key
50      * @param key The key within is store the cache into the manager
51      * @return The retrieved Cache or null if there's no corresponding cache
52      */
53     public abstract Cache getCache(String key);
54  }