| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| RiceConfigFactoryBean | 
 | 
 | 1.4;1.4 | 
| 1 |  /** | |
| 2 |   * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 |   * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 |   * not use this file except in compliance with the License. You may | |
| 5 |   * obtain a copy of the License at | |
| 6 |   * | |
| 7 |   * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 |   * | |
| 9 |   * Unless required by applicable law or agreed to in writing, | |
| 10 |   * software distributed under the License is distributed on an "AS IS" | |
| 11 |   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 |   * or implied. See the License for the specific language governing | |
| 13 |   * permissions and limitations under the License. | |
| 14 |   */ | |
| 15 | ||
| 16 |  package org.kuali.rice.student.core.config.spring; | |
| 17 | ||
| 18 |  /* | |
| 19 |   * Copyright 2007 The Kuali Foundation | |
| 20 |   * | |
| 21 |   * Licensed under the Educational Community License, Version 1.0 (the "License"); | |
| 22 |   * you may not use this file except in compliance with the License. | |
| 23 |   * You may obtain a copy of the License at | |
| 24 |   * | |
| 25 |   * http://www.opensource.org/licenses/ecl1.php | |
| 26 |   * | |
| 27 |   * Unless required by applicable law or agreed to in writing, software | |
| 28 |   * distributed under the License is distributed on an "AS IS" BASIS, | |
| 29 |   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 30 |   * See the License for the specific language governing permissions and | |
| 31 |   * limitations under the License. | |
| 32 |   */ | |
| 33 | ||
| 34 |  import java.util.List; | |
| 35 |  import java.util.Properties; | |
| 36 | ||
| 37 |  import org.kuali.rice.core.config.Config; | |
| 38 |  import org.kuali.rice.core.config.ConfigContext; | |
| 39 |  import org.kuali.rice.core.config.ConfigurationException; | |
| 40 |  import org.kuali.rice.core.config.JAXBConfigImpl; | |
| 41 |  import org.springframework.beans.factory.FactoryBean; | |
| 42 | ||
| 43 | 0 |  public class RiceConfigFactoryBean implements FactoryBean { | 
| 44 | ||
| 45 |          private List<String> configLocations; | |
| 46 | ||
| 47 | public Object getObject() throws Exception { | |
| 48 | 0 |                  if (getConfigLocations() == null) { | 
| 49 | 0 |                          throw new ConfigurationException( | 
| 50 |                                          "No config locations declared, at least one is required"); | |
| 51 | } | |
| 52 |                  // we don't have to worry about a null config below because the JAXBConfigImpl class handles that scenario | |
| 53 | 0 |                  JAXBConfigImpl config = new JAXBConfigImpl(getConfigLocations(), ConfigContext.getCurrentContextConfig()); | 
| 54 | 0 |                  config.setSystemOverride(true); | 
| 55 | 0 |                  config.parseConfig(); | 
| 56 |                  // we always want to call init for this config as it should be overriding any existing config object and any | |
| 57 |                  // existing config object should have already been merged into our new config object already from above | |
| 58 | 0 |                  ConfigContext.init(config); | 
| 59 | ||
| 60 | 0 |                  return config; | 
| 61 | } | |
| 62 | ||
| 63 |          public Class<?> getObjectType() { | |
| 64 | 0 |                  return Config.class; | 
| 65 | } | |
| 66 | ||
| 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 | } |