| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SimpleConfigFactoryBean |
|
| 1.4;1.4 |
| 1 | /* | |
| 2 | * Copyright 2007-2010 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 org.kuali.rice.core.config.Config; | |
| 19 | import org.springframework.beans.factory.FactoryBean; | |
| 20 | ||
| 21 | /** | |
| 22 | * Allows a config object to set and {@link Config#parseConfig()} to be called before it is returned. | |
| 23 | * | |
| 24 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 25 | * | |
| 26 | */ | |
| 27 | 0 | public class SimpleConfigFactoryBean implements FactoryBean { |
| 28 | ||
| 29 | private Config config; | |
| 30 | ||
| 31 | /** | |
| 32 | * Gets the config. | |
| 33 | * @return config the config | |
| 34 | */ | |
| 35 | public Config getConfig() { | |
| 36 | 0 | return this.config; |
| 37 | } | |
| 38 | ||
| 39 | /** | |
| 40 | * Sets the config. | |
| 41 | * @param config the config | |
| 42 | */ | |
| 43 | public void setConfig(Config config) { | |
| 44 | 0 | this.config = config; |
| 45 | 0 | } |
| 46 | ||
| 47 | /** | |
| 48 | * Returns a config object after calling {@link Config#parseConfig()}. | |
| 49 | * {@inheritDoc} | |
| 50 | */ | |
| 51 | public Config getObject() throws Exception { | |
| 52 | 0 | if (config == null) { |
| 53 | 0 | throw new IllegalStateException("config has not been set"); |
| 54 | } | |
| 55 | ||
| 56 | 0 | config.parseConfig(); |
| 57 | ||
| 58 | 0 | return config; |
| 59 | } | |
| 60 | ||
| 61 | /** {@inheritDoc} */ | |
| 62 | public Class<Config> getObjectType() { | |
| 63 | 0 | return Config.class; |
| 64 | } | |
| 65 | ||
| 66 | /** {@inheritDoc} */ | |
| 67 | public boolean isSingleton() { | |
| 68 | 0 | return true; |
| 69 | } | |
| 70 | } |