jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r446971 - in /jackrabbit/trunk/jca: deploy/jboss/4.x/ src/main/java/org/apache/jackrabbit/jca/
Date Sat, 16 Sep 2006 23:23:13 GMT
Author: jukka
Date: Sat Sep 16 16:23:13 2006
New Revision: 446971

URL: http://svn.apache.org/viewvc?view=rev&rev=446971
Log:
JCR-463: Applied Edgar's proposed patch (with a license header and a few tab cleanups) for
the upcoming 1.1 release candidate

Added:
    jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/TransactionBoundXAResource.java
  (with props)
Modified:
    jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml
    jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
    jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java

Modified: jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml?view=diff&rev=446971&r1=446970&r2=446971
==============================================================================
--- jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml (original)
+++ jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml Sat Sep 16 16:23:13 2006
@@ -6,5 +6,6 @@
 		<connection-definition>javax.jcr.Repository</connection-definition>
 		<config-property name="homeDir" type="java.lang.String">/temp/jackrabbit</config-property>
 		<config-property name="configFile" type="java.lang.String">classpath:repository.xml</config-property>
+		<config-property name="bindSessionToTrasaction" type="java.lang.Boolean">true</config-property>
     </tx-connection-factory>
 </connection-factories>

Modified: jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java?view=diff&rev=446971&r1=446970&r2=446971
==============================================================================
--- jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
(original)
+++ jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
Sat Sep 16 16:23:13 2006
@@ -57,6 +57,11 @@
     private final XASession session;
 
     /**
+     * XAResource instance.
+     */
+    private final XAResource xaResource;
+
+    /**
      * Listeners.
      */
     private final LinkedList listeners;
@@ -80,6 +85,11 @@
         this.session = session;
         this.listeners = new LinkedList();
         this.handles = new LinkedList();
+        if (this.mcf.getBindSessionToTrasaction().booleanValue()) {
+            this.xaResource =  new TransactionBoundXAResource(this, session.getXAResource());
+        } else {
+            this.xaResource = session.getXAResource();
+        }
     }
 
     /**
@@ -173,7 +183,7 @@
      */
     public XAResource getXAResource()
             throws ResourceException {
-        return session.getXAResource();
+        return this.xaResource;
     }
 
     /**
@@ -385,7 +395,7 @@
     /**
      * Release handles.
      */
-    private void closeHandles() {
+    void closeHandles() {
         synchronized (handles) {
             JCASessionHandle[] handlesArray = new JCASessionHandle[handles
                     .size()];

Modified: jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java?view=diff&rev=446971&r1=446970&r2=446971
==============================================================================
--- jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
(original)
+++ jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
Sat Sep 16 16:23:13 2006
@@ -48,6 +48,14 @@
     private String configFile;
 
     /**
+     * Flag indicating whether the session should be bound to the
+     * transaction lyfecyle.
+     * In other words, if this flag is true the handle
+     * will be closed when the transaction ends.
+     */
+    private Boolean bindSessionToTrasaction = Boolean.TRUE;
+
+    /**
      * Repository.
      */
     private transient RepositoryImpl repository;
@@ -282,5 +290,13 @@
         JCARepositoryManager mgr = JCARepositoryManager.getInstance();
         mgr.autoShutdownRepository(homeDir, configFile);
 	}
+
+    public Boolean getBindSessionToTrasaction() {
+        return bindSessionToTrasaction;
+    }
+
+    public void setBindSessionToTrasaction(Boolean bindSessionToTrasaction) {
+        this.bindSessionToTrasaction = bindSessionToTrasaction;
+    }
 
 }

Added: jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/TransactionBoundXAResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/TransactionBoundXAResource.java?view=auto&rev=446971
==============================================================================
--- jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/TransactionBoundXAResource.java
(added)
+++ jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/TransactionBoundXAResource.java
Sat Sep 16 16:23:13 2006
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+public class TransactionBoundXAResource implements XAResource {
+
+    private XAResource xaResource;
+
+    private JCAManagedConnection connection;
+
+    private boolean ending;
+
+    public TransactionBoundXAResource(JCAManagedConnection connection,
+            XAResource xaResource) {
+        super();
+        this.xaResource = xaResource;
+        this.connection = connection;
+    }
+
+    public void commit(Xid arg0, boolean arg1) throws XAException {
+        xaResource.commit(arg0, arg1);
+    }
+
+    public void end(Xid arg0, int arg1) throws XAException {
+        if (!ending) {
+            this.ending = true;
+            try {
+                xaResource.end(arg0, arg1);
+            } finally {
+                this.connection.closeHandles();
+            }
+            // reuse the XAResource
+            this.ending = false ;
+        }
+    }
+
+    public void forget(Xid arg0) throws XAException {
+        xaResource.forget(arg0);
+    }
+
+    public int getTransactionTimeout() throws XAException {
+        return xaResource.getTransactionTimeout();
+    }
+
+    public boolean isSameRM(XAResource arg0) throws XAException {
+        return xaResource.isSameRM(arg0);
+    }
+
+    public int prepare(Xid arg0) throws XAException {
+        return xaResource.prepare(arg0);
+    }
+
+    public Xid[] recover(int arg0) throws XAException {
+        return xaResource.recover(arg0);
+    }
+
+    public void rollback(Xid arg0) throws XAException {
+        xaResource.rollback(arg0);
+    }
+
+    public boolean setTransactionTimeout(int arg0) throws XAException {
+        return xaResource.setTransactionTimeout(arg0);
+    }
+
+    public void start(Xid arg0, int arg1) throws XAException {
+        xaResource.start(arg0, arg1);
+    }
+
+}

Propchange: jackrabbit/trunk/jca/src/main/java/org/apache/jackrabbit/jca/TransactionBoundXAResource.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message