| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 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 | |
|
| 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 | |
} |