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 2005-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  
 package org.kuali.rice.core.impl.config.property;
 17  
 
 18  
 import org.kuali.rice.core.api.config.ConfigurationException;
 19  
 import org.kuali.rice.core.api.config.property.Config;
 20  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 21  
 import org.springframework.beans.factory.FactoryBean;
 22  
 
 23  
 import java.util.List;
 24  
 
 25  0
 public class ConfigFactoryBean implements FactoryBean<org.kuali.rice.core.api.config.property.Config> {
 26  
 
 27  
         private List<String> configLocations;
 28  0
         private boolean initialize = false;
 29  
 
 30  
         public static String CONFIG_OVERRIDE_LOCATION;
 31  
 
 32  
         @Override
 33  
         public org.kuali.rice.core.api.config.property.Config getObject() throws Exception {
 34  
                 
 35  0
                 org.kuali.rice.core.api.config.property.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  
 
 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  
                 
 54  0
                 if (initialize) {
 55  0
                         ConfigContext.init(config);
 56  
                 }
 57  
                 
 58  0
                 return config;
 59  
         }
 60  
 
 61  
         @Override
 62  
         public Class<Config> getObjectType() {
 63  0
                 return org.kuali.rice.core.api.config.property.Config.class;
 64  
         }
 65  
 
 66  
         @Override
 67  
         public boolean isSingleton() {
 68  0
                 return true;
 69  
         }
 70  
 
 71  
         public List<String> getConfigLocations() {
 72  0
                 return this.configLocations;
 73  
         }
 74  
 
 75  
         public void setConfigLocations(List<String> configLocations) {
 76  0
                 this.configLocations = configLocations;
 77  0
         }
 78  
         
 79  
         public void setInitialize(boolean initialize) {
 80  0
                 this.initialize = initialize;
 81  0
         }
 82  
 
 83  
 }