Coverage Report - org.kuali.rice.core.config.spring.ConfigFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigFactoryBean
0%
0/18
0%
0/6
1.8
 
 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.config.spring;
 17  
 
 18  
 import java.util.List;
 19  
 import java.util.Properties;
 20  
 
 21  
 import org.kuali.rice.core.config.Config;
 22  
 import org.kuali.rice.core.config.ConfigContext;
 23  
 import org.kuali.rice.core.config.ConfigurationException;
 24  
 import org.kuali.rice.core.config.JAXBConfigImpl;
 25  
 import org.springframework.beans.factory.FactoryBean;
 26  
 
 27  0
 public class ConfigFactoryBean implements FactoryBean {
 28  
 
 29  
         private List<String> configLocations;
 30  
 
 31  
         public static String CONFIG_OVERRIDE_LOCATION;
 32  
 
 33  
         public Object getObject() throws Exception {
 34  
                 
 35  0
                 Config oldConfig = null;
 36  
                 
 37  0
                 if (getConfigLocations() == null) {
 38  0
                         throw new ConfigurationException("No config locations declared, at least one is required");
 39  
                 }
 40  0
                 Properties baseProperties = new Properties();
 41  0
                 if (ConfigContext.getCurrentContextConfig() != null) {
 42  0
                         oldConfig = ConfigContext.getCurrentContextConfig();
 43  
                 }
 44  
                 //SimpleConfig config = null;
 45  0
                 JAXBConfigImpl config = null;
 46  0
                 if (CONFIG_OVERRIDE_LOCATION != null) {
 47  0
                         config = new JAXBConfigImpl(CONFIG_OVERRIDE_LOCATION, oldConfig);                
 48  
                 } else {
 49  0
                         config = new JAXBConfigImpl(getConfigLocations(), oldConfig);
 50  
                 }
 51  
 
 52  0
                 config.parseConfig();
 53  0
                 return config;
 54  
         }
 55  
 
 56  
         public Class getObjectType() {
 57  0
                 return Config.class;
 58  
         }
 59  
 
 60  
         public boolean isSingleton() {
 61  0
                 return true;
 62  
         }
 63  
 
 64  
         public List<String> getConfigLocations() {
 65  0
                 return this.configLocations;
 66  
         }
 67  
 
 68  
         public void setConfigLocations(List<String> configLocations) {
 69  0
                 this.configLocations = configLocations;
 70  0
         }
 71  
 
 72  
 }