Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 43853 invoked from network); 1 Feb 2005 00:42:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Feb 2005 00:42:03 -0000 Received: (qmail 67628 invoked by uid 500); 1 Feb 2005 00:42:03 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 67471 invoked by uid 500); 1 Feb 2005 00:42:02 -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 Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 67457 invoked by uid 99); 1 Feb 2005 00:42:02 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 31 Jan 2005 16:42:02 -0800 Received: (qmail 43826 invoked by uid 65534); 1 Feb 2005 00:42:01 -0000 Message-ID: <20050201004201.43822.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Tue, 01 Feb 2005 00:42:01 -0000 Subject: svn commit: r149334 - geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java To: scm@geronimo.apache.org From: djencks@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: djencks Date: Mon Jan 31 16:41:59 2005 New Revision: 149334 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D149334 Log: GERONIMO-561 Don't add a connection to an inactive transaction context Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector= /outbound/TransactionCachingInterceptor.java Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/con= nector/outbound/TransactionCachingInterceptor.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/jav= a/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java= ?view=3Ddiff&r1=3D149333&r2=3D149334 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector= /outbound/TransactionCachingInterceptor.java (original) +++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector= /outbound/TransactionCachingInterceptor.java Mon Jan 31 16:41:59 2005 @@ -32,18 +32,18 @@ * TransactionCachingInterceptor.java * TODO: This implementation does not take account of unshareable resources * TODO: This implementation does not take account of application security - * where several connections with different security info are obtained. + * where several connections with different security info are obtained. * TODO: This implementation does not take account of container managed se= curity where, - * within one transaction, a security domain boundary is crossed + * within one transaction, a security domain boundary is crossed * and connections are obtained with two (or more) different subjects. - * + *

* I suggest a state pattern, with the state set in a threadlocal upon ent= ering a component, * will be a usable implementation. - * + *

* The afterCompletion method will need to move to an interface, and that= interface include the * security info to distinguish connections. - * - * + *

+ *

* Created: Mon Sep 29 15:07:07 2003 * * @version 1.0 @@ -60,30 +60,32 @@ =20 public void getConnection(ConnectionInfo connectionInfo) throws Resour= ceException { TransactionContext transactionContext =3D transactionContextManage= r=2EgetContext(); - if (transactionContext =3D=3D null) { + //There can be an inactive transaction context when a connection i= s requested in + //Synchronization.afterCompletion(). + if (transactionContext =3D=3D null || !transactionContext.isActive= ()) { next.getConnection(connectionInfo); } else { - ManagedConnectionInfos managedConnectionInfos =3D (ManagedConnecti= onInfos) transactionContext.getManagedConnectionInfo(this); - if (managedConnectionInfos =3D=3D null) { - managedConnectionInfos =3D new ManagedConnectionInfos(); - transactionContext.setManagedConnectionInfo(this, managedConne= ctionInfos); - } - if (connectionInfo.isUnshareable()) { - if (!managedConnectionInfos.containsUnshared(connectionInfo.ge= tManagedConnectionInfo())) { - next.getConnection(connectionInfo); - managedConnectionInfos.addUnshared(connectionInfo.getManag= edConnectionInfo()); + ManagedConnectionInfos managedConnectionInfos =3D (ManagedConn= ectionInfos) transactionContext.getManagedConnectionInfo(this); + if (managedConnectionInfos =3D=3D null) { + managedConnectionInfos =3D new ManagedConnectionInfos(); + transactionContext.setManagedConnectionInfo(this, managedC= onnectionInfos); } - } else { - ManagedConnectionInfo managedConnectionInfo =3D managedConnect= ionInfos.getShared(); - if (managedConnectionInfo !=3D null) { - connectionInfo.setManagedConnectionInfo(managedConnectionI= nfo); - return; + if (connectionInfo.isUnshareable()) { + if (!managedConnectionInfos.containsUnshared(connectionInf= o=2EgetManagedConnectionInfo())) { + next.getConnection(connectionInfo); + managedConnectionInfos.addUnshared(connectionInfo.getM= anagedConnectionInfo()); + } } else { - next.getConnection(connectionInfo); - managedConnectionInfos.setShared(connectionInfo.getManaged= ConnectionInfo()); + ManagedConnectionInfo managedConnectionInfo =3D managedCon= nectionInfos.getShared(); + if (managedConnectionInfo !=3D null) { + connectionInfo.setManagedConnectionInfo(managedConnect= ionInfo); + return; + } else { + next.getConnection(connectionInfo); + managedConnectionInfos.setShared(connectionInfo.getMan= agedConnectionInfo()); + } } } - } } =20 public void returnConnection(ConnectionInfo connectionInfo, Connection= ReturnAction connectionReturnAction) { @@ -97,6 +99,10 @@ if (transactionContext !=3D null && transactionContext.isActive())= { return; } + internalReturn(connectionInfo, connectionReturnAction); + } + + private void internalReturn(ConnectionInfo connectionInfo, ConnectionR= eturnAction connectionReturnAction) { if (connectionInfo.getManagedConnectionInfo().hasConnectionHandles= ()) { return; } @@ -105,7 +111,7 @@ } =20 public void afterCompletion(Object stuff) { - ManagedConnectionInfos managedConnectionInfos =3D (ManagedConnecti= onInfos)stuff; + ManagedConnectionInfos managedConnectionInfos =3D (ManagedConnecti= onInfos) stuff; ManagedConnectionInfo sharedMCI =3D managedConnectionInfos.getShar= ed(); if (sharedMCI !=3D null) { returnHandle(sharedMCI); @@ -119,7 +125,7 @@ private void returnHandle(ManagedConnectionInfo managedConnectionInfo)= { ConnectionInfo connectionInfo =3D new ConnectionInfo(); connectionInfo.setManagedConnectionInfo(managedConnectionInfo); - returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HAN= DLE); + internalReturn(connectionInfo, ConnectionReturnAction.RETURN_HANDL= E); } =20 static class ManagedConnectionInfos {