[jboss-remoting-commits] JBoss Remoting SVN: r4816 - in remoting-txn/trunk/src/main/java/org/jboss/remoting/txn: impl and 1 other directories.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Thu Jan 15 13:07:06 EST 2009


Author: david.lloyd at jboss.com
Date: 2009-01-15 13:07:06 -0500 (Thu, 15 Jan 2009)
New Revision: 4816

Added:
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/ForwardingTxnRequestVisitor.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/UnwrappingRequestHandler.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnRequest.java
Removed:
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequest.java
Modified:
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientSourceImpl.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/WrappingRequestHandler.java
Log:
The receiving end of transactional requests

Deleted: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnReply.java	2009-01-15 03:50:40 UTC (rev 4815)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnReply.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -1,290 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.txn;
-
-import javax.transaction.xa.Xid;
-
-/**
- * A reply to a request for a transaction operation on a transactional client.
- */
-public interface TxnReply {
-
-   /**
-    * Accept a visitor.
-    *
-    * @param visitor the visitor
-    * @param param a parameter to pass to the visitor method
-    * @param <I> the type of the visitor parameter
-    * @param <O> the return type of the visitor
-    * @return the value returned by the visitor
-    */
-    <I, O> O accept(Visitor<I, O> visitor, I param);
-
-    /**
-     * A visitor for {@code TxnReply} types.
-     *
-     * @param <I> the type of the visitor parameter
-     * @param <O> the return type of the visitor
-     */
-    interface Visitor<I, O> {
-
-        /**
-         * Handle a {@code ResourceManagerId} instance.
-         *
-         * @param reply the reply
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(ResourceManagerId reply, I param);
-
-        /**
-         * Handle a {@code Timeout} instance.
-         *
-         * @param reply the reply
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(Timeout reply, I param);
-
-        /**
-         * Handle a {@code Prepared} instance.
-         *
-         * @param reply the reply
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(Prepared reply, I param);
-
-        /**
-         * Handle a {@code Recover} instance.
-         *
-         * @param reply the reply
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(Recover reply, I param);
-
-        /**
-         * Handle a {@code TimeoutSet} instance.
-         *
-         * @param reply the reply
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(TimeoutSet reply, I param);
-
-        /**
-         * Handle a {@code Success} instance.
-         *
-         * @param reply the reply
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(Success reply, I param);
-    }
-
-    /**
-     * A reply to a request to get the resource manager ID.
-     *
-     * @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)
-     */
-    final class ResourceManagerId implements TxnReply {
-        private final Object id;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param id the resource manager ID
-         */
-        public ResourceManagerId(final Object id) {
-            this.id = id;
-        }
-
-        /**
-         * Get the resource manager ID.
-         *
-         * @return the resource manager ID
-         */
-        public Object getId() {
-            return id;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A reply to a request to get the currently configured transaction timeout.
-     *
-     * @see javax.transaction.xa.XAResource#getTransactionTimeout()
-     */
-    final class Timeout implements TxnReply {
-
-        private final int timeout;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param timeout the timeout
-         */
-        public Timeout(final int timeout) {
-            this.timeout = timeout;
-        }
-
-        /**
-         * Get the timeout.
-         *
-         * @return the timeout
-         */
-        public int getTimeout() {
-            return timeout;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A reply to a request to prepare a distributed transaction.
-     *
-     * @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid)
-     */
-    final class Prepared implements TxnReply {
-        private final int vote;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param vote the vote
-         */
-        public Prepared(final int vote) {
-            this.vote = vote;
-        }
-
-        /**
-         * Get the vote.
-         *
-         * @return the vote
-         */
-        public int getVote() {
-            return vote;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A reply to a request to get transaction IDs to recover.
-     *
-     * @see javax.transaction.xa.XAResource#recover(int)
-     */
-    final class Recover implements TxnReply {
-
-        private final Xid[] resources;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param resources the resources to recover
-         */
-        public Recover(final Xid[] resources) {
-            this.resources = resources;
-        }
-
-        /**
-         * Get the resources to recover.
-         *
-         * @return the resources to recover
-         */
-        public Xid[] getResources() {
-            return resources;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A reply to a request to set the transaction timeout.
-     *
-     * @see javax.transaction.xa.XAResource#setTransactionTimeout(int)
-     */
-    final class TimeoutSet implements TxnReply {
-
-        private final boolean success;
-        /**
-         * The timeout was set successfully.
-         */
-        public static final TimeoutSet SUCCESS = new TimeoutSet(true);
-        /**
-         * The timeout could not be set.
-         */
-        public static final TimeoutSet FAILED = new TimeoutSet(false);
-
-        private TimeoutSet(final boolean success) {
-            this.success = success;
-        }
-
-        /**
-         * Get whether the timeout was set successfully.
-         *
-         * @return {@code true} if the timeout was set successfully.
-         */
-        public boolean getSuccess() {
-            return success;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A general successful reply.
-     */
-    final class Success implements TxnReply {
-
-        /**
-         * Get the single instance.
-         */
-        public static final Success INSTANCE = new Success();
-
-        private Success() {
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-}

Deleted: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequest.java	2009-01-15 03:50:40 UTC (rev 4815)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequest.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -1,611 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.txn;
-
-import javax.transaction.xa.Xid;
-
-/**
- * A request for a transaction operation on a transactional client.
- */
-public interface TxnRequest {
-
-    /**
-     * Accept a visitor.
-     *
-     * @param visitor the visitor
-     * @param param a parameter to pass to the visitor method
-     * @param <I> the type of the visitor parameter
-     * @param <O> the return type of the visitor
-     * @return the value returned by the visitor
-     */
-    <I, O> O accept(Visitor<I, O> visitor, I param);
-
-    /**
-     * A visitor for {@code TxnRequest} types.
-     *
-     * @param <I> the type of the visitor parameter
-     * @param <O> the return type of the visitor
-     */
-    interface Visitor<I, O> {
-
-        /**
-         * Handle a {@code CommitXA} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(CommitXA request, I param);
-
-        /**
-         * Handle a {@code EndXA} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(EndXA request, I param);
-
-        /**
-         * Handle a {@code ForgetXA} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(ForgetXA request, I param);
-
-        /**
-         * Handle a {@code GetTimeout} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(GetTimeout request, I param);
-
-        /**
-         * Handle a {@code PrepareXA} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(PrepareXA request, I param);
-
-        /**
-         * Handle a {@code Recover} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(Recover request, I param);
-
-        /**
-         * Handle a {@code RollbackXA} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(RollbackXA request, I param);
-
-        /**
-         * Handle a {@code SetTimeout} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(SetTimeout request, I param);
-
-        /**
-         * Handle a {@code StartXA} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(StartXA request, I param);
-
-        /**
-         * Handle a {@code Wrapped} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(Wrapped request, I param);
-
-        /**
-         * Handle a {@code GetResourceManagerId} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(GetResourceManagerId request, I param);
-
-        /**
-         * Handle a {@code StartLocal} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(StartLocal request, I param);
-
-        /**
-         * Handle a {@code CommitLocal} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(CommitLocal request, I param);
-
-        /**
-         * Handle a {@code RollbackLocal} instance.
-         *
-         * @param request the request
-         * @param param the visitor parameter
-         * @return the visitor return value
-         */
-        O visit(RollbackLocal request, I param);
-    }
-
-    /**
-     * A request to commit a local transaction.
-     *
-     * @see TransactionalClient#commit()
-     */
-    final class CommitLocal implements TxnRequest {
-
-        /**
-         * The single instance.
-         */
-        public static final CommitLocal INSTANCE = new CommitLocal();
-    
-        private CommitLocal() {
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to end the work performed on behalf of a distributed transaction.
-     *
-     * @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid, int)
-     */
-    final class EndXA implements TxnRequest {
-
-        private final Xid xid;
-        private final int flags;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param xid the transaction ID
-         * @param flags the transaction flags
-         */
-        public EndXA(final Xid xid, final int flags) {
-            this.xid = xid;
-            this.flags = flags;
-        }
-
-        /**
-         * Get the XID.
-         *
-         * @return the XID
-         */
-        public Xid getXid() {
-            return xid;
-        }
-
-        /**
-         * Get the flags.
-         *
-         * @return the flags
-         */
-        public int getFlags() {
-            return flags;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to forget about a heurstically completed transaction branch.
-     *
-     * @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid)
-     */
-    final class ForgetXA implements TxnRequest {
-
-        private final Xid xid;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param xid the transaction ID
-         */
-        public ForgetXA(final Xid xid) {
-            this.xid = xid;
-        }
-
-        /**
-         * Get the XID.
-         *
-         * @return the XID
-         */
-        public Xid getXid() {
-            return xid;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to get the resource manager ID for this resource.
-     *
-     * @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)
-     */
-    final class GetResourceManagerId implements TxnRequest {
-
-        /**
-         * The single instance.
-         */
-        public static final GetResourceManagerId INSTANCE = new GetResourceManagerId();
-
-        private GetResourceManagerId() {
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to get the transaction timeout value.
-     *
-     * @see javax.transaction.xa.XAResource#getTransactionTimeout()
-     */
-    final class GetTimeout implements TxnRequest {
-
-        /**
-         * The single instance.
-         */
-        public static final GetTimeout INSTANCE = new GetTimeout();
-
-        private GetTimeout() {
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to set the transaction timeout value.
-     *
-     * @see javax.transaction.xa.XAResource#setTransactionTimeout(int)
-     */
-    final class SetTimeout implements TxnRequest {
-
-        private final int timeout;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param timeout the requested timeout value
-         */
-        public SetTimeout(final int timeout) {
-            this.timeout = timeout;
-        }
-
-        /**
-         * Get the requested timeout value.
-         *
-         * @return the requested timeout value
-         */
-        public int getTimeout() {
-            return timeout;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to prepare a for distributed transaction commit of the given transaction.
-     *
-     * @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid)
-     */
-    final class PrepareXA implements TxnRequest {
-
-        private final Xid xid;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param xid the transaction ID
-         */
-        public PrepareXA(final Xid xid) {
-            this.xid = xid;
-        }
-
-        /**
-         * Get the transaction ID.
-         *
-         * @return the transaction ID
-         */
-        public Xid getXid() {
-            return xid;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to obtain a list of prepared transaction branches from the underlying resource manager.
-     *
-     * @see javax.transaction.xa.XAResource#recover(int)
-     */
-    final class Recover implements TxnRequest {
-
-        private final int flag;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param flag the flag(s)
-         */
-        public Recover(final int flag) {
-            this.flag = flag;
-        }
-
-        /**
-         * Get the flag value.
-         *
-         * @return the flag value
-         */
-        public int getFlag() {
-            return flag;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to roll back a local transaction.
-     *
-     * @see TransactionalClient#rollback()
-     */
-    final class RollbackLocal implements TxnRequest {
-
-        /**
-         * The single instance.
-         */
-        public static RollbackLocal INSTANCE = new RollbackLocal();
-
-        private RollbackLocal() {
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to start a local transaction.
-     *
-     * @see TransactionalClient#start()
-     */
-    final class StartLocal implements TxnRequest {
-
-        /**
-         * The single instance.
-         */
-        public static StartLocal INSTANCE = new StartLocal();
-
-        private StartLocal() {
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A wrapped application request.
-     */
-    final class Wrapped implements TxnRequest {
-
-        private final Object wrappedRequest;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param request the application request
-         */
-        public Wrapped(final Object request) {
-            wrappedRequest = request;
-        }
-
-        /**
-         * Get the wrapped request.
-         *
-         * @return the wrapped request
-         */
-        public Object getWrappedRequest() {
-            return wrappedRequest;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to commit a distributed transaction.
-     *
-     * @see javax.transaction.xa.XAResource#commit(javax.transaction.xa.Xid, boolean)
-     */
-    final class CommitXA implements TxnRequest {
-        private final Xid xid;
-        private final boolean onePhase;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param xid the transaction ID
-         * @param onePhase {@code true} if the commit should be done in a single phase
-         */
-        public CommitXA(final Xid xid, final boolean onePhase) {
-            this.xid = xid;
-            this.onePhase = onePhase;
-        }
-
-        /**
-         * Get the transaction ID.
-         *
-         * @return the transaction ID
-         */
-        public Xid getXid() {
-            return xid;
-        }
-
-        /**
-         * Determine whether a one-phase commit was requested.
-         *
-         * @return {@code true} if a one-phase commit was requested
-         */
-        public boolean isOnePhase() {
-            return onePhase;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to roll back a distributed transaction.
-     *
-     * @see javax.transaction.xa.XAResource#rollback(javax.transaction.xa.Xid)
-     */
-    final class RollbackXA implements TxnRequest {
-
-        private final Xid xid;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param xid the transaction ID
-         */
-        public RollbackXA(final Xid xid) {
-            this.xid = xid;
-        }
-
-        /**
-         * Get the transaction ID.
-         *
-         * @return the transaction ID
-         */
-        public Xid getXid() {
-            return xid;
-        }
-
-        /** {@inheritDoc} */
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-
-    /**
-     * A request to start a distributed transaction.
-     *
-     * @see javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid, int)
-     */
-    final class StartXA implements TxnRequest {
-
-        private final Xid xid;
-        private final int flags;
-
-        /**
-         * Construct a new instance.
-         *
-         * @param xid the transaction ID
-         * @param flags the flags
-         */
-        public StartXA(final Xid xid, final int flags) {
-            this.xid = xid;
-            this.flags = flags;
-        }
-
-        /**
-         * Get the transaction ID.
-         *
-         * @return the transaction ID
-         */
-        public Xid getXid() {
-            return xid;
-        }
-
-        /**
-         * Get the flags.
-         *
-         * @return the flags
-         */
-        public int getFlags() {
-            return flags;
-        }
-
-        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
-            return visitor.visit(this, param);
-        }
-    }
-}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/ForwardingTxnRequestVisitor.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/ForwardingTxnRequestVisitor.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/ForwardingTxnRequestVisitor.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.txn.impl;
+
+import org.jboss.remoting.txn.spi.TxnRequest;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.RequestHandler;
+
+/**
+ * An abstract base class which forwards wrapped requests on to another request handler, but handles transaction
+ * control messages locally.
+ */
+public abstract class ForwardingTxnRequestVisitor implements TxnRequest.Visitor<ReplyHandler, RemoteRequestContext> {
+    private final RequestHandler requestHandler;
+
+    /**
+     * Construct a new instance.
+     *
+     * @param handler the handler which handles wrapped requests
+     */
+    protected ForwardingTxnRequestVisitor(final RequestHandler handler) {
+        requestHandler = handler;
+    }
+
+    /** {@inheritDoc} */
+    public RemoteRequestContext visit(final TxnRequest.Wrapped request, final ReplyHandler replyHandler) {
+        return requestHandler.receiveRequest(request.getWrappedRequest(), replyHandler);
+    }
+}

Modified: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java	2009-01-15 03:50:40 UTC (rev 4815)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -35,12 +35,12 @@
 import org.jboss.remoting.Client;
 import org.jboss.remoting.CloseHandler;
 import org.jboss.remoting.RemoteExecutionException;
-import org.jboss.remoting.txn.TxnRequest;
-import org.jboss.remoting.txn.TxnReply;
+import org.jboss.remoting.txn.spi.TxnRequest;
+import org.jboss.remoting.txn.spi.TxnReply;
 import org.jboss.remoting.txn.TransactionalClient;
 
 /**
- *
+ * A transactional client implementation.
  */
 public final class TransactionalClientImpl<I, O> implements TransactionalClient<I, O> {
 
@@ -75,34 +75,42 @@
         }
     }
 
+    /** {@inheritDoc} */
     public void start() throws IOException {
         txnClient.invoke(TxnRequest.StartLocal.INSTANCE);
     }
 
+    /** {@inheritDoc} */
     public void commit() throws IOException {
         txnClient.invoke(TxnRequest.CommitLocal.INSTANCE);
     }
 
+    /** {@inheritDoc} */
     public void rollback() throws IOException {
         txnClient.invoke(TxnRequest.RollbackLocal.INSTANCE);
     }
 
+    /** {@inheritDoc} */
     public XAResource getXAResource() {
         return remotingXAResource;
     }
 
+    /** {@inheritDoc} */
     public O invoke(final I request) throws IOException, CancellationException {
         return realClient.invoke(request);
     }
 
+    /** {@inheritDoc} */
     public IoFuture<? extends O> send(final I request) throws IOException {
         return realClient.send(request);
     }
 
+    /** {@inheritDoc} */
     public ConcurrentMap<Object, Object> getAttributes() {
         return realClient.getAttributes();
     }
 
+    /** {@inheritDoc} */
     public void close() throws IOException {
         try {
             realClient.close();
@@ -112,6 +120,7 @@
         }
     }
 
+    /** {@inheritDoc} */
     public Key addCloseHandler(final CloseHandler<? super Client<I, O>> handler) {
         return realClient.addCloseHandler(new CloseHandler<Client<I, O>>() {
             public void handleClose(final Client<I, O> closed) {
@@ -120,10 +129,7 @@
         });
     }
 
-    /**
-     *
-     */
-    public static final class RemotingXAResource implements XAResource {
+    private static final class RemotingXAResource implements XAResource {
         private final Client<TxnRequest, TxnReply> txnClient;
         private final IoFuture<? extends TxnReply.ResourceManagerId> futureIdReply;
 

Modified: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientSourceImpl.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientSourceImpl.java	2009-01-15 03:50:40 UTC (rev 4815)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientSourceImpl.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -28,8 +28,8 @@
 import org.jboss.remoting.Endpoint;
 import org.jboss.remoting.Client;
 import org.jboss.remoting.CloseHandler;
-import org.jboss.remoting.txn.TxnRequest;
-import org.jboss.remoting.txn.TxnReply;
+import org.jboss.remoting.txn.spi.TxnRequest;
+import org.jboss.remoting.txn.spi.TxnReply;
 import org.jboss.remoting.txn.TransactionalClientSource;
 import org.jboss.remoting.txn.TransactionalClient;
 import org.jboss.remoting.spi.RequestHandlerSource;

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/UnwrappingRequestHandler.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/UnwrappingRequestHandler.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/UnwrappingRequestHandler.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.txn.impl;
+
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.AbstractAutoCloseable;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.SpiUtils;
+import org.jboss.remoting.txn.spi.TxnRequest;
+import org.jboss.remoting.RemoteRequestException;
+import org.jboss.xnio.log.Logger;
+import java.util.concurrent.Executor;
+import java.io.IOException;
+
+/**
+ * A request handler which invokes a {@code TxnRequest} visitor to demultiplex a transaction control message.
+ *
+ * @see org.jboss.remoting.txn.impl.ForwardingTxnRequestVisitor
+ */
+public final class UnwrappingRequestHandler extends AbstractAutoCloseable<RequestHandler> implements RequestHandler{
+
+    private static final Logger log = Logger.getLogger("org.jboss.remoting.txn");
+
+    private final TxnRequest.Visitor<ReplyHandler, RemoteRequestContext> visitor;
+
+    /**
+     * Construct a new instance.
+     *
+     * @param executor the executor used to execute the close notification handlers
+     * @param visitor the visitor which will handle the decoded transaction control message
+     */
+    protected UnwrappingRequestHandler(final Executor executor, final TxnRequest.Visitor<ReplyHandler, RemoteRequestContext> visitor) {
+        super(executor);
+        this.visitor = visitor;
+    }
+
+    /** {@inheritDoc} */
+    public RemoteRequestContext receiveRequest(final Object request, final ReplyHandler replyHandler) {
+        if (request instanceof TxnRequest) {
+            final TxnRequest txnRequest = (TxnRequest) request;
+            return txnRequest.accept(visitor, replyHandler);
+        } else {
+            try {
+                replyHandler.handleException(new RemoteRequestException("Incorrect request type"));
+            } catch (IOException e) {
+                log.warn(e, "Failed to send RemoteRequestException");
+            }
+            return SpiUtils.getBlankRemoteRequestContext();
+        }
+    }
+}

Modified: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/WrappingRequestHandler.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/WrappingRequestHandler.java	2009-01-15 03:50:40 UTC (rev 4815)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/WrappingRequestHandler.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -28,7 +28,7 @@
 import org.jboss.remoting.spi.AbstractAutoCloseable;
 import org.jboss.remoting.spi.Handle;
 import org.jboss.remoting.CloseHandler;
-import org.jboss.remoting.txn.TxnRequest;
+import org.jboss.remoting.txn.spi.TxnRequest;
 import org.jboss.xnio.IoUtils;
 import java.util.concurrent.Executor;
 import java.io.IOException;

Copied: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnReply.java (from rev 4813, remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnReply.java)
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnReply.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.txn.spi;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * A reply to a request for a transaction operation on a transactional client.
+ */
+public interface TxnReply {
+
+   /**
+    * Accept a visitor.
+    *
+    * @param visitor the visitor
+    * @param param a parameter to pass to the visitor method
+    * @param <I> the type of the visitor parameter
+    * @param <O> the return type of the visitor
+    * @return the value returned by the visitor
+    */
+    <I, O> O accept(Visitor<I, O> visitor, I param);
+
+    /**
+     * A visitor for {@code TxnReply} types.
+     *
+     * @param <I> the type of the visitor parameter
+     * @param <O> the return type of the visitor
+     */
+    interface Visitor<I, O> {
+
+        /**
+         * Handle a {@code ResourceManagerId} instance.
+         *
+         * @param reply the reply
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(ResourceManagerId reply, I param);
+
+        /**
+         * Handle a {@code Timeout} instance.
+         *
+         * @param reply the reply
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(Timeout reply, I param);
+
+        /**
+         * Handle a {@code Prepared} instance.
+         *
+         * @param reply the reply
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(Prepared reply, I param);
+
+        /**
+         * Handle a {@code Recover} instance.
+         *
+         * @param reply the reply
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(Recover reply, I param);
+
+        /**
+         * Handle a {@code TimeoutSet} instance.
+         *
+         * @param reply the reply
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(TimeoutSet reply, I param);
+
+        /**
+         * Handle a {@code Success} instance.
+         *
+         * @param reply the reply
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(Success reply, I param);
+    }
+
+    /**
+     * A reply to a request to get the resource manager ID.
+     *
+     * @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)
+     */
+    final class ResourceManagerId implements TxnReply {
+        private final Object id;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param id the resource manager ID
+         */
+        public ResourceManagerId(final Object id) {
+            this.id = id;
+        }
+
+        /**
+         * Get the resource manager ID.
+         *
+         * @return the resource manager ID
+         */
+        public Object getId() {
+            return id;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A reply to a request to get the currently configured transaction timeout.
+     *
+     * @see javax.transaction.xa.XAResource#getTransactionTimeout()
+     */
+    final class Timeout implements TxnReply {
+
+        private final int timeout;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param timeout the timeout
+         */
+        public Timeout(final int timeout) {
+            this.timeout = timeout;
+        }
+
+        /**
+         * Get the timeout.
+         *
+         * @return the timeout
+         */
+        public int getTimeout() {
+            return timeout;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A reply to a request to prepare a distributed transaction.
+     *
+     * @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid)
+     */
+    final class Prepared implements TxnReply {
+        private final int vote;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param vote the vote
+         */
+        public Prepared(final int vote) {
+            this.vote = vote;
+        }
+
+        /**
+         * Get the vote.
+         *
+         * @return the vote
+         */
+        public int getVote() {
+            return vote;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A reply to a request to get transaction IDs to recover.
+     *
+     * @see javax.transaction.xa.XAResource#recover(int)
+     */
+    final class Recover implements TxnReply {
+
+        private final Xid[] resources;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param resources the resources to recover
+         */
+        public Recover(final Xid[] resources) {
+            this.resources = resources;
+        }
+
+        /**
+         * Get the resources to recover.
+         *
+         * @return the resources to recover
+         */
+        public Xid[] getResources() {
+            return resources;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A reply to a request to set the transaction timeout.
+     *
+     * @see javax.transaction.xa.XAResource#setTransactionTimeout(int)
+     */
+    final class TimeoutSet implements TxnReply {
+
+        private final boolean success;
+        /**
+         * The timeout was set successfully.
+         */
+        public static final TimeoutSet SUCCESS = new TimeoutSet(true);
+        /**
+         * The timeout could not be set.
+         */
+        public static final TimeoutSet FAILED = new TimeoutSet(false);
+
+        private TimeoutSet(final boolean success) {
+            this.success = success;
+        }
+
+        /**
+         * Get whether the timeout was set successfully.
+         *
+         * @return {@code true} if the timeout was set successfully.
+         */
+        public boolean getSuccess() {
+            return success;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A general successful reply.
+     */
+    final class Success implements TxnReply {
+
+        /**
+         * Get the single instance.
+         */
+        public static final Success INSTANCE = new Success();
+
+        private Success() {
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+}

Copied: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnRequest.java (from rev 4813, remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequest.java)
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/spi/TxnRequest.java	2009-01-15 18:07:06 UTC (rev 4816)
@@ -0,0 +1,611 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.txn.spi;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * A request for a transaction operation on a transactional client.
+ */
+public interface TxnRequest {
+
+    /**
+     * Accept a visitor.
+     *
+     * @param visitor the visitor
+     * @param param a parameter to pass to the visitor method
+     * @param <I> the type of the visitor parameter
+     * @param <O> the return type of the visitor
+     * @return the value returned by the visitor
+     */
+    <I, O> O accept(Visitor<I, O> visitor, I param);
+
+    /**
+     * A visitor for {@code TxnRequest} types.
+     *
+     * @param <I> the type of the visitor parameter
+     * @param <O> the return type of the visitor
+     */
+    interface Visitor<I, O> {
+
+        /**
+         * Handle a {@code CommitXA} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(CommitXA request, I param);
+
+        /**
+         * Handle a {@code EndXA} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(EndXA request, I param);
+
+        /**
+         * Handle a {@code ForgetXA} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(ForgetXA request, I param);
+
+        /**
+         * Handle a {@code GetTimeout} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(GetTimeout request, I param);
+
+        /**
+         * Handle a {@code PrepareXA} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(PrepareXA request, I param);
+
+        /**
+         * Handle a {@code Recover} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(Recover request, I param);
+
+        /**
+         * Handle a {@code RollbackXA} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(RollbackXA request, I param);
+
+        /**
+         * Handle a {@code SetTimeout} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(SetTimeout request, I param);
+
+        /**
+         * Handle a {@code StartXA} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(StartXA request, I param);
+
+        /**
+         * Handle a {@code Wrapped} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(Wrapped request, I param);
+
+        /**
+         * Handle a {@code GetResourceManagerId} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(GetResourceManagerId request, I param);
+
+        /**
+         * Handle a {@code StartLocal} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(StartLocal request, I param);
+
+        /**
+         * Handle a {@code CommitLocal} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(CommitLocal request, I param);
+
+        /**
+         * Handle a {@code RollbackLocal} instance.
+         *
+         * @param request the request
+         * @param param the visitor parameter
+         * @return the visitor return value
+         */
+        O visit(RollbackLocal request, I param);
+    }
+
+    /**
+     * A request to commit a local transaction.
+     *
+     * @see org.jboss.remoting.txn.TransactionalClient#commit()
+     */
+    final class CommitLocal implements TxnRequest {
+
+        /**
+         * The single instance.
+         */
+        public static final CommitLocal INSTANCE = new CommitLocal();
+    
+        private CommitLocal() {
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to end the work performed on behalf of a distributed transaction.
+     *
+     * @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid, int)
+     */
+    final class EndXA implements TxnRequest {
+
+        private final Xid xid;
+        private final int flags;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param xid the transaction ID
+         * @param flags the transaction flags
+         */
+        public EndXA(final Xid xid, final int flags) {
+            this.xid = xid;
+            this.flags = flags;
+        }
+
+        /**
+         * Get the XID.
+         *
+         * @return the XID
+         */
+        public Xid getXid() {
+            return xid;
+        }
+
+        /**
+         * Get the flags.
+         *
+         * @return the flags
+         */
+        public int getFlags() {
+            return flags;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to forget about a heurstically completed transaction branch.
+     *
+     * @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid)
+     */
+    final class ForgetXA implements TxnRequest {
+
+        private final Xid xid;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param xid the transaction ID
+         */
+        public ForgetXA(final Xid xid) {
+            this.xid = xid;
+        }
+
+        /**
+         * Get the XID.
+         *
+         * @return the XID
+         */
+        public Xid getXid() {
+            return xid;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to get the resource manager ID for this resource.
+     *
+     * @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)
+     */
+    final class GetResourceManagerId implements TxnRequest {
+
+        /**
+         * The single instance.
+         */
+        public static final GetResourceManagerId INSTANCE = new GetResourceManagerId();
+
+        private GetResourceManagerId() {
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to get the transaction timeout value.
+     *
+     * @see javax.transaction.xa.XAResource#getTransactionTimeout()
+     */
+    final class GetTimeout implements TxnRequest {
+
+        /**
+         * The single instance.
+         */
+        public static final GetTimeout INSTANCE = new GetTimeout();
+
+        private GetTimeout() {
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to set the transaction timeout value.
+     *
+     * @see javax.transaction.xa.XAResource#setTransactionTimeout(int)
+     */
+    final class SetTimeout implements TxnRequest {
+
+        private final int timeout;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param timeout the requested timeout value
+         */
+        public SetTimeout(final int timeout) {
+            this.timeout = timeout;
+        }
+
+        /**
+         * Get the requested timeout value.
+         *
+         * @return the requested timeout value
+         */
+        public int getTimeout() {
+            return timeout;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to prepare a for distributed transaction commit of the given transaction.
+     *
+     * @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid)
+     */
+    final class PrepareXA implements TxnRequest {
+
+        private final Xid xid;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param xid the transaction ID
+         */
+        public PrepareXA(final Xid xid) {
+            this.xid = xid;
+        }
+
+        /**
+         * Get the transaction ID.
+         *
+         * @return the transaction ID
+         */
+        public Xid getXid() {
+            return xid;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to obtain a list of prepared transaction branches from the underlying resource manager.
+     *
+     * @see javax.transaction.xa.XAResource#recover(int)
+     */
+    final class Recover implements TxnRequest {
+
+        private final int flag;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param flag the flag(s)
+         */
+        public Recover(final int flag) {
+            this.flag = flag;
+        }
+
+        /**
+         * Get the flag value.
+         *
+         * @return the flag value
+         */
+        public int getFlag() {
+            return flag;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to roll back a local transaction.
+     *
+     * @see org.jboss.remoting.txn.TransactionalClient#rollback()
+     */
+    final class RollbackLocal implements TxnRequest {
+
+        /**
+         * The single instance.
+         */
+        public static RollbackLocal INSTANCE = new RollbackLocal();
+
+        private RollbackLocal() {
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to start a local transaction.
+     *
+     * @see org.jboss.remoting.txn.TransactionalClient#start()
+     */
+    final class StartLocal implements TxnRequest {
+
+        /**
+         * The single instance.
+         */
+        public static StartLocal INSTANCE = new StartLocal();
+
+        private StartLocal() {
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A wrapped application request.
+     */
+    final class Wrapped implements TxnRequest {
+
+        private final Object wrappedRequest;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param request the application request
+         */
+        public Wrapped(final Object request) {
+            wrappedRequest = request;
+        }
+
+        /**
+         * Get the wrapped request.
+         *
+         * @return the wrapped request
+         */
+        public Object getWrappedRequest() {
+            return wrappedRequest;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to commit a distributed transaction.
+     *
+     * @see javax.transaction.xa.XAResource#commit(javax.transaction.xa.Xid, boolean)
+     */
+    final class CommitXA implements TxnRequest {
+        private final Xid xid;
+        private final boolean onePhase;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param xid the transaction ID
+         * @param onePhase {@code true} if the commit should be done in a single phase
+         */
+        public CommitXA(final Xid xid, final boolean onePhase) {
+            this.xid = xid;
+            this.onePhase = onePhase;
+        }
+
+        /**
+         * Get the transaction ID.
+         *
+         * @return the transaction ID
+         */
+        public Xid getXid() {
+            return xid;
+        }
+
+        /**
+         * Determine whether a one-phase commit was requested.
+         *
+         * @return {@code true} if a one-phase commit was requested
+         */
+        public boolean isOnePhase() {
+            return onePhase;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to roll back a distributed transaction.
+     *
+     * @see javax.transaction.xa.XAResource#rollback(javax.transaction.xa.Xid)
+     */
+    final class RollbackXA implements TxnRequest {
+
+        private final Xid xid;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param xid the transaction ID
+         */
+        public RollbackXA(final Xid xid) {
+            this.xid = xid;
+        }
+
+        /**
+         * Get the transaction ID.
+         *
+         * @return the transaction ID
+         */
+        public Xid getXid() {
+            return xid;
+        }
+
+        /** {@inheritDoc} */
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+
+    /**
+     * A request to start a distributed transaction.
+     *
+     * @see javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid, int)
+     */
+    final class StartXA implements TxnRequest {
+
+        private final Xid xid;
+        private final int flags;
+
+        /**
+         * Construct a new instance.
+         *
+         * @param xid the transaction ID
+         * @param flags the flags
+         */
+        public StartXA(final Xid xid, final int flags) {
+            this.xid = xid;
+            this.flags = flags;
+        }
+
+        /**
+         * Get the transaction ID.
+         *
+         * @return the transaction ID
+         */
+        public Xid getXid() {
+            return xid;
+        }
+
+        /**
+         * Get the flags.
+         *
+         * @return the flags
+         */
+        public int getFlags() {
+            return flags;
+        }
+
+        public <I, O> O accept(final Visitor<I, O> visitor, final I param) {
+            return visitor.visit(this, param);
+        }
+    }
+}




More information about the jboss-remoting-commits mailing list