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