Coverage Report - org.kuali.rice.core.framework.resourceloader.RiceSpringResourceLoaderConfigurer
 
Classes in this File Line Coverage Branch Coverage Complexity
RiceSpringResourceLoaderConfigurer
0%
0/24
0%
0/8
1.556
 
 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.framework.resourceloader;
 17  
 
 18  
 import java.util.Set;
 19  
 
 20  
 import javax.xml.namespace.QName;
 21  
 
 22  
 import org.kuali.rice.core.api.config.ConfigurationException;
 23  
 import org.kuali.rice.core.api.config.CoreConfigHelper;
 24  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 25  
 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
 26  
 import org.springframework.beans.BeansException;
 27  
 import org.springframework.beans.factory.BeanFactory;
 28  
 import org.springframework.beans.factory.BeanFactoryAware;
 29  
 import org.springframework.beans.factory.InitializingBean;
 30  
 
 31  
 /**
 32  
  * Wraps {@link BeanFactory} in {@link BeanFactoryResourceLoader} and places the {@link ResourceLoader} 
 33  
  * at the top of the {@link GlobalResourceLoader} stack.
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  *
 37  
  */
 38  0
 public class RiceSpringResourceLoaderConfigurer implements BeanFactoryAware, InitializingBean {
 39  
         
 40  
         private QName name;
 41  
         private String localServiceName;
 42  
         private String serviceNameSpaceURI;
 43  
         private Set<String> beanNames;
 44  
 
 45  
         private BeanFactory beanFactory;
 46  
 
 47  
         public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
 48  0
                 this.beanFactory = beanFactory;
 49  0
         }
 50  
 
 51  
         public void afterPropertiesSet() throws Exception {
 52  0
                 if (this.name == null) {
 53  0
                         if (this.getServiceNameSpaceURI() == null) {
 54  0
                                 this.setServiceNameSpaceURI(CoreConfigHelper.getApplicationId());
 55  
                         }
 56  0
                         if (this.getLocalServiceName() == null) {
 57  0
                                 throw new ConfigurationException("Need to give " + this.getClass().getName() + " a LocalServiceName");
 58  
                         }
 59  
                 }
 60  
                 
 61  0
                 ResourceLoader beanFactoryRL = new BeanFactoryResourceLoader(getName(), this.beanFactory, this.beanNames);
 62  0
                 GlobalResourceLoader.addResourceLoaderFirst(beanFactoryRL);
 63  0
         }
 64  
 
 65  
         public QName getName() {
 66  0
                 if (this.name == null) {
 67  0
                         this.setName(new QName(this.getServiceNameSpaceURI(), this.getLocalServiceName()));
 68  
                 }
 69  0
                 return name;
 70  
         }
 71  
 
 72  
         public void setName(QName name) {
 73  0
                 this.name = name;
 74  0
         }
 75  
         
 76  
         public String getLocalServiceName() {
 77  0
                 return localServiceName;
 78  
         }
 79  
 
 80  
         public void setLocalServiceName(String localServiceName) {
 81  0
                 this.localServiceName = localServiceName;
 82  0
         }
 83  
 
 84  
         public String getServiceNameSpaceURI() {
 85  0
                 return serviceNameSpaceURI;
 86  
         }
 87  
 
 88  
         public void setServiceNameSpaceURI(String serviceNameSpaceURI) {
 89  0
                 this.serviceNameSpaceURI = serviceNameSpaceURI;
 90  0
         }
 91  
         
 92  
         public void setBeanNames(Set<String> beanNames) {
 93  0
                 this.beanNames = beanNames;
 94  0
         }
 95  
 
 96  
 }