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 | 0 | super(new QName(child.getName().toString() + " to parent " + parent.getName().toString())); |
37 | 0 | this.parent = parent; |
38 | 0 | this.child = child; |
39 | 0 | } |
40 | |
|
41 | |
public Object getObject(ObjectDefinition definition) { |
42 | 0 | Object object = child.getObject(definition); |
43 | 0 | if (object == null) { |
44 | 0 | object = parent.getObject(definition); |
45 | |
} |
46 | 0 | return object; |
47 | |
} |
48 | |
|
49 | |
public Object getService(QName qname) { |
50 | 0 | Object service = child.getService(qname); |
51 | 0 | if (service == null) { |
52 | 0 | service = parent.getService(qname); |
53 | |
} |
54 | 0 | return service; |
55 | |
} |
56 | |
|
57 | |
public void start() throws Exception { |
58 | |
|
59 | 0 | if (!child.isStarted()) { |
60 | 0 | child.start(); |
61 | |
} |
62 | 0 | super.start(); |
63 | 0 | } |
64 | |
|
65 | |
public void stop() throws Exception { |
66 | 0 | child.stop(); |
67 | 0 | super.stop(); |
68 | 0 | } |
69 | |
|
70 | |
public void addResourceLoader(ResourceLoader resourceLoader) { |
71 | 0 | this.child.addResourceLoader(resourceLoader); |
72 | 0 | } |
73 | |
|
74 | |
public void addResourceLoaderFirst(ResourceLoader resourceLoader) { |
75 | 0 | this.child.addResourceLoaderFirst(resourceLoader); |
76 | 0 | } |
77 | |
|
78 | |
|
79 | |
public ResourceLoader getResourceLoader(QName name) { |
80 | 0 | ResourceLoader resourceLoader = this.child.getResourceLoader(name); |
81 | 0 | if (resourceLoader == null && parent != null) { |
82 | 0 | return parent.getResourceLoader(name); |
83 | |
} else { |
84 | 0 | return resourceLoader; |
85 | |
} |
86 | |
} |
87 | |
|
88 | |
public List<QName> getResourceLoaderNames() { |
89 | 0 | return this.child.getResourceLoaderNames(); |
90 | |
} |
91 | |
|
92 | |
public List<ResourceLoader> getResourceLoaders() { |
93 | 0 | return this.child.getResourceLoaders(); |
94 | |
} |
95 | |
|
96 | |
public void removeResourceLoader(QName name) { |
97 | 0 | this.child.removeResourceLoader(name); |
98 | 0 | } |
99 | |
|
100 | |
|
101 | |
|
102 | |
} |