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.property.ConfigContext;
 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  
 import org.kuali.rice.ksb.messaging.config.ServiceHolder;
 31  
 
 32  
 /**
 33  
  * Wraps {@link BeanFactory} in {@link BeanFactoryResourceLoader} and places the {@link ResourceLoader} 
 34  
  * at the top of the {@link GlobalResourceLoader} stack.
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  *
 38  
  */
 39  0
 public class RiceSpringResourceLoaderConfigurer implements BeanFactoryAware, InitializingBean {
 40  
         
 41  
         private QName name;
 42  
         private String localServiceName;
 43  
         private String serviceNameSpaceURI;
 44  
         private Set<String> beanNames;
 45  
 
 46  
         private BeanFactory beanFactory;
 47  
 
 48  
         public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
 49  0
                 this.beanFactory = beanFactory;
 50  0
         }
 51  
 
 52  
         public void afterPropertiesSet() throws Exception {
 53  0
                 if (this.name == null) {
 54  0
                         if (this.getServiceNameSpaceURI() == null) {
 55  0
                                 this.setServiceNameSpaceURI((new ServiceHolder()).getServiceNameSpaceURI());
 56  
                         }
 57  0
                         if (this.getLocalServiceName() == null) {
 58  0
                                 throw new ConfigurationException("Need to give " + this.getClass().getName() + " a LocalServiceName");
 59  
                         }
 60  
                 }
 61  
                 
 62  0
                 ResourceLoader beanFactoryRL = new BeanFactoryResourceLoader(getName(), this.beanFactory, this.beanNames);
 63  0
                 GlobalResourceLoader.addResourceLoaderFirst(beanFactoryRL);
 64  0
         }
 65  
 
 66  
         public QName getName() {
 67  0
                 if (this.name == null) {
 68  0
                         this.setName(new QName(this.getServiceNameSpaceURI(), this.getLocalServiceName()));
 69  
                 }
 70  0
                 return name;
 71  
         }
 72  
 
 73  
         public void setName(QName name) {
 74  0
                 this.name = name;
 75  0
         }
 76  
         
 77  
         public String getLocalServiceName() {
 78  0
                 return localServiceName;
 79  
         }
 80  
 
 81  
         public void setLocalServiceName(String localServiceName) {
 82  0
                 this.localServiceName = localServiceName;
 83  0
         }
 84  
 
 85  
         public String getServiceNameSpaceURI() {
 86  0
                 return serviceNameSpaceURI;
 87  
         }
 88  
 
 89  
         public void setServiceNameSpaceURI(String serviceNameSpaceURI) {
 90  0
                 this.serviceNameSpaceURI = serviceNameSpaceURI;
 91  0
         }
 92  
         
 93  
         public void setBeanNames(Set<String> beanNames) {
 94  0
                 this.beanNames = beanNames;
 95  0
         }
 96  
 
 97  
 }