View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
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  package net.sf.ehcache.writer;
17  
18  import net.sf.ehcache.Cache;
19  import net.sf.ehcache.CacheEntry;
20  import net.sf.ehcache.CacheException;
21  import net.sf.ehcache.Element;
22  
23  /***
24   * A {@code CacheWriterManager} coordinates how element are written to a back-end store.
25   * <p/>
26   * The {@code CacheWriterManager} will in its turn call the {@code CacheWriter} that belongs to the relevant cache to perform
27   * the actual write logic as it's implemented by the user.
28   *
29   * @author Geert Bevin
30   * @version $Id: CacheWriterManager.html 13146 2011-08-01 17:12:39Z oletizi $
31   */
32  public interface CacheWriterManager {
33      /***
34       * Initialize the cache writer manager.
35       * <p>
36       * This method is called when the cache writer manager is registered to a cache.
37       *
38       * @param cache the cache with which the writer manager
39       * @throws CacheException when an exception occurs during the initialisation of the cache
40       */
41      void init(Cache cache) throws CacheException;
42  
43      /***
44       * Schedule a put operation for this element in the CacheWriterManager, which will call the CacheWriter when appropriate.
45       *
46       * @param element the element that should be used for the operation
47       * @throws CacheException when an exception occurs during the writing of the element
48       */
49      void put(Element element) throws CacheException;
50  
51      /***
52       * Schedule a remove operation for this key in the CacheWriterManager, which will call the CacheWriter when appropriate.
53       *
54       * @param entry the entry that should be used for the operation
55       * @throws CacheException when an exception occurs during the removal of the element
56       */
57      void remove(CacheEntry entry) throws CacheException;
58  
59      /***
60       * Cleans up the resources of the cache writer manager.
61       * <p>
62       * This method is called when the manager is unregistered from a cache.
63       */
64      void dispose() throws CacheException;
65  }