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.CacheEntry;
19  import net.sf.ehcache.CacheException;
20  import net.sf.ehcache.Ehcache;
21  import net.sf.ehcache.Element;
22  
23  import java.util.Collection;
24  
25  /***
26   * A convenience abstract base class that implements all {@code CacheWriter} methods.
27   * <p/>
28   * The {@link #write}, {@link #writeAll}, {@link #delete} and {@link #deleteAll} methods throw
29   * {@code UnsupportedOperationException} unless they're overridden by the class that is extending
30   * {@code AbstractCacheWriter}. Classes that are extending this abstract base class should make sure that the
31   * appropriate cache writer operation methods are implemented with their application functionalities.
32   *
33   * @author Geert Bevin
34   * @version $Id: AbstractCacheWriter.html 13146 2011-08-01 17:12:39Z oletizi $
35   */
36  public abstract class AbstractCacheWriter implements CacheWriter {
37      /***
38       * {@inheritDoc}
39       */
40      public void write(Element element) throws CacheException {
41          throw new UnsupportedOperationException();
42      }
43  
44      /***
45       * {@inheritDoc}
46       */
47      public void writeAll(Collection<Element> elements) throws CacheException {
48          throw new UnsupportedOperationException();
49      }
50  
51      /***
52       * {@inheritDoc}
53       */
54      public void delete(CacheEntry entry) throws CacheException {
55          throw new UnsupportedOperationException();
56      }
57  
58      /***
59       * {@inheritDoc}
60       */
61      public void deleteAll(Collection<CacheEntry> entries) throws CacheException {
62          throw new UnsupportedOperationException();
63      }
64  
65      /***
66       * {@inheritDoc}
67       */
68      public CacheWriter clone(Ehcache cache) throws CloneNotSupportedException {
69          throw new CloneNotSupportedException();
70      }
71  
72      /***
73       * {@inheritDoc}
74       */
75      public void init() {
76          // no-op
77      }
78  
79      /***
80       * {@inheritDoc}
81       */
82      public void dispose() throws CacheException {
83          // no-op
84      }
85  }