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