View Javadoc
1   /*
2    *    Copyright 2009-2021 the original author or authors.
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 org.apache.ibatis.cache.decorators;
17  
18  import org.apache.ibatis.cache.Cache;
19  
20  /**
21   * @author Clinton Begin
22   */
23  public class SynchronizedCache implements Cache {
24  
25    private final Cache delegate;
26  
27    public SynchronizedCache(Cache delegate) {
28      this.delegate = delegate;
29    }
30  
31    @Override
32    public String getId() {
33      return delegate.getId();
34    }
35  
36    @Override
37    public synchronized int getSize() {
38      return delegate.getSize();
39    }
40  
41    @Override
42    public synchronized void putObject(Object key, Object object) {
43      delegate.putObject(key, object);
44    }
45  
46    @Override
47    public synchronized Object getObject(Object key) {
48      return delegate.getObject(key);
49    }
50  
51    @Override
52    public synchronized Object removeObject(Object key) {
53      return delegate.removeObject(key);
54    }
55  
56    @Override
57    public synchronized void clear() {
58      delegate.clear();
59    }
60  
61    @Override
62    public int hashCode() {
63      return delegate.hashCode();
64    }
65  
66    @Override
67    public boolean equals(Object obj) {
68      return delegate.equals(obj);
69    }
70  
71  }