Coverage Report - org.kuali.rice.core.impl.config.property.ConfigFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigFactoryBean
0%
0/22
0%
0/8
1.833
 
 1  
 /*
 2  
  * Copyright 2006-2011 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  
 
 17  
 package org.kuali.rice.core.impl.config.property;
 18  
 
 19  
 import org.kuali.rice.core.api.config.ConfigurationException;
 20  
 import org.kuali.rice.core.api.config.property.Config;
 21  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 22  
 import org.springframework.beans.factory.FactoryBean;
 23  
 
 24  
 import java.util.List;
 25  
 
 26  0
 public class ConfigFactoryBean implements FactoryBean<org.kuali.rice.core.api.config.property.Config> {
 27  
 
 28  
         private List<String> configLocations;
 29  0
         private boolean initialize = false;
 30  
 
 31  
         public static String CONFIG_OVERRIDE_LOCATION;
 32  
 
 33  
         @Override
 34  
         public org.kuali.rice.core.api.config.property.Config getObject() throws Exception {
 35  
                 
 36  0
                 org.kuali.rice.core.api.config.property.Config oldConfig = null;
 37  
                 
 38  0
                 if (getConfigLocations() == null) {
 39  0
                         throw new ConfigurationException("No config locations declared, at least one is required");
 40  
                 }
 41  
 
 42  0
                 if (ConfigContext.getCurrentContextConfig() != null) {
 43  0
                         oldConfig = ConfigContext.getCurrentContextConfig();
 44  
                 }
 45  
                 //SimpleConfig config = null;
 46  0
                 JAXBConfigImpl config = null;
 47  0
                 if (CONFIG_OVERRIDE_LOCATION != null) {
 48  0
                         config = new JAXBConfigImpl(CONFIG_OVERRIDE_LOCATION, oldConfig);                
 49  
                 } else {
 50  0
                         config = new JAXBConfigImpl(getConfigLocations(), oldConfig);
 51  
                 }
 52  
 
 53  0
                 config.parseConfig();
 54  
                 
 55  0
                 if (initialize) {
 56  0
                         ConfigContext.init(config);
 57  
                 }
 58  
                 
 59  0
                 return config;
 60  
         }
 61  
 
 62  
         @Override
 63  
         public Class<Config> getObjectType() {
 64  0
                 return org.kuali.rice.core.api.config.property.Config.class;
 65  
         }
 66  
 
 67  
         @Override
 68  
         public boolean isSingleton() {
 69  0
                 return true;
 70  
         }
 71  
 
 72  
         public List<String> getConfigLocations() {
 73  0
                 return this.configLocations;
 74  
         }
 75  
 
 76  
         public void setConfigLocations(List<String> configLocations) {
 77  0
                 this.configLocations = configLocations;
 78  0
         }
 79  
         
 80  
         public void setInitialize(boolean initialize) {
 81  0
                 this.initialize = initialize;
 82  0
         }
 83  
 
 84  
 }