| 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 | ||
| 36 | import org.kuali.rice.core.api.config.ConfigurationException; | |
| 37 | import org.kuali.rice.core.api.config.property.ConfigContext; | |
| 38 | import org.kuali.rice.core.impl.config.property.Config; | |
| 39 | import org.kuali.rice.core.impl.config.property.JAXBConfigImpl; | |
| 40 | import org.springframework.beans.factory.FactoryBean; | |
| 41 | ||
| 42 | 0 | public class RiceConfigFactoryBean implements FactoryBean { |
| 43 | ||
| 44 | private List<String> configLocations; | |
| 45 | ||
| 46 | public Object getObject() throws Exception { | |
| 47 | 0 | if (getConfigLocations() == null) { |
| 48 | 0 | throw new ConfigurationException( |
| 49 | "No config locations declared, at least one is required"); | |
| 50 | } | |
| 51 | // we don't have to worry about a null config below because the JAXBConfigImpl class handles that scenario | |
| 52 | 0 | JAXBConfigImpl config = new JAXBConfigImpl(getConfigLocations(), ConfigContext.getCurrentContextConfig()); |
| 53 | 0 | config.setSystemOverride(true); |
| 54 | 0 | config.parseConfig(); |
| 55 | // we always want to call init for this config as it should be overriding any existing config object and any | |
| 56 | // existing config object should have already been merged into our new config object already from above | |
| 57 | 0 | ConfigContext.init(config); |
| 58 | ||
| 59 | 0 | return config; |
| 60 | } | |
| 61 | ||
| 62 | public Class<?> getObjectType() { | |
| 63 | 0 | return Config.class; |
| 64 | } | |
| 65 | ||
| 66 | public boolean isSingleton() { | |
| 67 | 0 | return true; |
| 68 | } | |
| 69 | ||
| 70 | public List<String> getConfigLocations() { | |
| 71 | 0 | return this.configLocations; |
| 72 | } | |
| 73 | ||
| 74 | public void setConfigLocations(List<String> configLocations) { | |
| 75 | 0 | this.configLocations = configLocations; |
| 76 | 0 | } |
| 77 | ||
| 78 | } |