openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1536596 - in /openjpa/branches/2.3.x: ./ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/audit/ openjpa-persistence-jdbc/src/test/resources/META-INF/
Date Tue, 29 Oct 2013 06:37:52 GMT
Author: struberg
Date: Tue Oct 29 06:37:51 2013
New Revision: 1536596

URL: http://svn.apache.org/r1536596
Log:
OPENJPA-2437 transactional listeners added too late to observe begin event

txs 2 rmannibucau for the fix.
Patch applied with cleanup and tests pimped. 


Added:
    openjpa/branches/2.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/audit/TestBeginEventOnTransactionListener.java
      - copied unchanged from r1536595, openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/audit/TestBeginEventOnTransactionListener.java
Modified:
    openjpa/branches/2.3.x/   (props changed)
    openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    openjpa/branches/2.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml

Propchange: openjpa/branches/2.3.x/
------------------------------------------------------------------------------
  Merged /openjpa/trunk:r1536595

Modified: openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=1536596&r1=1536595&r2=1536596&view=diff
==============================================================================
--- openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Tue Oct 29 06:37:51 2013
@@ -227,8 +227,6 @@ public abstract class AbstractBrokerFact
         DelegatingStoreManager dsm = createDelegatingStoreManager();
 
         ((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization);
-        if (!fromDeserialization)
-            addListeners(broker);
 
         // if we're using remote events, register the event manager so
         // that it can broadcast commit notifications from the broker

Modified: openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=1536596&r1=1536595&r2=1536596&view=diff
==============================================================================
--- openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ openjpa/branches/2.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Tue Oct 29 06:37:51 2013
@@ -391,6 +391,11 @@ public class BrokerImpl implements Broke
         _printParameters =
             Boolean.parseBoolean(Configurations.parseProperties(_conf.getConnectionFactoryProperties()).getProperty(
                 PRINT_PARAMETERS_CONFIG_STR, "false"));
+
+        // do it before begin event otherwise transactional listeners can't use it, see @Auditable
+        if (!fromDeserialization)
+            _factory.addListeners(this);
+
         // synch with the global transaction in progress, if any
         if (_factory.syncWithManagedTransaction(this, false))
             beginInternal();

Modified: openjpa/branches/2.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=1536596&r1=1536595&r2=1536596&view=diff
==============================================================================
--- openjpa/branches/2.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
(original)
+++ openjpa/branches/2.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
Tue Oct 29 06:37:51 2013
@@ -442,6 +442,17 @@
     </persistence-unit>
 
 
+  <persistence-unit name="auditjta" transaction-type="JTA">
+    <class>org.apache.openjpa.audit.X</class>
+    <class>org.apache.openjpa.audit.AuditedEntry</class>
+
+    <properties>
+      <property name="openjpa.Auditor" value="org.apache.openjpa.audit.TestBeginEventOnTransactionListener$MockAuditor"
/>
+      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"
/>
+      <property name="openjpa.DynamicEnhancementAgent" value="false" />
+      <property name="openjpa.ManagedRuntime" value="org.apache.openjpa.jta.JTAManagedRuntime"/>
+    </properties>
+  </persistence-unit>
 	<persistence-unit name="audit">
 		<class>org.apache.openjpa.audit.X</class>
 		<class>org.apache.openjpa.audit.AuditedEntry</class>



Mime
View raw message