01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.rice.resourceloader;
17:
18: import java.util.List;
19:
20: import javax.xml.namespace.QName;
21:
22: import org.kuali.rice.definition.ObjectDefinition;
23:
24: /**
25: * This is a description of what this class does - ewestfal don't forget to fill this in.
26: *
27: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
28: *
29: */
30: public class ParentChildResourceLoader extends BaseResourceLoader {
31:
32: private ResourceLoader parent;
33: private ResourceLoader child;
34:
35: public ParentChildResourceLoader(ResourceLoader parent,
36: ResourceLoader child) {
37: super (new QName(child.getName().toString() + " to parent "
38: + parent.getName().toString()));
39: this .parent = parent;
40: this .child = child;
41: }
42:
43: public Object getObject(ObjectDefinition definition) {
44: Object object = child.getObject(definition);
45: if (object == null) {
46: object = parent.getObject(definition);
47: }
48: return object;
49: }
50:
51: public Object getService(QName qname) {
52: Object service = child.getService(qname);
53: if (service == null) {
54: service = parent.getService(qname);
55: }
56: return service;
57: }
58:
59: public void start() throws Exception {
60: // just start the child, it will be assumed that parent will be started from it's context
61: if (!child.isStarted()) {
62: child.start();
63: }
64: super .start();
65: }
66:
67: public void stop() throws Exception {
68: child.stop();
69: super .stop();
70: }
71:
72: public void addResourceLoader(ResourceLoader resourceLoader) {
73: this .child.addResourceLoader(resourceLoader);
74: }
75:
76: public void addResourceLoaderFirst(ResourceLoader resourceLoader) {
77: this .child.addResourceLoaderFirst(resourceLoader);
78: }
79:
80: public ResourceLoader getResourceLoader(QName name) {
81: return this .child.getResourceLoader(name);
82: }
83:
84: public List<QName> getResourceLoaderNames() {
85: return this .child.getResourceLoaderNames();
86: }
87:
88: public List<ResourceLoader> getResourceLoaders() {
89: return this .child.getResourceLoaders();
90: }
91:
92: public void removeResourceLoader(QName name) {
93: this.child.removeResourceLoader(name);
94: }
95:
96: }
|