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.infinispan;
17  
18  import java.util.concurrent.TimeUnit;
19  
20  import de.smartics.properties.spi.config.cache.UnawareCache;
21  
22  /**
23   * Implementation of an cache that delegates to an infinispan cache.
24   *
25   * @param <K> the type for the key.
26   * @param <V> the type for the value.
27   */
28  public class InfinispanDelegatingCache<K, V> implements UnawareCache<K, V>
29  {
30    // ********************************* Fields *********************************
31  
32    /**
33     * The cache to which everything is delegated.
34     */
35    private final org.infinispan.Cache<K, V> cache;
36  
37    // --- constants ------------------------------------------------------------
38  
39    // --- members --------------------------------------------------------------
40  
41    // ****************************** Initializer *******************************
42  
43    // ****************************** Constructors ******************************
44  
45    /**
46     * Constructor.
47     *
48     * @param cache the cache to delegate to.
49     */
50    public InfinispanDelegatingCache(final org.infinispan.Cache<K, V> cache)
51    {
52      this.cache = cache;
53    }
54  
55    // ****************************** Inner Classes *****************************
56  
57    // ********************************* Methods ********************************
58  
59    // --- init -----------------------------------------------------------------
60  
61    // --- get&set --------------------------------------------------------------
62  
63    // --- business -------------------------------------------------------------
64  
65    @Override
66    public final V get(final Object key)
67    {
68      return cache.get(key);
69    }
70  
71    @Override
72    public final void put(final K key, final V resolvedProperty,
73        final long updateIntervalInMs, final TimeUnit milliseconds)
74    {
75      cache.put(key, resolvedProperty, updateIntervalInMs, milliseconds);
76    }
77  
78    @Override
79    public final V remove(final Object key)
80    {
81      return cache.remove(key);
82    }
83  
84    @Override
85    public final void put(final K key, final V value)
86    {
87      cache.put(key, value);
88    }
89  
90    @Override
91    // CHECKSTYLE:OFF
92    public final void put(final K key, final V value, final int lifespan,
93        final TimeUnit lifespanTimeUnit, final int maxIdleTime,
94        final TimeUnit maxIdleTimeTimeUnit)
95    {
96      cache.put(key, value, lifespan, lifespanTimeUnit, maxIdleTime,
97          maxIdleTimeTimeUnit);
98    }
99  
100   // CHECKSTYLE:ON
101 
102   // --- object basics --------------------------------------------------------
103 
104 }