From dev-return-17354-apmail-jackrabbit-dev-archive=jackrabbit.apache.org@jackrabbit.apache.org Mon Mar 03 10:39:57 2008 Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 39792 invoked from network); 3 Mar 2008 10:39:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Mar 2008 10:39:57 -0000 Received: (qmail 91222 invoked by uid 500); 3 Mar 2008 10:39:52 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 91011 invoked by uid 500); 3 Mar 2008 10:39:52 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 91002 invoked by uid 99); 3 Mar 2008 10:39:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Mar 2008 02:39:52 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Mar 2008 10:39:25 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 9BA33234C083 for ; Mon, 3 Mar 2008 02:38:50 -0800 (PST) Message-ID: <21409942.1204540730636.JavaMail.jira@brutus> Date: Mon, 3 Mar 2008 02:38:50 -0800 (PST) From: "Stephane Landelle (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Created: (JCR-1446) Local transactions support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Local transactions support -------------------------- Key: JCR-1446 URL: https://issues.apache.org/jira/browse/JCR-1446 Project: Jackrabbit Issue Type: Improvement Components: jackrabbit-jca Affects Versions: 1.5 Reporter: Stephane Landelle JCAManagedConnectionFactory doesn't currently support LocalTransaction. Wouldn't it be simple to provide a simple implemetation like the following (inspired of JR test suite): package com.weka.jackrabbit.jca; import javax.jcr.Session; import javax.resource.ResourceException; import javax.resource.spi.LocalTransaction; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import org.apache.jackrabbit.api.XASession; /** * JackRabbit Local transaction (based on the XA Resource returned by * JackRabbit).

Inspired from JackRabbit test suite. * * Internal {@link javax.transaction.LocalTransaction} implementation. * */ public class JackRabbitLocalTransaction implements LocalTransaction { /** * Global transaction id counter. TODO: remove the static attribute */ private static byte counter = 0; /** * XASession */ private XASession session; /** * XAResource */ private final XAResource xares; /** * Xid */ private Xid xid; /** * Create a new instance of this class. Takes a session as parameter. * * @param session * session. If session is not of type {@link XASession}, an * IllegalArgumentException is thrown */ public JackRabbitLocalTransaction(Session session) { if (session instanceof XASession) { this.session = (XASession) session; xares = this.session.getXAResource(); } else { throw new IllegalArgumentException("Session not of type XASession"); } } /** * @see javax.transaction.LocalTransaction#begin */ public void begin() throws ResourceException { try { xid = new XidImpl(counter++); xares.start(xid, XAResource.TMNOFLAGS); } catch (XAException e) { throw new ResourceException("Unable to begin transaction: " + "XA_ERR=" + e.errorCode); } } /** * @see javax.transaction.LocalTransaction#commit */ public void commit() throws ResourceException { try { xares.end(xid, XAResource.TMSUCCESS); xares.prepare(xid); xares.commit(xid, false); session.logout(); } catch (XAException e) { if (e.errorCode >= XAException.XA_RBBASE && e.errorCode <= XAException.XA_RBEND) { throw new ResourceException(e.toString()); } throw new ResourceException("Unable to commit transaction: " + "XA_ERR=" + e.errorCode); } } /** * @see javax.transaction.LocalTransaction#rollback */ public void rollback() throws ResourceException { try { xares.end(xid, XAResource.TMFAIL); xares.rollback(xid); session.logout(); } catch (XAException e) { throw new ResourceException("Unable to rollback transaction: " + "XA_ERR=" + e.errorCode); } } /** * Internal {@link Xid} implementation. */ class XidImpl implements Xid { /** Global transaction id */ private final byte[] globalTxId; /** * Create a new instance of this class. Takes a global transaction * number as parameter * * @param globalTxNumber * global transaction number */ public XidImpl(byte globalTxNumber) { this.globalTxId = new byte[] { globalTxNumber }; } /** * @see javax.transaction.xa.Xid#getFormatId() */ public int getFormatId() { return 0; } /** * @see javax.transaction.xa.Xid#getBranchQualifier() */ public byte[] getBranchQualifier() { return new byte[0]; } /** * @see javax.transaction.xa.Xid#getGlobalTransactionId() */ public byte[] getGlobalTransactionId() { return globalTxId; } } /** * @return Returns the counter. */ public byte getCounter() { return counter; } /** * @param counter * The counter to set. */ public void setCounter(byte counter) { JackRabbitLocalTransaction.counter = counter; } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.