jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r933554 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/ jackrabbit-jca/src/test/java/org/apach...
Date Tue, 13 Apr 2010 11:15:37 GMT
Author: jukka
Date: Tue Apr 13 11:15:36 2010
New Revision: 933554

URL: http://svn.apache.org/viewvc?rev=933554&view=rev
Log:
JCR-2578: Deprecate XASession

Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/XASession.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
    jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
    jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
    jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCASessionHandle.java
    jackrabbit/trunk/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/XASession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/XASession.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/XASession.java
(original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/XASession.java
Tue Apr 13 11:15:36 2010
@@ -31,6 +31,8 @@ import javax.transaction.xa.XAResource;
  * use it directly.
  *
  * @since 1.4
+ * @deprecated An XA-enabled session should directly implement the
+ *             {@link javax.transaction.xa.XAResource} interface
  */
 public interface XASession extends Session {
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
Tue Apr 13 11:15:36 2010
@@ -59,7 +59,7 @@ public class UserTransactionImpl impleme
     /**
      * Create a new instance of this class. Takes a session as parameter.
      * @param session session. If session is not of type
-     * {@link XASession}, an <code>IllegalArgumentException</code>
+     * {@link XAResource}, an <code>IllegalArgumentException</code>
      * is thrown
      */
     public UserTransactionImpl(Session session) {
@@ -69,16 +69,16 @@ public class UserTransactionImpl impleme
     /**
      * Create a new instance of this class. Takes a session as parameter.
      * @param session session. If session is not of type
-     * {@link XASession}, an <code>IllegalArgumentException</code>
+     * {@link XAResource}, an <code>IllegalArgumentException</code>
      * is thrown
      */
     public UserTransactionImpl(Session session, boolean distributedThreadAccess) {
-        if (session instanceof XASession) {
+        if (session instanceof XAResource) {
             counter++;
-            xaResources.put(((XASession) session).getXAResource(), new XidImpl(counter));
+            xaResources.put((XAResource) session, new XidImpl(counter));
             this.distributedThreadAccess = distributedThreadAccess; 
         } else {
-            throw new IllegalArgumentException("Session not of type XASession");
+            throw new IllegalArgumentException("Session not of type XAResource");
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Tue Apr 13 11:15:36 2010
@@ -36,7 +36,7 @@ import java.util.StringTokenizer;
 
 /**
  * <code>XATest</code> contains the test cases for the methods
- * inside {@link org.apache.jackrabbit.api.XASession}.
+ * inside {@link XASessionImpl}.
  */
 public class XATest extends AbstractJCRTest {
 

Modified: jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
(original)
+++ jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
Tue Apr 13 11:15:36 2010
@@ -16,10 +16,9 @@
  */
 package org.apache.jackrabbit.jca;
 
-import org.apache.jackrabbit.api.XASession;
-
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionEvent;
 import javax.resource.spi.ConnectionEventListener;
@@ -53,7 +52,7 @@ public final class JCAManagedConnection
     /**
      * Session instance.
      */
-    private final XASession session;
+    private final Session session;
 
     /**
      * XAResource instance.
@@ -78,16 +77,18 @@ public final class JCAManagedConnection
     /**
      * Construct the managed connection.
      */
-    public JCAManagedConnection(JCAManagedConnectionFactory mcf, JCAConnectionRequestInfo
cri, XASession session) {
+    public JCAManagedConnection(
+            JCAManagedConnectionFactory mcf, JCAConnectionRequestInfo cri,
+            Session session) {
         this.mcf = mcf;
         this.cri = cri;
         this.session = session;
         this.listeners = new LinkedList<ConnectionEventListener>();
         this.handles = new LinkedList<JCASessionHandle>();
         if (this.mcf.getBindSessionToTransaction().booleanValue()) {
-            this.xaResource =  new TransactionBoundXAResource(this, session.getXAResource());
+            this.xaResource =  new TransactionBoundXAResource(this, (XAResource) session);
         } else {
-            this.xaResource = session.getXAResource();
+            this.xaResource = (XAResource) session;
         }
     }
 
@@ -218,7 +219,7 @@ public final class JCAManagedConnection
     /**
      * Return the session.
      */
-    public XASession getSession(JCASessionHandle handle) {
+    public Session getSession(JCASessionHandle handle) {
         synchronized (handles) {
             if ((handles.size() > 0) && (handles.get(0) == handle)) {
                 return session;

Modified: jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
Tue Apr 13 11:15:36 2010
@@ -143,7 +143,7 @@ public final class JCAManagedConnectionF
     /**
      * Create a new session.
      */
-    private XASession openSession(JCAConnectionRequestInfo cri)
+    private Session openSession(JCAConnectionRequestInfo cri)
             throws ResourceException {
         createRepository();
         Credentials creds = cri.getCredentials();
@@ -152,7 +152,7 @@ public final class JCAManagedConnectionF
         try {
             Session session = getRepository().login(creds, workspace);
             log("Created session (" + session + ")");
-            return (XASession) session;
+            return session;
         } catch (RepositoryException e) {
             log("Failed to create session", e);
             ResourceException exception = new ResourceException(

Modified: jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCASessionHandle.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCASessionHandle.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCASessionHandle.java
(original)
+++ jackrabbit/trunk/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCASessionHandle.java
Tue Apr 13 11:15:36 2010
@@ -45,16 +45,17 @@ import javax.jcr.nodetype.NoSuchNodeType
 import javax.jcr.retention.RetentionManager;
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.version.VersionException;
+import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
 
-import org.apache.jackrabbit.api.XASession;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
 /**
  * This class implements the JCA implementation of session.
  */
-public final class JCASessionHandle implements XASession {
+public final class JCASessionHandle implements Session, XAResource {
 
     /**
      * Managed connection.
@@ -85,7 +86,7 @@ public final class JCASessionHandle impl
     /**
      * Return the session.
      */
-    private XASession getSession() {
+    private Session getSession() {
         return mc.getSession(this);
     }
 
@@ -381,15 +382,59 @@ public final class JCASessionHandle impl
         getSession().removeItem(path);
     }
 
-    //---------------------------------------------------------< XASession >--
+    //--------------------------------------------------------< XAResource >--
 
-    /**
-     * Returns the XAResource associated with this session.
-     *
-     * @return XA resource
-     */
-    public XAResource getXAResource() {
-        return getSession().getXAResource();
+    private XAResource getXAResource() throws XAException {
+        Session session = getSession();
+        if (session instanceof XAResource) {
+            return (XAResource) session;
+        } else {
+            throw new XAException(
+                    "XA transactions are not supported with " + session);
+        }
+    }
+
+    public void start(Xid xid, int flags) throws XAException {
+        getXAResource().start(xid, flags);
+    }
+
+    public void end(Xid xid, int flags) throws XAException {
+        getXAResource().end(xid, flags);
+    }
+
+    public int prepare(Xid xid) throws XAException {
+        return getXAResource().prepare(xid);
+    }
+
+    public void rollback(Xid xid) throws XAException {
+        getXAResource().rollback(xid);
+    }
+
+    public void commit(Xid xid, boolean onePhase) throws XAException {
+        getXAResource().commit(xid, onePhase);
+    }
+
+    public void forget(Xid xid) throws XAException {
+        getXAResource().forget(xid);
+    }
+
+    public Xid[] recover(int flag) throws XAException {
+        return getXAResource().recover(flag);
+    }
+
+    public boolean isSameRM(XAResource xares) throws XAException {
+        if (xares instanceof JCASessionHandle) {
+            xares = ((JCASessionHandle) xares).getXAResource();
+        }
+        return getXAResource().isSameRM(xares);
+    }
+
+    public int getTransactionTimeout() throws XAException {
+        return getXAResource().getTransactionTimeout();
+    }
+
+    public boolean setTransactionTimeout(int seconds) throws XAException {
+        return getXAResource().setTransactionTimeout(seconds);
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java?rev=933554&r1=933553&r2=933554&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java
Tue Apr 13 11:15:36 2010
@@ -24,8 +24,8 @@ import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.naming.Referenceable;
 import javax.resource.spi.ManagedConnection;
+import javax.transaction.xa.XAResource;
 
-import org.apache.jackrabbit.api.XASession;
 import org.apache.jackrabbit.jca.JCAConnectionRequestInfo;
 import org.apache.jackrabbit.jca.JCARepositoryHandle;
 import org.apache.jackrabbit.jca.JCASessionHandle;
@@ -117,7 +117,7 @@ public final class ConnectionFactoryTest
 
         // Open a session
         Session session = repository.login(JCR_SUPERUSER);
-        assertTrue(session instanceof XASession);
+        assertTrue(session instanceof XAResource);
         session.logout();
     }
     



Mime
View raw message