| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.krad.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.krad.service.DataDictionaryService; |
| 24 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
| 25 | |
import org.kuali.rice.krad.util.KRADConstants; |
| 26 | |
|
| 27 | |
import javax.sql.DataSource; |
| 28 | |
import java.util.ArrayList; |
| 29 | |
import java.util.List; |
| 30 | |
|
| 31 | 0 | public class KRADConfigurer extends ModuleConfigurer { |
| 32 | |
|
| 33 | |
private DataSource applicationDataSource; |
| 34 | |
private DataSource serverDataSource; |
| 35 | |
|
| 36 | |
private boolean includeKnsSpringBeans; |
| 37 | |
|
| 38 | |
private static final String KRAD_SPRING_BEANS_PATH = "classpath:org/kuali/rice/krad/config/KRADSpringBeans.xml"; |
| 39 | |
private static final String KRAD_KSB_SPRING_BEANS_PATH = |
| 40 | |
"classpath:org/kuali/rice/krad/config/KRADServiceBusSpringBeans.xml"; |
| 41 | |
private static final String KNS_SPRING_BEANS_PATH = "classpath:org/kuali/rice/kns/config/KNSSpringBeans.xml"; |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public void addAdditonalToConfig() { |
| 45 | 0 | configureDataSource(); |
| 46 | 0 | } |
| 47 | |
|
| 48 | |
@Override |
| 49 | |
public List<String> getPrimarySpringFiles() { |
| 50 | 0 | final List<String> springFileLocations = new ArrayList<String>(); |
| 51 | 0 | springFileLocations.add(KRAD_SPRING_BEANS_PATH); |
| 52 | |
|
| 53 | 0 | if (isExposeServicesOnBus()) { |
| 54 | 0 | springFileLocations.add(KRAD_KSB_SPRING_BEANS_PATH); |
| 55 | |
} |
| 56 | |
|
| 57 | 0 | if (isIncludeKnsSpringBeans()) { |
| 58 | 0 | springFileLocations.add(KNS_SPRING_BEANS_PATH); |
| 59 | |
} |
| 60 | |
|
| 61 | 0 | return springFileLocations; |
| 62 | |
} |
| 63 | |
|
| 64 | |
@Override |
| 65 | |
public void doAdditionalContextStartedLogic() { |
| 66 | 0 | loadDataDictionary(); |
| 67 | 0 | } |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
private void loadDataDictionary() { |
| 76 | 0 | if (isLoadDataDictionary()) { |
| 77 | 0 | LOG.info("KRAD Configurer - Loading DD"); |
| 78 | 0 | DataDictionaryService dds = KRADServiceLocatorWeb.getDataDictionaryService(); |
| 79 | 0 | if (dds == null) { |
| 80 | 0 | dds = (DataDictionaryService) GlobalResourceLoader |
| 81 | |
.getService(KRADServiceLocatorWeb.DATA_DICTIONARY_SERVICE); |
| 82 | |
} |
| 83 | 0 | dds.getDataDictionary().parseDataDictionaryConfigurationFiles(false); |
| 84 | |
|
| 85 | 0 | if (isValidateDataDictionary()) { |
| 86 | 0 | LOG.info("KRAD Configurer - Validating DD"); |
| 87 | 0 | dds.getDataDictionary().validateDD(isValidateDataDictionaryEboReferences()); |
| 88 | |
} |
| 89 | |
|
| 90 | 0 | dds.getDataDictionary().performBeanOverrides(); |
| 91 | |
} |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
@Override |
| 100 | |
public boolean shouldRenderWebInterface() { |
| 101 | 0 | return true; |
| 102 | |
} |
| 103 | |
|
| 104 | |
public boolean isLoadDataDictionary() { |
| 105 | 0 | return Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty("load.data.dictionary")) |
| 106 | |
.booleanValue(); |
| 107 | |
} |
| 108 | |
|
| 109 | |
public boolean isValidateDataDictionary() { |
| 110 | 0 | return Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty("validate.data.dictionary")) |
| 111 | |
.booleanValue(); |
| 112 | |
} |
| 113 | |
|
| 114 | |
public boolean isValidateDataDictionaryEboReferences() { |
| 115 | 0 | return Boolean |
| 116 | |
.valueOf(ConfigContext.getCurrentContextConfig().getProperty("validate.data.dictionary.ebo.references")) |
| 117 | |
.booleanValue(); |
| 118 | |
} |
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
protected void configureDataSource() { |
| 127 | 0 | if (getApplicationDataSource() != null && getServerDataSource() == null) { |
| 128 | 0 | throw new ConfigurationException( |
| 129 | |
"An application data source was defined but a server data source was not defined. Both must be specified."); |
| 130 | |
} |
| 131 | 0 | if (getApplicationDataSource() == null && getServerDataSource() != null) { |
| 132 | 0 | throw new ConfigurationException( |
| 133 | |
"A server data source was defined but an application data source was not defined. Both must be specified."); |
| 134 | |
} |
| 135 | |
|
| 136 | 0 | if (getApplicationDataSource() != null) { |
| 137 | 0 | ConfigContext.getCurrentContextConfig() |
| 138 | |
.putObject(KRADConstants.KRAD_APPLICATION_DATASOURCE, getApplicationDataSource()); |
| 139 | |
} |
| 140 | 0 | if (getServerDataSource() != null) { |
| 141 | 0 | ConfigContext.getCurrentContextConfig() |
| 142 | |
.putObject(KRADConstants.KRAD_SERVER_DATASOURCE, getServerDataSource()); |
| 143 | |
} |
| 144 | 0 | } |
| 145 | |
|
| 146 | |
public DataSource getApplicationDataSource() { |
| 147 | 0 | return this.applicationDataSource; |
| 148 | |
} |
| 149 | |
|
| 150 | |
public DataSource getServerDataSource() { |
| 151 | 0 | return this.serverDataSource; |
| 152 | |
} |
| 153 | |
|
| 154 | |
public void setApplicationDataSource(DataSource applicationDataSource) { |
| 155 | 0 | this.applicationDataSource = applicationDataSource; |
| 156 | 0 | } |
| 157 | |
|
| 158 | |
public void setServerDataSource(DataSource serverDataSource) { |
| 159 | 0 | this.serverDataSource = serverDataSource; |
| 160 | 0 | } |
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
public boolean isIncludeKnsSpringBeans() { |
| 169 | 0 | return includeKnsSpringBeans; |
| 170 | |
} |
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
public void setIncludeKnsSpringBeans(boolean includeKnsSpringBeans) { |
| 178 | 0 | this.includeKnsSpringBeans = includeKnsSpringBeans; |
| 179 | 0 | } |
| 180 | |
} |