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
20 public class BeanDescriptionCache extends ContextAwareBase {
21
22 private Map<Class<?>, BeanDescription> classToBeanDescription = new HashMap<Class<?>, BeanDescription>();
23 private BeanDescriptionFactory beanDescriptionFactory;
24
25 public BeanDescriptionCache(Context context) {
26 setContext(context);
27 }
28
29 private BeanDescriptionFactory getBeanDescriptionFactory() {
30 if (beanDescriptionFactory == null) {
31 beanDescriptionFactory = new BeanDescriptionFactory(getContext());
32 }
33 return beanDescriptionFactory;
34 }
35
36
45 public BeanDescription getBeanDescription(Class<?> clazz) {
46 if (!classToBeanDescription.containsKey(clazz)) {
47 BeanDescription beanDescription = getBeanDescriptionFactory().create(clazz);
48 classToBeanDescription.put(clazz, beanDescription);
49 }
50 return classToBeanDescription.get(clazz);
51 }
52
53 }
54