View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
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 de.smartics.properties.spi.config.cache;
17  
18  import java.util.Set;
19  
20  /**
21   * Interface to use caches. Two different kinds of caches have to be supported.
22   * One implementing {@link UnawareCache} and one implementing {@link Cache}. The
23   * reason is that we do not need to support some Methods for a properties cache,
24   * so that here the a <code>UnawreCache</code> implementation is sufficient. But
25   * for configurations we also need the additional method supported by
26   * <code>Cache</code>. Its totally legal to use the same Cache implementation
27   * for both use-cases.
28   */
29  public interface CacheManager
30  {
31    // ********************************* Fields *********************************
32  
33    // --- constants ------------------------------------------------------------
34  
35    // ****************************** Initializer *******************************
36  
37    // ****************************** Inner Classes *****************************
38  
39    // ********************************* Methods ********************************
40  
41    // --- get&set --------------------------------------------------------------
42  
43    // --- business -------------------------------------------------------------
44  
45    /**
46     * Removes all keys from all caches.
47     */
48    void clearAll();
49  
50    /**
51     * Clears the cache with the given name.
52     *
53     * @param cacheName the name of the cache to be cleared.
54     */
55    void clear(String cacheName);
56  
57    /**
58     * Clears and stops the cache.
59     *
60     * @param cacheName the name of the cache to be cleared and stopped.
61     */
62    void discard(String cacheName);
63  
64    /**
65     * Stops all caches, rendering the manager in a stopped state.
66     */
67    void stopAll();
68  
69    /**
70     * Stops the cache with the given name.
71     *
72     * @param cacheName the name of the cache to stop.
73     */
74    void stop(String cacheName);
75  
76    /**
77     * Returns the properties cache with the given name. The cache is already
78     * started.
79     *
80     * @param cacheName the name of the cache to fetch.
81     * @return the requested cache already started.
82     */
83    UnawareCache<?, ?> getPropertiesCache(String cacheName);
84  
85    /**
86     * Returns the configurations cache with the given name. The cache is already
87     * started.
88     *
89     * @param cacheName the name of the cache to fetch.
90     * @return the requested cache already started.
91     */
92    Cache<?, ?> getConfigurationsCache(String cacheName);
93  
94    /**
95     * Returns the set of cache names.
96     *
97     * @return the set of cache names.
98     */
99    Set<String> getCacheNames();
100 
101   // --- object basics --------------------------------------------------------
102 }