svn commit: r1141277 - /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: r1141277 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java

doogie-3
Author: doogie
Date: Wed Jun 29 22:11:25 2011
New Revision: 1141277

URL: http://svn.apache.org/viewvc?rev=1141277&view=rev
Log:
OPTIMIZE: Move the group helper initialization code out of the loop and
into a separate method.

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=1141277&r1=1141276&r2=1141277&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 22:11:25 2011
@@ -240,30 +240,7 @@ public class GenericDelegator implements
         // initialize helpers by group
         Set<String> groupNames = getModelGroupReader().getGroupNames(delegatorBaseName);
         for (String groupName: groupNames) {
-            GenericHelperInfo helperInfo = this.getGroupHelperInfo(groupName);
-            String helperBaseName = helperInfo.getHelperBaseName();
-
-            if (Debug.infoOn()) {
-                Debug.logInfo("Delegator \"" + delegatorFullName + "\" initializing helper \"" + helperBaseName + "\" for entity group \"" + groupName + "\".", module);
-            }
-            if (UtilValidate.isNotEmpty(helperInfo.getHelperFullName())) {
-                // pre-load field type defs, the return value is ignored
-                ModelFieldTypeReader.getModelFieldTypeReader(helperBaseName);
-                // get the helper and if configured, do the datasource check
-                GenericHelper helper = GenericHelperFactory.getHelper(helperInfo);
-
-                DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperBaseName);
-                if (datasourceInfo.checkOnStart) {
-                    if (Debug.infoOn()) {
-                        Debug.logInfo("Doing database check as requested in entityengine.xml with addMissing=" + datasourceInfo.addMissingOnStart, module);
-                    }
-                    try {
-                        helper.checkDataSource(this.getModelEntityMapByGroup(groupName), null, datasourceInfo.addMissingOnStart);
-                    } catch (GenericEntityException e) {
-                        Debug.logWarning(e, e.getMessage(), module);
-                    }
-                }
-            }
+            initializeOneGenericHelper(groupName);
         }
 
         // 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
@@ -272,6 +249,33 @@ public class GenericDelegator implements
         this.crypto = new EntityCrypto(this);
     }
 
+    private void initializeOneGenericHelper(String groupName) {
+        GenericHelperInfo helperInfo = this.getGroupHelperInfo(groupName);
+        String helperBaseName = helperInfo.getHelperBaseName();
+
+        if (Debug.infoOn()) {
+            Debug.logInfo("Delegator \"" + delegatorFullName + "\" initializing helper \"" + helperBaseName + "\" for entity group \"" + groupName + "\".", module);
+        }
+        if (UtilValidate.isNotEmpty(helperInfo.getHelperFullName())) {
+            // pre-load field type defs, the return value is ignored
+            ModelFieldTypeReader.getModelFieldTypeReader(helperBaseName);
+            // get the helper and if configured, do the datasource check
+            GenericHelper helper = GenericHelperFactory.getHelper(helperInfo);
+
+            DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperBaseName);
+            if (datasourceInfo.checkOnStart) {
+                if (Debug.infoOn()) {
+                    Debug.logInfo("Doing database check as requested in entityengine.xml with addMissing=" + datasourceInfo.addMissingOnStart, module);
+                }
+                try {
+                    helper.checkDataSource(this.getModelEntityMapByGroup(groupName), null, datasourceInfo.addMissingOnStart);
+                } catch (GenericEntityException e) {
+                    Debug.logWarning(e, e.getMessage(), module);
+                }
+            }
+        }
+    }
+
     protected void setDelegatorNames(String delegatorFullName) {
         this.delegatorFullName = delegatorFullName;