View Javadoc
1   /*
2    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
3    * use this file except in compliance with the License. You may obtain a copy of
4    * the License at
5    * 
6    * http://www.apache.org/licenses/LICENSE-2.0
7    * 
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11   * License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  
15  package org.esigate.cache;
16  
17  import java.io.IOException;
18  import java.util.Properties;
19  
20  import org.apache.http.client.cache.HttpCacheEntry;
21  import org.apache.http.client.cache.HttpCacheStorage;
22  import org.apache.http.client.cache.HttpCacheUpdateCallback;
23  import org.apache.http.client.cache.HttpCacheUpdateException;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  public abstract class CacheStorage implements HttpCacheStorage {
28      private static final Logger LOG = LoggerFactory.getLogger(CacheStorage.class);
29  
30      public abstract void init(Properties properties);
31  
32      private HttpCacheStorage impl;
33  
34      @Override
35      public void putEntry(String key, HttpCacheEntry entry) throws IOException {
36          LOG.debug("putEntry({},{})", key, entry);
37          impl.putEntry(key, entry);
38      }
39  
40      @Override
41      public HttpCacheEntry getEntry(String key) throws IOException {
42          LOG.debug("getEntry({})", key);
43          return impl.getEntry(key);
44      }
45  
46      @Override
47      public void removeEntry(String key) throws IOException {
48          LOG.debug("removeEntry({})", key);
49          impl.removeEntry(key);
50  
51      }
52  
53      @Override
54      public void updateEntry(String key, HttpCacheUpdateCallback callback) throws IOException, HttpCacheUpdateException {
55          LOG.debug("updateEntry({},{})", key, callback);
56          impl.updateEntry(key, callback);
57      }
58  
59      public void setImpl(HttpCacheStorage impl) {
60          this.impl = impl;
61      }
62  
63  }