| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kns.config; |
| 18 | |
|
| 19 | |
import org.kuali.rice.core.api.config.ConfigurationException; |
| 20 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 21 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 22 | |
import org.kuali.rice.core.impl.config.module.ModuleConfigurer; |
| 23 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 24 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
| 25 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 26 | |
import org.kuali.rice.kns.util.KNSConstants; |
| 27 | |
|
| 28 | |
import javax.sql.DataSource; |
| 29 | |
import java.util.ArrayList; |
| 30 | |
import java.util.List; |
| 31 | |
|
| 32 | 0 | public class KNSConfigurer extends ModuleConfigurer { |
| 33 | |
|
| 34 | |
private DataSource applicationDataSource; |
| 35 | |
private DataSource serverDataSource; |
| 36 | |
|
| 37 | |
private static final String KNS_SPRING_BEANS_PATH = "classpath:org/kuali/rice/kns/config/KNSSpringBeans.xml"; |
| 38 | |
private static final String KNS_KSB_SPRING_BEANS_PATH = "classpath:org/kuali/rice/kns/config/KNSServiceBusSpringBeans.xml"; |
| 39 | |
|
| 40 | |
@Override |
| 41 | |
public void addAdditonalToConfig() { |
| 42 | 0 | configureDataSource(); |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
@Override |
| 46 | |
public List<String> getPrimarySpringFiles() { |
| 47 | 0 | final List<String> springFileLocations = new ArrayList<String>(); |
| 48 | |
|
| 49 | |
|
| 50 | 0 | if ( isExposeServicesOnBus() ) { |
| 51 | 0 | springFileLocations.add(KNS_KSB_SPRING_BEANS_PATH); |
| 52 | |
} |
| 53 | 0 | return springFileLocations; |
| 54 | |
} |
| 55 | |
|
| 56 | |
@Override |
| 57 | |
public void doAdditionalContextStartedLogic() { |
| 58 | 0 | loadDataDictionary(); |
| 59 | 0 | } |
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
private void loadDataDictionary() { |
| 68 | 0 | if (isLoadDataDictionary()) { |
| 69 | 0 | LOG.info("KNS Configurer - Loading DD"); |
| 70 | 0 | DataDictionaryService dds = KNSServiceLocatorWeb.getDataDictionaryService(); |
| 71 | 0 | if ( dds == null ) { |
| 72 | 0 | dds = (DataDictionaryService) GlobalResourceLoader.getService(KNSServiceLocatorWeb.DATA_DICTIONARY_SERVICE); |
| 73 | |
} |
| 74 | 0 | dds.getDataDictionary().parseDataDictionaryConfigurationFiles(false); |
| 75 | |
|
| 76 | 0 | if ( isValidateDataDictionary() ) { |
| 77 | 0 | LOG.info("KNS Configurer - Validating DD"); |
| 78 | 0 | dds.getDataDictionary().validateDD( isValidateDataDictionaryEboReferences() ); |
| 79 | |
} |
| 80 | |
|
| 81 | 0 | dds.getDataDictionary().performBeanOverrides(); |
| 82 | |
} |
| 83 | 0 | } |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
@Override |
| 91 | |
public boolean shouldRenderWebInterface() { |
| 92 | 0 | return true; |
| 93 | |
} |
| 94 | |
|
| 95 | |
public boolean isLoadDataDictionary() { |
| 96 | 0 | return Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty("load.data.dictionary")).booleanValue(); |
| 97 | |
} |
| 98 | |
|
| 99 | |
public boolean isValidateDataDictionary() { |
| 100 | 0 | return Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty("validate.data.dictionary")).booleanValue(); |
| 101 | |
} |
| 102 | |
|
| 103 | |
public boolean isValidateDataDictionaryEboReferences() { |
| 104 | 0 | return Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty("validate.data.dictionary.ebo.references")).booleanValue(); |
| 105 | |
} |
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
protected void configureDataSource() { |
| 114 | 0 | if (getApplicationDataSource() != null && getServerDataSource() == null) { |
| 115 | 0 | throw new ConfigurationException("An application data source was defined but a server data source was not defined. Both must be specified."); |
| 116 | |
} |
| 117 | 0 | if (getApplicationDataSource() == null && getServerDataSource() != null) { |
| 118 | 0 | throw new ConfigurationException("A server data source was defined but an application data source was not defined. Both must be specified."); |
| 119 | |
} |
| 120 | |
|
| 121 | 0 | if (getApplicationDataSource() != null) { |
| 122 | 0 | ConfigContext.getCurrentContextConfig().putObject(KNSConstants.KNS_APPLICATION_DATASOURCE, getApplicationDataSource()); |
| 123 | |
} |
| 124 | 0 | if (getServerDataSource() != null) { |
| 125 | 0 | ConfigContext.getCurrentContextConfig().putObject(KNSConstants.KNS_SERVER_DATASOURCE, getServerDataSource()); |
| 126 | |
} |
| 127 | 0 | } |
| 128 | |
|
| 129 | |
public DataSource getApplicationDataSource() { |
| 130 | 0 | return this.applicationDataSource; |
| 131 | |
} |
| 132 | |
|
| 133 | |
public DataSource getServerDataSource() { |
| 134 | 0 | return this.serverDataSource; |
| 135 | |
} |
| 136 | |
|
| 137 | |
public void setApplicationDataSource(DataSource applicationDataSource) { |
| 138 | 0 | this.applicationDataSource = applicationDataSource; |
| 139 | 0 | } |
| 140 | |
|
| 141 | |
public void setServerDataSource(DataSource serverDataSource) { |
| 142 | 0 | this.serverDataSource = serverDataSource; |
| 143 | 0 | } |
| 144 | |
} |