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