1 package ch.qos.logback.core.joran.util.beans;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import ch.qos.logback.core.Context;
7 import ch.qos.logback.core.spi.ContextAwareBase;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class BeanDescriptionCache extends ContextAwareBase {
23
24 private Map<Class<?>, BeanDescription> classToBeanDescription = new HashMap<Class<?>, BeanDescription>();
25 private BeanDescriptionFactory beanDescriptionFactory;
26
27 public BeanDescriptionCache(Context context) {
28 setContext(context);
29 }
30
31 private BeanDescriptionFactory getBeanDescriptionFactory() {
32 if (beanDescriptionFactory == null) {
33 beanDescriptionFactory = new BeanDescriptionFactory(getContext());
34 }
35 return beanDescriptionFactory;
36 }
37
38
39
40
41
42
43
44
45
46 public BeanDescription getBeanDescription(Class<?> clazz) {
47 if (!classToBeanDescription.containsKey(clazz)) {
48 BeanDescription beanDescription = getBeanDescriptionFactory().create(clazz);
49 classToBeanDescription.put(clazz, beanDescription);
50 }
51 return classToBeanDescription.get(clazz);
52 }
53
54 }