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