[jboss-cvs] JBossAS SVN: r111035 - in projects/jboss-jca/trunk/core/src/test: resources and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 25 11:00:22 EDT 2011


Author: jesper.pedersen
Date: 2011-03-25 11:00:18 -0400 (Fri, 25 Mar 2011)
New Revision: 111035

Added:
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/LocalXAResourceImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionIntegrationImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionLocalImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/UserTransactionRegistryImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceRecoveryImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceWrapperImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XATerminatorImpl.java
Removed:
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java
Modified:
   projects/jboss-jca/trunk/core/src/test/resources/noop-transaction.xml
Log:
[JBJCA-533] Transaction infrastructure (Part 3)

Deleted: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java	2011-03-25 14:27:42 UTC (rev 111034)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
-
-import org.jboss.jca.core.spi.transaction.xa.XATerminator;
-
-import java.io.Serializable;
-
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkCompletedException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-/**
- * A JBoss XATerminator implementation
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class JBossXATerminatorImpl implements XATerminator, Serializable
-{
-   private static final long serialVersionUID = 1L;
-
-   /**
-    * Constructor
-    */
-   public JBossXATerminatorImpl()
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void commit(Xid xid, boolean onePhase) throws XAException
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void forget(Xid xid) throws XAException
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public int prepare(Xid xid) throws XAException
-   {
-      return XAResource.XA_OK;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public Xid[] recover(int flag) throws XAException
-   {
-      return new Xid[0];
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void rollback(Xid xid) throws XAException
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void registerWork(Work work, Xid xid, long timeout) throws WorkCompletedException
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void startWork(Work work, Xid xid) throws WorkCompletedException
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void endWork(Work work, Xid xid)
-   {
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void cancelWork(Work work, Xid xid)
-   {
-   }
-}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/LocalXAResourceImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/LocalXAResourceImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/LocalXAResourceImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener;
+import org.jboss.jca.core.spi.transaction.local.LocalXAException;
+import org.jboss.jca.core.spi.transaction.local.LocalXAResource;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * Local XA resource implementation.
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class LocalXAResourceImpl implements LocalXAResource
+{
+   /**
+    * Creates a new instance.
+    */
+   public LocalXAResourceImpl()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setConnectionManager(ConnectionManager connectionManager)
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setConnectionListener(ConnectionListener cl)
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void start(Xid xid, int flags) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void end(Xid xid, int flags) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Xid xid, boolean onePhase) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void forget(Xid xid) throws XAException
+   {
+      throw new LocalXAException("Forget not supported in local tx", XAException.XAER_RMERR);
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public int getTransactionTimeout() throws XAException
+   {
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isSameRM(XAResource xaResource) throws XAException
+   {
+      return xaResource == this;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int prepare(Xid xid) throws XAException
+   {
+      return XAResource.XA_OK;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid[] recover(int flag) throws XAException
+   {
+      throw new LocalXAException("No recover with local-tx only resource managers", XAException.XAER_RMERR);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Xid xid) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean setTransactionTimeout(int seconds) throws XAException
+   {
+      return false;
+   }
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionIntegrationImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionIntegrationImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionIntegrationImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.local.LocalXAResource;
+import org.jboss.jca.core.spi.transaction.local.TransactionLocal;
+import org.jboss.jca.core.spi.transaction.local.TransactionLocalDelegate;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry;
+import org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper;
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.SubjectFactory;
+
+/**
+ * This class provide an implementation of the transaction integration for
+ * the IronJacamar container using NoopTS.
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class TransactionIntegrationImpl implements TransactionIntegration
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(TransactionIntegrationImpl.class);
+
+   /** The transaction manager */
+   private TransactionManager tm;
+
+   /** The transaction synchronization registry */
+   private TransactionSynchronizationRegistry tsr;
+
+   /** User transaction registry */
+   private UserTransactionRegistry utr;
+
+   /** XATerminator */
+   private XATerminator terminator;
+
+   /** Recovery registry */
+   private XAResourceRecoveryRegistry rr;
+
+   /** Transaction local delegate */
+   private TransactionLocalDelegate tld;
+
+   /**
+    * Constructor
+    * @param tm The transaction manager
+    * @param tsr The transaction synchronization registry
+    * @param utr The user transaction registry
+    * @param terminator The XA terminator
+    * @param rr The recovery registry
+    * @param tld The transaction local delegate
+    */
+   public TransactionIntegrationImpl(TransactionManager tm,
+                                     TransactionSynchronizationRegistry tsr,
+                                     UserTransactionRegistry utr,
+                                     XATerminator terminator,
+                                     XAResourceRecoveryRegistry rr,
+                                     TransactionLocalDelegate tld)
+   {
+      this.tm = tm;
+      this.tsr = tsr;
+      this.utr = utr;
+      this.terminator = terminator;
+      this.rr = rr;
+      this.tld = tld;
+   }
+
+   /**
+    * Get the transaction manager
+    * @return The value
+    */
+   public TransactionManager getTransactionManager()
+   {
+      return tm;
+   }
+
+   /**
+    * Get the transaction synchronization registry
+    * @return The value
+    */
+   public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
+   {
+      return tsr;
+   }
+
+   /**
+    * Get the user transaction registry
+    * @return The value
+    */
+   public UserTransactionRegistry getUserTransactionRegistry()
+   {
+      return utr;
+   }
+
+   /**
+    * Get the recovery registry
+    * @return The value
+    */
+   public XAResourceRecoveryRegistry getRecoveryRegistry()
+   {
+      return rr;
+   }
+
+   /**
+    * Get the XATerminator
+    * @return The value
+    */
+   public XATerminator getXATerminator()
+   {
+      return terminator;
+   }
+
+   /**
+    * Get the XATerminator
+    * @return The value
+    */
+   public TransactionLocalDelegate getTransactionLocalDelegate()
+   {
+      return tld;
+   }
+
+   /**
+    * Create an XAResourceRecovery instance
+    *
+    * @param mcf The managed connection factory
+    * @param pad Should the branch qualifier for Xid's be padded
+    * @param override Should the isSameRM value be overriden; <code>null</code> for instance equally check
+    * @param wrapXAResource Should the XAResource be wrapped
+    * @param recoverUserName The user name for recovery
+    * @param recoverPassword The password for recovery
+    * @param recoverSecurityDomain The security domain for recovery
+    * @param subjectFactory The subject factory
+    * @param plugin The recovery plugin
+    * @return The value
+    */
+   public XAResourceRecovery createXAResourceRecovery(ManagedConnectionFactory mcf,
+                                                      Boolean pad, Boolean override, 
+                                                      Boolean wrapXAResource,
+                                                      String recoverUserName, String recoverPassword, 
+                                                      String recoverSecurityDomain,
+                                                      SubjectFactory subjectFactory,
+                                                      RecoveryPlugin plugin)
+   {
+      return new XAResourceRecoveryImpl();
+   }
+
+   /**
+    * Create a LocalXAResource instance
+    * @param cm The connection manager
+    * @return The value
+    */
+   public LocalXAResource createLocalXAResource(ConnectionManager cm)
+   {
+      return new LocalXAResourceImpl();
+   }
+
+   /**
+    * Create an XAResource wrapper instance
+    * @param xares The XAResource instance
+    * @param pad Should the branch qualifier for Xid's be padded
+    * @param override Should the isSameRM value be overriden; <code>null</code> for instance equally check
+    * @param productName The product name
+    * @param productVersion The product version
+    * @param jndiName The JNDI name for the resource
+    * @return The value
+    */
+   public XAResourceWrapper createXAResourceWrapper(XAResource xares,
+                                                    boolean pad, Boolean override, 
+                                                    String productName, String productVersion,
+                                                    String jndiName)
+   {
+      return new XAResourceWrapperImpl(xares, override, productName, productVersion, jndiName);
+   }
+
+   /**
+    * Create a transaction local instance
+    * @return The value
+    */
+   public TransactionLocal createTransactionLocal()
+   {
+      return new TransactionLocalImpl(this);
+   }
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionLocalImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionLocalImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionLocalImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.local.TransactionLocal;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.transaction.Transaction;
+
+/**
+ * A TransactionLocal implementation
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class TransactionLocalImpl implements TransactionLocal
+{
+   private TransactionIntegration ti;
+   private Map<Transaction, Object> values;
+
+   /**
+    * Constructor
+    * @param ti The transaction integration
+    */
+   public TransactionLocalImpl(TransactionIntegration ti)
+   {
+      this.ti = ti;
+      this.values = Collections.synchronizedMap(new HashMap<Transaction, Object>());
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void lock() throws InterruptedException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void lock(Transaction transaction) throws InterruptedException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void unlock()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void unlock(Transaction transaction)
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public synchronized Object get()
+   {
+      return get(getTransaction());
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public synchronized Object get(Transaction transaction)
+   {
+      return values.get(transaction);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public synchronized void set(Object value)
+   {
+      set(getTransaction(), value);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public synchronized void set(Transaction transaction, Object value)
+   {
+      values.put(transaction, value);
+   }
+
+   /**
+    * Get the current transaction
+    * @return The value
+    */
+   public synchronized Transaction getTransaction()
+   {
+      try
+      {
+         return ti.getTransactionManager().getTransaction();
+      }
+      catch (Throwable t)
+      {
+         throw new IllegalStateException(t.getMessage(), t);
+      }
+   }
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/UserTransactionRegistryImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/UserTransactionRegistryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/UserTransactionRegistryImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionListener;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * UserTransactionRegistry implementation.
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class UserTransactionRegistryImpl implements UserTransactionRegistry
+{
+   /** Listeners */
+   private Set<UserTransactionListener> listeners;
+
+   /**
+    * Constructor
+    */
+   public UserTransactionRegistryImpl()
+   {
+      this.listeners = Collections.synchronizedSet(new HashSet<UserTransactionListener>());
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void addListener(UserTransactionListener listener)
+   {
+      if (listener != null)
+         listeners.add(listener);
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public void removeListener(UserTransactionListener listener)
+   {
+      if (listener != null)
+         listeners.remove(listener);
+   }
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceRecoveryImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceRecoveryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceRecoveryImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * An XAResourceRecovery implementation.
+ *
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XAResourceRecoveryImpl implements XAResourceRecovery
+{
+   /**
+    * Constructor
+    */
+   public XAResourceRecoveryImpl()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public XAResource[] getXAResources()
+   {
+      return new XAResource[0];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void setJndiName(String jndiName)
+   {
+   }
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceWrapperImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceWrapperImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XAResourceWrapperImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A XAResourceWrapper.
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XAResourceWrapperImpl implements XAResourceWrapper
+{
+   /** Serial version UID */
+   private static final long serialVersionUID = 2147435420748633848L;
+
+   /** Log instance */
+   private static Logger log = Logger.getLogger(XAResourceWrapperImpl.class);
+   
+   /** The XA resource */
+   private XAResource xaResource;
+   
+   /** Override Rm Value */
+   private Boolean overrideRmValue;
+
+   /** Product name */
+   private String productName;
+
+   /** Product version */
+   private String productVersion;
+   
+   /** Product version */
+   private String jndiName;
+   
+   /**
+    * Creates a new wrapper instance.
+    * @param resource xaresource
+    * @param override override
+    * @param productName product name
+    * @param productVersion product version
+    * @param jndiName jndi name
+    */   
+   public XAResourceWrapperImpl(XAResource resource, Boolean override, 
+                                String productName, String productVersion,
+                                String jndiName)
+   {
+      this.xaResource = resource;
+      this.overrideRmValue = override;
+      this.productName = productName;
+      this.productVersion = productVersion;
+      this.jndiName = jndiName;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Xid xid, boolean onePhase) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void end(Xid xid, int flags) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void forget(Xid xid) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int getTransactionTimeout() throws XAException
+   {
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isSameRM(XAResource resource) throws XAException
+   {
+      if (overrideRmValue != null)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Executing isSameRM with override value" + overrideRmValue + " for XAResourceWrapper" + this);
+         }
+         return overrideRmValue.booleanValue();
+      }
+      else
+      {
+         if (resource instanceof org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper)
+         {
+            org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper other =
+               (org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper)resource;
+            return xaResource.isSameRM(other.getResource());
+         }
+         else
+         {
+            return xaResource.isSameRM(resource);
+         }
+         
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int prepare(Xid xid) throws XAException
+   {
+      return XAResource.XA_OK;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid[] recover(int flag) throws XAException
+   {
+      return new Xid[0];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Xid xid) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean setTransactionTimeout(int flag) throws XAException
+   {
+      return true;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void start(Xid xid, int flags) throws XAException
+   {
+   }
+
+   /**
+    * Get the XAResource that is being wrapped
+    * @return The XAResource
+    */
+   public XAResource getResource()
+   {
+      return xaResource;
+   }
+
+   /**
+    * Get product name
+    * @return Product name of the instance if defined; otherwise <code>null</code>
+    */
+   public String getProductName()
+   {
+      return productName;
+   }
+
+   /**
+    * Get product version
+    * @return Product version of the instance if defined; otherwise <code>null</code>
+    */
+   public String getProductVersion()
+   {
+      return productVersion;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+   
+   /**
+    * Return wrapper for given xid.
+    * @param xid xid
+    * @return return wrapper
+    */
+   private Xid convertXid(Xid xid)
+   {
+      return xid;
+   }
+}

Copied: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XATerminatorImpl.java (from rev 111030, projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XATerminatorImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/XATerminatorImpl.java	2011-03-25 15:00:18 UTC (rev 111035)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test.txmgr;
+
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
+
+import java.io.Serializable;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkCompletedException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * An XATerminator implementation
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XATerminatorImpl implements XATerminator, Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   /**
+    * Constructor
+    */
+   public XATerminatorImpl()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Xid xid, boolean onePhase) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void forget(Xid xid) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int prepare(Xid xid) throws XAException
+   {
+      return XAResource.XA_OK;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid[] recover(int flag) throws XAException
+   {
+      return new Xid[0];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Xid xid) throws XAException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void registerWork(Work work, Xid xid, long timeout) throws WorkCompletedException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void startWork(Work work, Xid xid) throws WorkCompletedException
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void endWork(Work work, Xid xid)
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void cancelWork(Work work, Xid xid)
+   {
+   }
+}

Modified: projects/jboss-jca/trunk/core/src/test/resources/noop-transaction.xml
===================================================================
--- projects/jboss-jca/trunk/core/src/test/resources/noop-transaction.xml	2011-03-25 14:27:42 UTC (rev 111034)
+++ projects/jboss-jca/trunk/core/src/test/resources/noop-transaction.xml	2011-03-25 15:00:18 UTC (rev 111035)
@@ -12,8 +12,8 @@
 
   <!-- XATerminator -->
   <bean name="XATerminator"
-        interface="org.jboss.tm.JBossXATerminator" 
-        class="org.jboss.jca.test.txmgr.JBossXATerminatorImpl">
+        interface="org.jboss.jca.core.spi.transaction.xa.XATerminator" 
+        class="org.jboss.jca.test.txmgr.XATerminatorImpl">
   </bean>
 
   <!-- Transaction manager -->
@@ -48,4 +48,24 @@
     <depends>NamingServer</depends>
   </bean>
 
+  <!-- UserTransactionRegistry -->
+  <bean name="UserTransactionRegistry"
+        interface="org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry" 
+        class="org.jboss.jca.test.txmgr.UserTransactionRegistryImpl">
+  </bean>
+
+  <!-- Transaction integration -->
+  <bean name="TransactionIntegration"
+        interface="org.jboss.jca.core.spi.transaction.TransactionIntegration"
+        class="org.jboss.jca.test.txmgr.TransactionIntegrationImpl">
+    <constructor>
+      <parameter><inject bean="RealTransactionManager"/></parameter>
+      <parameter><inject bean="TransactionSynchronizationRegistry"/></parameter>
+      <parameter><inject bean="UserTransactionRegistry"/></parameter>
+      <parameter><inject bean="XATerminator"/></parameter>
+      <parameter><null/></parameter>
+      <parameter><null/></parameter>
+    </constructor>
+  </bean>
+
 </deployment>



More information about the jboss-cvs-commits mailing list