1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.reflection;
17
18 import java.util.concurrent.ConcurrentHashMap;
19 import java.util.concurrent.ConcurrentMap;
20
21 public class DefaultReflectorFactory implements ReflectorFactory {
22 private boolean classCacheEnabled = true;
23 private final ConcurrentMap<Class<?>, Reflector> reflectorMap = new ConcurrentHashMap<>();
24
25 public DefaultReflectorFactory() {
26 }
27
28 @Override
29 public boolean isClassCacheEnabled() {
30 return classCacheEnabled;
31 }
32
33 @Override
34 public void setClassCacheEnabled(boolean classCacheEnabled) {
35 this.classCacheEnabled = classCacheEnabled;
36 }
37
38 @Override
39 public Reflector findForClass(Class<?> type) {
40 if (classCacheEnabled) {
41
42 return reflectorMap.computeIfAbsent(type, Reflector::new);
43 } else {
44 return new Reflector(type);
45 }
46 }
47
48 }