Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 26897 invoked from network); 22 Jul 2004 15:08:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 22 Jul 2004 15:08:14 -0000 Received: (qmail 99963 invoked by uid 500); 22 Jul 2004 15:08:11 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 99767 invoked by uid 500); 22 Jul 2004 15:08:09 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 99751 invoked by uid 99); 22 Jul 2004 15:08:09 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received: from [141.20.1.28] (HELO nsuncom2.rz.hu-berlin.de) (141.20.1.28) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 22 Jul 2004 08:08:07 -0700 Received: from localhost (nsuncom.rz.hu-berlin.de [141.20.1.7]) by nsuncom2.rz.hu-berlin.de (8.12.11/8.12.11) with ESMTP id i6MF840j021722 for ; Thu, 22 Jul 2004 17:08:04 +0200 (MEST) Received: from nsuncom.rz.hu-berlin.de ([127.0.0.1]) by localhost (nsuncom [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 02732-02 for ; Thu, 22 Jul 2004 17:08:02 +0200 (MEST) Received: from apache.org (isdnppp0.informatik.hu-berlin.de [141.20.29.140]) by nsuncom.rz.hu-berlin.de (8.12.10/8.12.10) with ESMTP id i6MF7vVS002796 for ; Thu, 22 Jul 2004 17:07:58 +0200 (MEST) Message-ID: <40FFD83E.8050404@apache.org> Date: Thu, 22 Jul 2004 17:07:42 +0200 From: =?ISO-8859-1?Q?Stefan_L=FCtzkendorf?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: [transaction] Extended TransactionalResource interface Content-Type: multipart/mixed; boundary="------------070705000808090402090400" X-Virus-Scanned: by amavisd-new at hu-berlin.de X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --------------070705000808090402090400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello Oliver, while using MapXAResource and the TransactionalMapWrapper's for implementing the transient stores for slide I found that the interface TransactionalMapWrapper has no methods for starting, suspending and resuming a transaction. So my first draft of AbstractTransientStore has to deal with the transactional map directly and has to add some extra logic for starting, suspending and resuming a transaction. Just for a trail I have extended the interface, added the corresponding calls to AbstractXAResource and modified MapTransactionalResource. With these changes the impelementation of slides AbstractTransientStore would be relly lean and nice. I attach the corresponding patch at this mail. This change would require that we adapt slides AbstractRDBMSStore.TransactionId XAServiceBase.DummyTxResource too, but I think thats no problem. What do you think? Regards, Stefan --------------070705000808090402090400 Content-Type: text/plain; name="patch-transaction.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-transaction.txt" Index: src/java/org/apache/commons/transaction/memory/jca/MapXAResource.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/jca/MapXAResource.java,v retrieving revision 1.4 diff -u -r1.4 MapXAResource.java --- src/java/org/apache/commons/transaction/memory/jca/MapXAResource.java 20 Jul 2004 09:21:31 -0000 1.4 +++ src/java/org/apache/commons/transaction/memory/jca/MapXAResource.java 22 Jul 2004 14:44:55 -0000 @@ -91,6 +91,7 @@ protected static class MapTransactionalResource extends AbstractTransactionalResource { TransactionalMapWrapper map; + private TransactionalMapWrapper.TxContext txContext = null; LoggerFacade loggerFacade; @@ -109,6 +110,10 @@ } public void rollback() throws XAException { + // resume if suspended, because the transactional map throws an + // exception if we call prepare on suspended txns + if (isSuspended()) resume(); + try { map.rollbackTransaction(); } catch (IllegalStateException e) { @@ -117,6 +122,10 @@ } public int prepare() throws XAException { + // resume if suspended, because the transactional map throws an + // exception if we call prepare on suspended txns + if (isSuspended()) resume(); + if (map.isTransactionMarkedForRollback()) { throw new XAException(XAException.XA_RBROLLBACK); } @@ -124,5 +133,28 @@ return (map.isReadOnly() ? XA_RDONLY : XA_OK); } + public void suspend() throws XAException { + if (isSuspended()) { + throw new XAException(XAException.XAER_PROTO); + } + this.txContext = map.suspendTransaction(); + } + public void resume() throws XAException { + if (!isSuspended()) { + throw new XAException(XAException.XAER_PROTO); + } + map.resumeTransaction(this.txContext); + this.txContext = null; + } + public void begin() throws XAException { + if (isSuspended()) { + throw new XAException(XAException.XAER_PROTO); + } + this.map.startTransaction(); + } + + private boolean isSuspended() { + return this.txContext != null; + } } } Index: src/java/org/apache/commons/transaction/util/xa/AbstractXAResource.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/util/xa/AbstractXAResource.java,v retrieving revision 1.5 diff -u -r1.5 AbstractXAResource.java --- src/java/org/apache/commons/transaction/util/xa/AbstractXAResource.java 14 Jul 2004 09:49:17 -0000 1.5 +++ src/java/org/apache/commons/transaction/util/xa/AbstractXAResource.java 22 Jul 2004 14:44:59 -0000 @@ -133,6 +133,7 @@ switch (flags) { case TMSUSPEND : + ts.suspend(); addSuspendedTransactionalResource(xid, ts); removeActiveTransactionalResource(xid); break; @@ -164,6 +165,7 @@ default : try { ts = createTransactionResource(xid); + ts.begin(); } catch (Exception e) { getLoggerFacade().logSevere("Could not create new transactional resource", e); throw new XAException(e.getMessage()); @@ -174,6 +176,7 @@ if (ts == null) { throw new XAException(XAException.XAER_NOTA); } + ts.resume(); removeSuspendedTransactionalResource(xid); break; } Index: src/java/org/apache/commons/transaction/util/xa/TransactionalResource.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/util/xa/TransactionalResource.java,v retrieving revision 1.3 diff -u -r1.3 TransactionalResource.java --- src/java/org/apache/commons/transaction/util/xa/TransactionalResource.java 12 Jul 2004 14:47:41 -0000 1.3 +++ src/java/org/apache/commons/transaction/util/xa/TransactionalResource.java 22 Jul 2004 14:45:00 -0000 @@ -62,6 +62,10 @@ * notation */ public void rollback() throws XAException; + + public void begin() throws XAException; + public void suspend() throws XAException; + public void resume() throws XAException; /** * Returns the current status of this transaction resource. --------------070705000808090402090400 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------070705000808090402090400--