You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2011/06/30 01:09:51 UTC
svn commit: r1141316 -
/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
Author: doogie
Date: Wed Jun 29 23:09:50 2011
New Revision: 1141316
URL: http://svn.apache.org/viewvc?rev=1141316&view=rev
Log:
FEATURE: Parsing of eecas.xml files are now done in parallel, using the
global thread pool.
Modified:
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=1141316&r1=1141315&r2=1141316&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java Wed Jun 29 23:09:50 2011
@@ -21,11 +21,14 @@ package org.ofbiz.entityext.eca;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.component.ComponentConfig;
+import org.ofbiz.base.concurrent.ExecutionPool;
import org.ofbiz.base.config.GenericConfigException;
import org.ofbiz.base.config.MainResourceHandler;
import org.ofbiz.base.config.ResourceHandler;
@@ -78,20 +81,20 @@ public class EntityEcaUtil {
return;
}
- List<List<EntityEcaRule>> allRules = FastList.newInstance();
+ List<Future<List<EntityEcaRule>>> futures = FastList.newInstance();
for (Element eecaResourceElement: entityEcaReaderInfo.resourceElements) {
ResourceHandler handler = new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, eecaResourceElement);
- allRules.add(getEcaDefinitions(handler));
+ futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(handler)));
}
// get all of the component resource eca stuff, ie specified in each ofbiz-component.xml file
for (ComponentConfig.EntityResourceInfo componentResourceInfo: ComponentConfig.getAllEntityResourceInfos("eca")) {
if (entityEcaReaderName.equals(componentResourceInfo.readerName)) {
- allRules.add(getEcaDefinitions(componentResourceInfo.createResourceHandler()));
+ futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(componentResourceInfo.createResourceHandler())));
}
}
- for (List<EntityEcaRule> oneFileRules: allRules) {
+ for (List<EntityEcaRule> oneFileRules: ExecutionPool.getAllFutures(futures)) {
for (EntityEcaRule rule: oneFileRules) {
String entityName = rule.getEntityName();
String eventName = rule.getEventName();
@@ -134,6 +137,14 @@ public class EntityEcaUtil {
return rules;
}
+ protected static Callable<List<EntityEcaRule>> createEcaLoaderCallable(final ResourceHandler handler) {
+ return new Callable<List<EntityEcaRule>>() {
+ public List<EntityEcaRule> call() throws Exception {
+ return getEcaDefinitions(handler);
+ }
+ };
+ }
+
public static Collection<EntityEcaRule> getEntityEcaRules(Delegator delegator, String entityName, String event) {
Map<String, Map<String, List<EntityEcaRule>>> ecaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegator.getDelegatorName()));
Map<String, List<EntityEcaRule>> eventMap = ecaCache.get(entityName);