Coverage Report - org.kuali.rice.core.resourceloader.ParentChildResourceLoader
 
Classes in this File Line Coverage Branch Coverage Complexity
ParentChildResourceLoader
0%
0/31
0%
0/10
1.545
 
 1  
 /*
 2  
  * Copyright 2007-2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 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.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  
  * This is a description of what this class does - ewestfal don't forget to fill this in.
 26  
  *
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
         // just start the child, it will be assumed that parent will be started from it's context
 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  
 }