001/* 002 * (C) Copyright 2017 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 */ 017package org.nuxeo.ecm.core.cache; 018 019import java.io.Serializable; 020import java.util.Set; 021 022/** 023 * @since 9.1 024 */ 025public abstract class CacheWrapper implements Cache { 026 027 public final Cache cache; 028 029 protected CacheWrapper(Cache cache) { 030 this.cache = cache; 031 } 032 033 public void stop() { 034 if (cache instanceof CacheWrapper) { 035 ((CacheWrapper) cache).stop(); 036 } 037 onStop(); 038 } 039 040 protected void onStop() { 041 } 042 043 @Override 044 public String getName() { 045 return cache.getName(); 046 } 047 048 @Override 049 public Serializable get(String key) { 050 return cache.get(key); 051 } 052 053 @Override 054 public Set<String> keySet() { 055 return cache.keySet(); 056 } 057 058 @Override 059 public void invalidate(String key) { 060 cache.invalidate(key); 061 } 062 063 @Override 064 public void invalidateAll() { 065 cache.invalidateAll(); 066 } 067 068 @Override 069 public void put(String key, Serializable value) { 070 cache.put(key, value); 071 } 072 073 @Override 074 public boolean hasEntry(String key) { 075 return cache.hasEntry(key); 076 } 077 078}