svn commit: r1226234 - in /ofbiz/trunk/framework/entity: config/entityengine.xml dtd/entity-config.xsd src/org/ofbiz/entity/config/EntityConfigUtil.java src/org/ofbiz/entity/transaction/TransactionUtil.java

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

svn commit: r1226234 - in /ofbiz/trunk/framework/entity: config/entityengine.xml dtd/entity-config.xsd src/org/ofbiz/entity/config/EntityConfigUtil.java src/org/ofbiz/entity/transaction/TransactionUtil.java

jleroux@apache.org
Author: jleroux
Date: Sun Jan  1 11:27:10 2012
New Revision: 1226234

URL: http://svn.apache.org/viewvc?rev=1226234&view=rev
Log:
A patch from Philippe Mouawad "Set TransactionUtil#debugResources default value to false and make it configurable" https://issues.apache.org/jira/browse/OFBIZ-4293

debugResources is true which creates a DebugXAResource (that creates an Exception) , it should be false and made an option for debuging

jleroux: see comments in Jira 4282 for more

Modified:
    ofbiz/trunk/framework/entity/config/entityengine.xml
    ofbiz/trunk/framework/entity/dtd/entity-config.xsd
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java

Modified: ofbiz/trunk/framework/entity/config/entityengine.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/config/entityengine.xml?rev=1226234&r1=1226233&r2=1226234&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/config/entityengine.xml (original)
+++ ofbiz/trunk/framework/entity/config/entityengine.xml Sun Jan  1 11:27:10 2012
@@ -48,6 +48,7 @@ access. For a detailed description see t
 
     <!-- the connection factory class to use, one is needed for obtaining connections/pools for defined resources -->
     <connection-factory class="org.ofbiz.entity.connection.DBCPConnectionFactory"/>
+    <!-- debug-xa-resources value="true" --> <!-- see https://issues.apache.org/jira/browse/OFBIZ-4282 for more -->
 
     <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
         <group-map group-name="org.ofbiz" datasource-name="localderby"/>

Modified: ofbiz/trunk/framework/entity/dtd/entity-config.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/dtd/entity-config.xsd?rev=1226234&r1=1226233&r2=1226234&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/dtd/entity-config.xsd (original)
+++ ofbiz/trunk/framework/entity/dtd/entity-config.xsd Sun Jan  1 11:27:10 2012
@@ -25,6 +25,7 @@ under the License.
                 <xs:element maxOccurs="unbounded" ref="resource-loader"/>
                 <xs:element ref="transaction-factory"/>
                 <xs:element ref="connection-factory"/>
+                <xs:element ref="debug-xa-resources"/>
                 <xs:element maxOccurs="unbounded" ref="delegator"/>
                 <xs:element maxOccurs="unbounded" ref="entity-model-reader"/>
                 <xs:element maxOccurs="unbounded" ref="entity-group-reader"/>
@@ -81,6 +82,11 @@ under the License.
             <xs:attributeGroup ref="attlist.connection-factory"/>
         </xs:complexType>
     </xs:element>
+    <xs:element name="debug-xa-resources">
+        <xs:complexType>
+            <xs:attribute default="false"  name="value" type="xs:boolean"/>
+        </xs:complexType>
+    </xs:element>
     <xs:attributeGroup name="attlist.connection-factory">
         <xs:attribute type="xs:string" name="class" use="required"/>
     </xs:attributeGroup>

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java?rev=1226234&r1=1226233&r2=1226234&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java Sun Jan  1 11:27:10 2012
@@ -48,6 +48,10 @@ public class EntityConfigUtil {
     private final String txFactoryTxMgrJndiName;
     private final String txFactoryTxMgrJndiServerName;
     private final String connFactoryClass;
+    /**
+     * Create Begin stacktrace when enlisting transactions
+     */
+    private final Boolean debugXAResources;
 
     private final Map<String, ResourceLoaderInfo> resourceLoaderInfos = new HashMap<String, ResourceLoaderInfo>();
     private final Map<String, DelegatorInfo> delegatorInfos = new HashMap<String, DelegatorInfo>();
@@ -122,6 +126,12 @@ public class EntityConfigUtil {
 
         connFactoryClass = connectionFactoryElement.getAttribute("class");
 
+        Element debugXaResourcesElement = UtilXml.firstChildElement(rootElement, "debug-xa-resources");
+        if (debugXaResourcesElement == null) {
+            debugXAResources = false;
+        } else {
+            debugXAResources = "true".equals(debugXaResourcesElement.getAttribute("value"));
+        }
         // not load all of the maps...
 
         // resource-loader - resourceLoaderInfos
@@ -188,6 +198,13 @@ public class EntityConfigUtil {
     public static String getTxFactoryTxMgrJndiName() {
         return configRef.get().txFactoryTxMgrJndiName;
     }
+    
+    /**
+     * @return true Create Begin stacktrace when enlisting transactions
+     */
+    public static boolean isDebugXAResource() {
+        return configRef.get().debugXAResources;
+    }
 
     public static String getTxFactoryTxMgrJndiServerName() {
         return configRef.get().txFactoryTxMgrJndiServerName;

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java?rev=1226234&r1=1226233&r2=1226234&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java Sun Jan  1 11:27:10 2012
@@ -53,6 +53,7 @@ import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.config.EntityConfigUtil;
 
 /**
  * <p>Transaction Utility to help with some common transaction tasks
@@ -62,7 +63,7 @@ public class TransactionUtil implements
     // Debug module name
     public static final String module = TransactionUtil.class.getName();
     public static Map<Xid, DebugXaResource> debugResMap = Collections.<Xid, DebugXaResource>synchronizedMap(new HashMap<Xid, DebugXaResource>());
-    public static boolean debugResources = true;
+    public static boolean debugResources = EntityConfigUtil.isDebugXAResource();
 
     private static ThreadLocal<List<Transaction>> suspendedTxStack = new ThreadLocal<List<Transaction>>();
     private static ThreadLocal<List<Exception>> suspendedTxLocationStack = new ThreadLocal<List<Exception>>();