| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.edl.impl.config; |
| 18 | |
|
| 19 | |
import org.apache.commons.lang.StringUtils; |
| 20 | |
import org.kuali.rice.core.api.config.module.RunMode; |
| 21 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 22 | |
import org.kuali.rice.core.api.lifecycle.Lifecycle; |
| 23 | |
import org.kuali.rice.core.api.resourceloader.ResourceLoader; |
| 24 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
| 25 | |
import org.kuali.rice.core.impl.config.module.ModuleConfigurer; |
| 26 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 27 | |
import org.kuali.rice.core.impl.resourceloader.RiceResourceLoaderFactory; |
| 28 | |
import org.kuali.rice.kew.lifecycle.EmbeddedLifeCycle; |
| 29 | |
import org.kuali.rice.kew.plugin.PluginRegistry; |
| 30 | |
import org.kuali.rice.kew.plugin.PluginRegistryFactory; |
| 31 | |
import org.kuali.rice.kew.resourceloader.CoreResourceLoader; |
| 32 | |
import org.kuali.rice.kew.util.KEWConstants.ClientProtocol; |
| 33 | |
|
| 34 | |
import javax.sql.DataSource; |
| 35 | |
import java.util.ArrayList; |
| 36 | |
import java.util.Collection; |
| 37 | |
import java.util.Collections; |
| 38 | |
import java.util.LinkedList; |
| 39 | |
import java.util.List; |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | 0 | public class EDLConfigurer extends ModuleConfigurer { |
| 48 | |
|
| 49 | |
public static final String KEW_DATASOURCE_OBJ = "org.kuali.workflow.datasource"; |
| 50 | |
|
| 51 | |
private DataSource dataSource; |
| 52 | |
|
| 53 | |
@Override |
| 54 | |
public List<String> getPrimarySpringFiles() { |
| 55 | |
final List<String> springFileLocations; |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | 0 | springFileLocations = getEmbeddedSpringFileLocation(); |
| 61 | |
|
| 62 | |
|
| 63 | 0 | return springFileLocations; |
| 64 | |
} |
| 65 | |
|
| 66 | |
private List<String> getEmbeddedSpringFileLocation(){ |
| 67 | 0 | final List<String> springFileLocations = new ArrayList<String>(); |
| 68 | 0 | springFileLocations.add("classpath:org/kuali/rice/edl/impl/config/EDLSpringBeans.xml"); |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | 0 | springFileLocations.add("classpath:org/kuali/rice/edl/impl/config/EDLOJBSpringBeans.xml"); |
| 83 | |
|
| 84 | |
|
| 85 | 0 | return springFileLocations; |
| 86 | |
} |
| 87 | |
|
| 88 | |
@Override |
| 89 | |
public void addAdditonalToConfig() { |
| 90 | 0 | configureDataSource(); |
| 91 | 0 | } |
| 92 | |
|
| 93 | |
private void configureDataSource() { |
| 94 | 0 | if (getDataSource() != null) { |
| 95 | 0 | ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource()); |
| 96 | |
} |
| 97 | 0 | } |
| 98 | |
|
| 99 | |
@Override |
| 100 | |
public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception { |
| 101 | |
|
| 102 | 0 | PluginRegistry registry = null; |
| 103 | 0 | String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled"); |
| 104 | 0 | if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) { |
| 105 | 0 | registry = new PluginRegistryFactory().createPluginRegistry(); |
| 106 | |
} |
| 107 | |
|
| 108 | 0 | final Collection<ResourceLoader> rls = new ArrayList<ResourceLoader>(); |
| 109 | 0 | for (ResourceLoader rl : RiceResourceLoaderFactory.getSpringResourceLoaders()) { |
| 110 | 0 | CoreResourceLoader coreResourceLoader = |
| 111 | |
new CoreResourceLoader(rl, registry); |
| 112 | 0 | coreResourceLoader.start(); |
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | 0 | GlobalResourceLoader.addResourceLoader(coreResourceLoader); |
| 119 | |
|
| 120 | |
|
| 121 | 0 | if (registry != null) { |
| 122 | 0 | registry.start(); |
| 123 | |
|
| 124 | |
|
| 125 | |
} |
| 126 | 0 | rls.add(coreResourceLoader); |
| 127 | 0 | } |
| 128 | |
|
| 129 | 0 | return rls; |
| 130 | |
} |
| 131 | |
|
| 132 | |
private ClientProtocol getClientProtocol() { |
| 133 | 0 | return ClientProtocol.valueOf(ConfigContext.getCurrentContextConfig().getProperty("client.protocol")); |
| 134 | |
} |
| 135 | |
|
| 136 | |
public DataSource getDataSource() { |
| 137 | 0 | return dataSource; |
| 138 | |
} |
| 139 | |
|
| 140 | |
public void setDataSource(DataSource dataSource) { |
| 141 | 0 | this.dataSource = dataSource; |
| 142 | 0 | } |
| 143 | |
} |