svn commit: r1141314 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1141314 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java

doogie-3
Author: doogie
Date: Wed Jun 29 23:09:39 2011
New Revision: 1141314

URL: http://svn.apache.org/viewvc?rev=1141314&view=rev
Log:
FEATURE: Do GenericHelper initialization in parallel.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1141314&r1=1141313&r2=1141314&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Wed Jun 29 23:09:39 2011
@@ -27,6 +27,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 
@@ -35,6 +37,7 @@ import javax.xml.parsers.ParserConfigura
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
+import org.ofbiz.base.concurrent.ExecutionPool;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralRuntimeException;
 import org.ofbiz.base.util.UtilDateTime;
@@ -239,9 +242,11 @@ public class GenericDelegator implements
 
         // initialize helpers by group
         Set<String> groupNames = getModelGroupReader().getGroupNames(delegatorBaseName);
+        List<Future<Void>> futures = FastList.newInstance();
         for (String groupName: groupNames) {
-            initializeOneGenericHelper(groupName);
+            futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createHelperCallable(groupName)));
         }
+        ExecutionPool.getAllFutures(futures);
 
         // NOTE: doing some things before the ECAs and such to make sure it is in place just in case it is used in a service engine startup thing or something
 
@@ -276,6 +281,15 @@ public class GenericDelegator implements
         }
     }
 
+    protected Callable<Void> createHelperCallable(final String groupName) {
+        return new Callable<Void>() {
+            public Void call() {
+                initializeOneGenericHelper(groupName);
+                return null;
+            }
+        };
+    }
+
     protected void setDelegatorNames(String delegatorFullName) {
         this.delegatorFullName = delegatorFullName;