[jboss-remoting-commits] JBoss Remoting SVN: r4809 - in remoting-txn/trunk: src and 6 other directories.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Jan 14 17:57:56 EST 2009


Author: david.lloyd at jboss.com
Date: 2009-01-14 17:57:56 -0500 (Wed, 14 Jan 2009)
New Revision: 4809

Added:
   remoting-txn/trunk/src/
   remoting-txn/trunk/src/main/
   remoting-txn/trunk/src/main/java/
   remoting-txn/trunk/src/main/java/org/
   remoting-txn/trunk/src/main/java/org/jboss/
   remoting-txn/trunk/src/main/java/org/jboss/remoting/
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClient.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientImpl.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSource.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSourceImpl.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnCommitRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnEndRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnForgetRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequestVisitor.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRollbackRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnStartRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSuccessfulReply.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnWrappedRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXACommitRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXARollbackRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXAStartRequest.java
   remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/WrappingRequestHandler.java
Log:
Initial import of remoting-txn

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public abstract class AbstractTxnReply {
+
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/AbstractTxnRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public abstract class AbstractTxnRequest {
+    public abstract <I, O> O accept(TxnRequestVisitor<I, O> visitor, I param);
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClient.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClient.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClient.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,42 @@
+/*
+ * 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 org.jboss.remoting.Client;
+
+import javax.transaction.xa.XAResource;
+
+import java.io.IOException;
+
+/**
+ *
+ */
+public interface TransactionalClient<I, O> extends Client<I, O> {
+    void start() throws IOException;
+
+    void commit() throws IOException;
+
+    void rollback() throws IOException;
+
+    XAResource getXaResource();
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientImpl.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientImpl.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientImpl.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,189 @@
+/*
+ * 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 java.io.IOException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.IoUtils;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.RemoteExecutionException;
+
+/**
+ *
+ */
+public final class TransactionalClientImpl<I, O> implements TransactionalClient<I, O> {
+
+    private final Client<I, O> realClient;
+    private final Client<AbstractTxnRequest, AbstractTxnReply> txnClient;
+
+    private RemotingXAResource remotingXAResource;
+
+    TransactionalClientImpl(final Client<I, O> realClient, final Client<AbstractTxnRequest, AbstractTxnReply> txnClient) throws IOException {
+        this.realClient = realClient;
+        this.txnClient = txnClient;
+        remotingXAResource = new RemotingXAResource(txnClient);
+    }
+
+    private static XAException xaException(IOException ex) {
+        try {
+            throw ex;
+        } catch (RemoteExecutionException e) {
+            try {
+                throw e.getCause();
+            } catch (XAException xae) {
+                return xae;
+            } catch (Throwable throwable) {
+                final XAException xae = new XAException(XAException.XA_RBPROTO);
+                xae.initCause(e);
+                return xae;
+            }
+        } catch (IOException e) {
+            final XAException xae = new XAException(XAException.XA_RBPROTO);
+            xae.initCause(e);
+            return xae;
+        }
+    }
+
+    private static AbstractTxnReply doInvoke(Client<AbstractTxnRequest, AbstractTxnReply> txnClient, AbstractTxnRequest request) throws XAException {
+        try {
+            return txnClient.invoke(request);
+        } catch (IOException e) {
+            throw xaException(e);
+        }
+    }
+
+    public void start() throws IOException {
+        txnClient.invoke(TxnStartRequest.INSTANCE);
+    }
+
+    public void commit() throws IOException {
+        txnClient.invoke(TxnCommitRequest.INSTANCE);
+    }
+
+    public void rollback() throws IOException {
+        txnClient.invoke(TxnRollbackRequest.INSTANCE);
+    }
+
+    public XAResource getXaResource() {
+        return remotingXAResource;
+    }
+
+    public O invoke(final I request) throws IOException, CancellationException {
+        return realClient.invoke(request);
+    }
+
+    public IoFuture<? extends O> send(final I request) throws IOException {
+        return realClient.send(request);
+    }
+
+    public ConcurrentMap<Object, Object> getAttributes() {
+        return realClient.getAttributes();
+    }
+
+    public void close() throws IOException {
+        try {
+            realClient.close();
+            txnClient.close();
+        } finally {
+            IoUtils.safeClose(txnClient);
+        }
+    }
+
+    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) {
+                handler.handleClose(TransactionalClientImpl.this);
+            }
+        });
+    }
+
+    /**
+     *
+     */
+    public static final class RemotingXAResource implements XAResource {
+        private final Client<AbstractTxnRequest, AbstractTxnReply> txnClient;
+        private final IoFuture<? extends TxnGetResourceManagerIdReply> futureIdReply;
+
+        public RemotingXAResource(final Client<AbstractTxnRequest, AbstractTxnReply> client) throws IOException {
+            txnClient = client;
+            futureIdReply = IoUtils.cast(txnClient.send(TxnGetResourceManagerIdRequest.INSTANCE), TxnGetResourceManagerIdReply.class);
+        }
+
+        public void commit(final Xid xid, final boolean onePhase) throws XAException {
+            doInvoke(txnClient, new TxnXACommitRequest(xid, onePhase));
+        }
+
+        public void end(final Xid xid, final int flags) throws XAException {
+            doInvoke(txnClient, new TxnEndRequest(xid, flags));
+        }
+
+        public void forget(final Xid xid) throws XAException {
+            doInvoke(txnClient, new TxnForgetRequest(xid));
+        }
+
+        public int getTransactionTimeout() throws XAException {
+            return ((TxnGetTimeoutReply) doInvoke(txnClient, TxnGetTimeoutRequest.INSTANCE)).getTimeout();
+        }
+
+        public boolean isSameRM(final XAResource resource) throws XAException {
+            if (resource instanceof RemotingXAResource) {
+                final RemotingXAResource xaResource = (RemotingXAResource) resource;
+                try {
+                    return futureIdReply.get().getId().equals(xaResource.futureIdReply.get().getId());
+                } catch (IOException e) {
+                    throw xaException(e);
+                }
+            } else {
+                return false;
+            }
+        }
+
+        public int prepare(final Xid xid) throws XAException {
+            return ((TxnPrepareReply) doInvoke(txnClient, new TxnPrepareRequest(xid))).getVote();
+        }
+
+        public Xid[] recover(final int flag) throws XAException {
+            return ((TxnRecoverReply) doInvoke(txnClient, new TxnRecoverRequest(flag))).getResources();
+        }
+
+        public void rollback(final Xid xid) throws XAException {
+            doInvoke(txnClient, new TxnXARollbackRequest(xid));
+        }
+
+        public boolean setTransactionTimeout(final int timeout) throws XAException {
+            return ((TxnSetTimeoutReply) doInvoke(txnClient, new TxnSetTimeoutRequest(timeout))).getSuccess();
+        }
+
+        public void start(final Xid xid, final int flags) throws XAException {
+            doInvoke(txnClient, new TxnXAStartRequest(xid, flags));
+        }
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSource.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSource.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSource.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,34 @@
+/*
+ * 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 org.jboss.remoting.ClientSource;
+import java.io.IOException;
+
+/**
+ *
+ */
+public interface TransactionalClientSource<I, O> extends ClientSource<I, O> {
+
+    TransactionalClient<I, O> createClient() throws IOException;
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSourceImpl.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSourceImpl.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TransactionalClientSourceImpl.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,98 @@
+/*
+ * 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 java.io.IOException;
+import java.util.concurrent.Executor;
+import org.jboss.remoting.ClientSource;
+import org.jboss.remoting.Endpoint;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.AbstractHandleableCloseable;
+import org.jboss.xnio.IoUtils;
+
+/**
+ *
+ */
+public final class TransactionalClientSourceImpl<I, O> extends AbstractHandleableCloseable<ClientSource<I, O>> implements TransactionalClientSource<I, O> {
+
+    private final Endpoint endpoint;
+    private final RequestHandlerSource requestHandlerSource;
+    private final Class<I> requestClass;
+    private final Class<O> replyClass;
+    private volatile Key key;
+
+    private TransactionalClientSourceImpl(final Executor executor, final Endpoint endpoint, final RequestHandlerSource requestHandlerSource, final Class<I> requestClass, final Class<O> replyClass) {
+        super(executor);
+        this.endpoint = endpoint;
+        this.requestHandlerSource = requestHandlerSource;
+        this.requestClass = requestClass;
+        this.replyClass = replyClass;
+    }
+
+    static <I, O> TransactionalClientSourceImpl<I, O> create(final Executor executor, final Endpoint endpoint, final RequestHandlerSource requestHandlerSource, final Class<I> requestClass, final Class<O> replyClass) {
+        final TransactionalClientSourceImpl<I, O> clientSource = new TransactionalClientSourceImpl<I, O>(executor, endpoint, requestHandlerSource, requestClass, replyClass);
+        final Key key = requestHandlerSource.addCloseHandler(new CloseHandler<RequestHandlerSource>() {
+            public void handleClose(final RequestHandlerSource closed) {
+                IoUtils.safeClose(clientSource);
+            }
+        });
+        clientSource.key = key;
+        return clientSource;
+    }
+
+    protected void closeAction() throws IOException {
+        final Key key = this.key;
+        if (key != null) {
+            key.remove();
+            this.key = null;
+        }
+    }
+
+    public TransactionalClient<I, O> createClient() throws IOException {
+        boolean ok = false;
+        final Handle<RequestHandler> handle = requestHandlerSource.createRequestHandler();
+        try {
+            final RequestHandler requestHandler = handle.getResource();
+            final Client<I, O> realClient = endpoint.createClient(WrappingRequestHandler.create(executor, requestHandler), requestClass, replyClass);
+            try {
+                final Client<AbstractTxnRequest, AbstractTxnReply> txnClient = endpoint.createClient(requestHandler, AbstractTxnRequest.class, AbstractTxnReply.class);
+                try {
+                    handle.close();
+                    final TransactionalClientImpl<I, O> transactionalClient = new TransactionalClientImpl<I, O>(realClient, txnClient);
+                    ok = true;
+                    return transactionalClient;
+                } finally {
+                    if (! ok) IoUtils.safeClose(txnClient);
+                }
+            } finally {
+                if (! ok) IoUtils.safeClose(realClient);
+            }
+        } finally {
+            IoUtils.safeClose(handle);
+        }
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnCommitRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnCommitRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnCommitRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnCommitRequest extends AbstractTxnRequest {
+    public static final TxnCommitRequest INSTANCE = new TxnCommitRequest();
+
+    private TxnCommitRequest() {
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnEndRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnEndRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnEndRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnEndRequest extends AbstractTxnRequest {
+
+    public TxnEndRequest(final Xid xid, final int flags) {
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnForgetRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnForgetRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnForgetRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnForgetRequest extends AbstractTxnRequest {
+
+    private final Xid xid;
+
+    public TxnForgetRequest(final Xid xid) {
+        this.xid = xid;
+    }
+
+    public Xid getXid() {
+        return xid;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnGetResourceManagerIdReply extends AbstractTxnReply {
+    private final Object id;
+
+    public TxnGetResourceManagerIdReply(final Object id) {
+        this.id = id;
+    }
+
+    public Object getId() {
+        return id;
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetResourceManagerIdRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnGetResourceManagerIdRequest extends AbstractTxnRequest {
+
+    public static final TxnGetResourceManagerIdRequest INSTANCE = new TxnGetResourceManagerIdRequest();
+
+    private TxnGetResourceManagerIdRequest() {
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnGetTimeoutReply extends AbstractTxnReply {
+
+    private final int timeout;
+
+    public TxnGetTimeoutReply(final int timeout) {
+        this.timeout = timeout;
+    }
+
+    public int getTimeout() {
+        return timeout;
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnGetTimeoutRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnGetTimeoutRequest extends AbstractTxnRequest {
+
+    public static final TxnGetTimeoutRequest INSTANCE = new TxnGetTimeoutRequest();
+
+    private TxnGetTimeoutRequest() {
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnPrepareReply extends AbstractTxnReply {
+    private final int vote;
+
+    public TxnPrepareReply(final int vote) {
+        this.vote = vote;
+    }
+
+    public int getVote() {
+        return vote;
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnPrepareRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnPrepareRequest extends AbstractTxnRequest {
+
+    private final Xid xid;
+
+    public TxnPrepareRequest(final Xid xid) {
+        this.xid = xid;
+    }
+
+    public Xid getXid() {
+        return xid;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnRecoverReply extends AbstractTxnReply {
+
+    private final Xid[] resources;
+
+    public TxnRecoverReply(final Xid[] resources) {
+        this.resources = resources;
+    }
+
+    public Xid[] getResources() {
+        return resources;
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRecoverRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnRecoverRequest extends AbstractTxnRequest {
+
+    private final int flag;
+
+    public TxnRecoverRequest(final int flag) {
+        this.flag = flag;
+    }
+
+    public int getFlag() {
+        return flag;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequestVisitor.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequestVisitor.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRequestVisitor.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public interface TxnRequestVisitor<I, O> {
+
+    O visit(TxnXACommitRequest request, I param);
+
+    O visit(TxnEndRequest request, I param);
+
+    O visit(TxnForgetRequest request, I param);
+
+    O visit(TxnGetTimeoutRequest request, I param);
+
+    O visit(TxnPrepareRequest request, I param);
+
+    O visit(TxnRecoverRequest request, I param);
+
+    O visit(TxnXARollbackRequest request, I param);
+
+    O visit(TxnSetTimeoutRequest request, I param);
+
+    O visit(TxnXAStartRequest request, I param);
+
+    O visit(TxnWrappedRequest request, I param);
+
+    O visit(TxnGetResourceManagerIdRequest request, I param);
+
+    O visit(TxnStartRequest request, I param);
+
+    O visit(TxnCommitRequest request, I param);
+
+    O visit(TxnRollbackRequest request, I param);
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRollbackRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRollbackRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnRollbackRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnRollbackRequest extends AbstractTxnRequest {
+
+    public static TxnRollbackRequest INSTANCE = new TxnRollbackRequest();
+
+    private TxnRollbackRequest() {
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnSetTimeoutReply extends AbstractTxnReply {
+
+    private final boolean success;
+
+    public TxnSetTimeoutReply(final boolean success) {
+        this.success = success;
+    }
+
+    public boolean getSuccess() {
+        return success;
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSetTimeoutRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnSetTimeoutRequest extends AbstractTxnRequest {
+
+    private final int timeout;
+
+    public TxnSetTimeoutRequest(final int timeout) {
+        this.timeout = timeout;
+    }
+
+    public int getTimeout() {
+        return timeout;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnStartRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnStartRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnStartRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnStartRequest extends AbstractTxnRequest {
+
+    public static TxnStartRequest INSTANCE = new TxnStartRequest();
+
+    private TxnStartRequest() {
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSuccessfulReply.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSuccessfulReply.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnSuccessfulReply.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnSuccessfulReply extends AbstractTxnReply {
+    public static final TxnSuccessfulReply INSTANCE = new TxnSuccessfulReply();
+
+    private TxnSuccessfulReply() {
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnWrappedRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnWrappedRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnWrappedRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnWrappedRequest extends AbstractTxnRequest {
+
+    private final Object wrappedRequest;
+
+    public TxnWrappedRequest(final Object request) {
+        wrappedRequest = request;
+    }
+
+    public Object getWrappedRequest() {
+        return wrappedRequest;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXACommitRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXACommitRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXACommitRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -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;
+
+import javax.transaction.xa.Xid;
+
+/**
+ *
+ */
+public final class TxnXACommitRequest extends AbstractTxnRequest {
+    private final Xid xid;
+    private final boolean onePhase;
+
+    public TxnXACommitRequest(final Xid xid, final boolean onePhase) {
+        this.xid = xid;
+        this.onePhase = onePhase;
+    }
+
+    public Xid getXid() {
+        return xid;
+    }
+
+    public boolean isOnePhase() {
+        return onePhase;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXARollbackRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXARollbackRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXARollbackRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnXARollbackRequest extends AbstractTxnRequest {
+
+    private final Xid xid;
+
+    public TxnXARollbackRequest(final Xid xid) {
+        this.xid = xid;
+    }
+
+    public Xid getXid() {
+        return xid;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXAStartRequest.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXAStartRequest.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/TxnXAStartRequest.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public final class TxnXAStartRequest extends AbstractTxnRequest {
+
+    private final Xid xid;
+    private final int flags;
+
+    public TxnXAStartRequest(final Xid xid, final int flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    public Xid getXid() {
+        return xid;
+    }
+
+    public int getFlags() {
+        return flags;
+    }
+
+    public <I, O> O accept(final TxnRequestVisitor<I, O> visitor, final I param) {
+        return visitor.visit(this, param);
+    }
+}

Added: remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/WrappingRequestHandler.java
===================================================================
--- remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/WrappingRequestHandler.java	                        (rev 0)
+++ remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/WrappingRequestHandler.java	2009-01-14 22:57:56 UTC (rev 4809)
@@ -0,0 +1,70 @@
+/*
+ * 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 org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.AbstractAutoCloseable;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.xnio.IoUtils;
+import java.util.concurrent.Executor;
+import java.io.IOException;
+
+/**
+ *
+ */
+public final class WrappingRequestHandler extends AbstractAutoCloseable<RequestHandler> implements RequestHandler {
+
+    private final Handle<RequestHandler> handle;
+    private volatile Key key;
+
+    private WrappingRequestHandler(final Executor executor, final RequestHandler handler) throws IOException {
+        super(executor);
+        handle = handler.getHandle();
+    }
+
+    static WrappingRequestHandler create(final Executor executor, final RequestHandler handler) throws IOException {
+        final WrappingRequestHandler requestHandler = new WrappingRequestHandler(executor, handler);
+        requestHandler.key = requestHandler.handle.addCloseHandler(new CloseHandler<Handle<RequestHandler>>() {
+            public void handleClose(final Handle<RequestHandler> closed) {
+                IoUtils.safeClose(requestHandler);
+            }
+        });
+        return requestHandler;
+    }
+
+    protected void closeAction() throws IOException {
+        try {
+            handle.close();
+        } finally {
+            key.remove();
+            key = null;
+        }
+    }
+
+    public RemoteRequestContext receiveRequest(final Object request, final ReplyHandler replyHandler) {
+        return handle.getResource().receiveRequest(new TxnWrappedRequest(request), replyHandler);
+    }
+}




More information about the jboss-remoting-commits mailing list