01: package org.conform;
02:
03: import java.util.*;
04:
05: /**
06: * @author hengels
07: * @version $Revision: 831 $
08: */
09: public abstract class DelegatingBeanMetaProvider implements
10: BeanMetaProvider {
11: BeanMetaProvider parent;
12: Map cache = new HashMap();
13:
14: protected DelegatingBeanMetaProvider() {
15: }
16:
17: protected DelegatingBeanMetaProvider(BeanMetaProvider parent) {
18: this .parent = parent;
19: }
20:
21: public void setParent(BeanMetaProvider parent) {
22: this .parent = parent;
23: }
24:
25: public void clearCache() {
26: cache.clear();
27: parent.clearCache();
28: }
29:
30: public BeanMeta getBeanMeta(Class type) {
31: BeanMeta meta = (BeanMeta) cache.get(type);
32: if (meta == null) {
33: meta = parent.getBeanMeta(type);
34: meta = (BeanMeta) meta.clone();
35: cache.put(type, meta);
36: configure(meta);
37: }
38: return meta;
39: }
40:
41: protected abstract void configure(BeanMeta meta);
42: }
|