| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.core.config.spring; |
| 17 | |
|
| 18 | |
import java.util.List; |
| 19 | |
import java.util.Properties; |
| 20 | |
|
| 21 | |
import org.kuali.rice.core.config.Config; |
| 22 | |
import org.kuali.rice.core.config.ConfigContext; |
| 23 | |
import org.kuali.rice.core.config.ConfigurationException; |
| 24 | |
import org.kuali.rice.core.config.JAXBConfigImpl; |
| 25 | |
import org.springframework.beans.factory.FactoryBean; |
| 26 | |
|
| 27 | 0 | public class ConfigFactoryBean implements FactoryBean { |
| 28 | |
|
| 29 | |
private List<String> configLocations; |
| 30 | |
|
| 31 | |
public static String CONFIG_OVERRIDE_LOCATION; |
| 32 | |
|
| 33 | |
public Object getObject() throws Exception { |
| 34 | |
|
| 35 | 0 | 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 | 0 | Properties baseProperties = new Properties(); |
| 41 | 0 | if (ConfigContext.getCurrentContextConfig() != null) { |
| 42 | 0 | oldConfig = ConfigContext.getCurrentContextConfig(); |
| 43 | |
} |
| 44 | |
|
| 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 | 0 | return config; |
| 54 | |
} |
| 55 | |
|
| 56 | |
public Class getObjectType() { |
| 57 | 0 | return Config.class; |
| 58 | |
} |
| 59 | |
|
| 60 | |
public boolean isSingleton() { |
| 61 | 0 | return true; |
| 62 | |
} |
| 63 | |
|
| 64 | |
public List<String> getConfigLocations() { |
| 65 | 0 | return this.configLocations; |
| 66 | |
} |
| 67 | |
|
| 68 | |
public void setConfigLocations(List<String> configLocations) { |
| 69 | 0 | this.configLocations = configLocations; |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
} |