1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.resourceloader;
17
18 import java.util.List;
19
20 import javax.xml.namespace.QName;
21
22 import org.kuali.rice.core.reflect.ObjectDefinition;
23
24
25
26
27
28
29
30 public class ParentChildResourceLoader extends BaseResourceLoader {
31
32 private ResourceLoader parent;
33 private ResourceLoader child;
34
35 public ParentChildResourceLoader(ResourceLoader parent, ResourceLoader child) {
36 super(new QName(child.getName().toString() + " to parent " + parent.getName().toString()));
37 this.parent = parent;
38 this.child = child;
39 }
40
41 public Object getObject(ObjectDefinition definition) {
42 Object object = child.getObject(definition);
43 if (object == null) {
44 object = parent.getObject(definition);
45 }
46 return object;
47 }
48
49 public Object getService(QName qname) {
50 Object service = child.getService(qname);
51 if (service == null) {
52 service = parent.getService(qname);
53 }
54 return service;
55 }
56
57 public void start() throws Exception {
58
59 if (!child.isStarted()) {
60 child.start();
61 }
62 super.start();
63 }
64
65 public void stop() throws Exception {
66 child.stop();
67 super.stop();
68 }
69
70 public void addResourceLoader(ResourceLoader resourceLoader) {
71 this.child.addResourceLoader(resourceLoader);
72 }
73
74 public void addResourceLoaderFirst(ResourceLoader resourceLoader) {
75 this.child.addResourceLoaderFirst(resourceLoader);
76 }
77
78
79 public ResourceLoader getResourceLoader(QName name) {
80 ResourceLoader resourceLoader = this.child.getResourceLoader(name);
81 if (resourceLoader == null && parent != null) {
82 return parent.getResourceLoader(name);
83 } else {
84 return resourceLoader;
85 }
86 }
87
88 public List<QName> getResourceLoaderNames() {
89 return this.child.getResourceLoaderNames();
90 }
91
92 public List<ResourceLoader> getResourceLoaders() {
93 return this.child.getResourceLoaders();
94 }
95
96 public void removeResourceLoader(QName name) {
97 this.child.removeResourceLoader(name);
98 }
99
100
101
102 }