Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

[hibernate-commits] Hibernate SVN: r15168 -
 core/trunk/core/src/main/java/org/hibernate/context.

hibernate-commits

2008-09-09


Author LoginPost Reply
Author: steve.ebersole@(protected)
Date: 2008-09-09 17:27:28 -0400 (Tue, 09 Sep 2008)
New Revision: 15168

Modified:
 core/trunk/core/src/main/java/org/hibernate/context/JTASessionContext.java
Log:
HHH-3472 : WebSphere + JTASessionContext

Modified: core/trunk/core/src/main/java/org/hibernate/context/JTASessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/JTASessionContext.java  2008-09-09 21:27:11 UTC (rev 15167)
+++ core/trunk/core/src/main/java/org/hibernate/context/JTASessionContext.java  2008-09-09 21:27:28 UTC (rev 15168)
@@(protected) @@
     throw new HibernateException( "Problem locating/validating JTA transaction", t );
   }

-    Session currentSession = ( Session ) currentSessionMap.get( txn );
+    final Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
+        ? txn
+        : factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );

+    Session currentSession = ( Session ) currentSessionMap.get( txnIdentifier );
+
   if ( currentSession == null ) {
     currentSession = buildOrObtainSession();

     try {
-        txn.registerSynchronization( buildCleanupSynch( txn ) );
+        txn.registerSynchronization( buildCleanupSynch( txnIdentifier ) );
     }
     catch ( Throwable t ) {
       try {
@@(protected) @@
       throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" );
     }

-      Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
-          ? txn
-          : factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
     currentSessionMap.put( txnIdentifier, currentSession );
   }

   return currentSession;
 }

-  private CleanupSynch buildCleanupSynch(Transaction txn) {
-    return new CleanupSynch( txn, this );
+  /**
+   * Builds a {@(protected)
+   * callback.
+   *
+   * @param transactionIdentifier The transaction identifier under which the current session is registered.
+   * @return The cleanup synch.
+   */
+  private CleanupSynch buildCleanupSynch(Object transactionIdentifier) {
+    return new CleanupSynch( transactionIdentifier, this );
 }

 /**
@@(protected) @@
  * JTA transaction synch used for cleanup of the internal session map.
  */
 protected static class CleanupSynch implements Synchronization {
-    private Transaction txn;
+    private Object transactionIdentifier;
   private JTASessionContext context;

-    public CleanupSynch(Transaction txn, JTASessionContext context) {
-      this.txn = txn;
+    public CleanupSynch(Object transactionIdentifier, JTASessionContext context) {
+      this.transactionIdentifier = transactionIdentifier;
     this.context = context;
   }

@@(protected) @@
    * {@(protected)}
    */
   public void afterCompletion(int i) {
-      context.currentSessionMap.remove( txn );
+      context.currentSessionMap.remove( transactionIdentifier );
   }
 }
}

_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits
©2008 gg3721.com - Jax Systems, LLC, U.S.A.