Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 24752 invoked from network); 5 Feb 2007 01:36:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2007 01:36:09 -0000 Received: (qmail 56787 invoked by uid 500); 5 Feb 2007 01:36:15 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 56651 invoked by uid 500); 5 Feb 2007 01:36:15 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 56640 invoked by uid 99); 5 Feb 2007 01:36:15 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Feb 2007 17:36:15 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Feb 2007 17:36:08 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 4C3491A981A; Sun, 4 Feb 2007 17:35:48 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r503531 - /geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Date: Mon, 05 Feb 2007 01:35:48 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070205013548.4C3491A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Sun Feb 4 17:35:47 2007 New Revision: 503531 URL: http://svn.apache.org/viewvc?view=rev&rev=503531 Log: GERONIMO-2795 Allow lots of interposed synchs to be registered Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?view=diff&rev=503531&r1=503530&r2=503531 ============================================================================== --- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java (original) +++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Sun Feb 4 17:35:47 2007 @@ -54,6 +54,7 @@ private final TransactionLog txnLog; private final long timeout; private final List syncList = new ArrayList(5); + private final List interposedSyncList = new ArrayList(3); private final LinkedList resourceManagers = new LinkedList(); private final IdentityHashMap activeXaResources = new IdentityHashMap(3); private final IdentityHashMap suspendedXaResources = new IdentityHashMap(3); @@ -61,7 +62,6 @@ private Object logMark; private final Map resources = new HashMap(); - private Synchronization interposedSynchronization; private final Map entityManagers = new HashMap(); TransactionImpl(XidFactory xidFactory, TransactionLog txnLog, long transactionTimeoutMilliseconds) throws SystemException { @@ -122,7 +122,7 @@ } public void registerInterposedSynchronization(Synchronization synchronization) { - interposedSynchronization = synchronization; + interposedSyncList.add(synchronization); } public synchronized void setRollbackOnly() throws IllegalStateException { @@ -494,21 +494,19 @@ } private void beforeCompletion() { + beforeCompletion(syncList); + beforeCompletion(interposedSyncList); + } + + private void beforeCompletion(List syncs) { int i = 0; while (true) { Synchronization synch; synchronized (this) { - if (i == syncList.size()) { - if (interposedSynchronization != null) { - synch = interposedSynchronization; - i++; - } else { - return; - } - } else if (i == syncList.size() + 1) { + if (i == syncs.size()) { return; } else { - synch = (Synchronization) syncList.get(i++); + synch = (Synchronization) syncs.get(i++); } } try { @@ -524,26 +522,23 @@ private void afterCompletion() { // this does not synchronize because nothing can modify our state at this time - if (interposedSynchronization != null) { - try { - interposedSynchronization.afterCompletion(status); - } catch (Exception e) { - log.warn("Unexpected exception from afterCompletion; continuing", e); - } + afterCompletion(interposedSyncList); + afterCompletion(syncList); + for (Iterator i = entityManagers.values().iterator(); i.hasNext();) { + Closeable entityManager = (Closeable) i.next(); + entityManager.close(); } - for (Iterator i = syncList.iterator(); i.hasNext();) { + } + + private void afterCompletion(List syncs) { + for (Iterator i = syncs.iterator(); i.hasNext();) { Synchronization synch = (Synchronization) i.next(); try { synch.afterCompletion(status); } catch (Exception e) { log.warn("Unexpected exception from afterCompletion; continuing", e); - continue; } } - for (Iterator i = entityManagers.values().iterator(); i.hasNext();) { - Closeable entityManager = (Closeable) i.next(); - entityManager.close(); - } } private void endResources() { @@ -592,7 +587,6 @@ if (cause == null) { cause = new SystemException(e.errorCode); } - continue; } } synchronized (this) { @@ -617,7 +611,6 @@ if (cause == null) { cause = new SystemException(e.errorCode); } - continue; } } //if all resources were read only, we didn't write a prepare record.