[jboss-cvs] JBossAS SVN: r64571 - in trunk/jbossmq/src/main/org/jboss/mq: sm/jdbc and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 14 09:36:38 EDT 2007


Author: adrian at jboss.org
Date: 2007-08-14 09:36:38 -0400 (Tue, 14 Aug 2007)
New Revision: 64571

Modified:
   trunk/jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java
   trunk/jbossmq/src/main/org/jboss/mq/sm/jdbc/JDBCStateManager.java
Log:
Port JBAS-4607 from 4.2

Modified: trunk/jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java
===================================================================
--- trunk/jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java	2007-08-14 13:31:20 UTC (rev 64570)
+++ trunk/jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java	2007-08-14 13:36:38 UTC (rev 64571)
@@ -45,7 +45,6 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.sql.DataSource;
-import javax.transaction.Status;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 import javax.transaction.xa.Xid;
@@ -181,6 +180,7 @@
     */
    protected class TransactionManagerStrategy
    {
+      boolean rollback = false;
 
       Transaction threadTx;
 
@@ -213,21 +213,14 @@
 
       void setRollbackOnly() throws JMSException
       {
-         try
-         {
-            tm.setRollbackOnly();
-         }
-         catch (Exception e)
-         {
-            throw new SpyJMSException("Could not start a mark the transaction for rollback .", e);
-         }
+         rollback = true;
       }
 
       void endTX() throws JMSException
       {
          try
          {
-            if (tm.getStatus() == Status.STATUS_MARKED_ROLLBACK)
+            if (rollback)
             {
                tm.rollback();
             }

Modified: trunk/jbossmq/src/main/org/jboss/mq/sm/jdbc/JDBCStateManager.java
===================================================================
--- trunk/jbossmq/src/main/org/jboss/mq/sm/jdbc/JDBCStateManager.java	2007-08-14 13:31:20 UTC (rev 64570)
+++ trunk/jbossmq/src/main/org/jboss/mq/sm/jdbc/JDBCStateManager.java	2007-08-14 13:36:38 UTC (rev 64571)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.mq.sm.jdbc;
 
 import java.io.ByteArrayInputStream;
@@ -43,7 +43,6 @@
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.sql.DataSource;
-import javax.transaction.Status;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
@@ -86,48 +85,48 @@
    protected TransactionManager tm;
 
    /** The sql properties */
-   private Properties sqlProperties = new Properties();
+   protected Properties sqlProperties = new Properties();
 
    /** Whether to create tables */
-   private boolean createTables = true;
+   protected boolean createTables = true;
 
    /** Create the user table */
-   private String CREATE_USER_TABLE = "CREATE TABLE JMS_USERS (USERID VARCHAR(32) NOT NULL, PASSWD VARCHAR(32) NOT NULL, CLIENTID VARCHAR(128),"
+   protected String CREATE_USER_TABLE = "CREATE TABLE JMS_USERS (USERID VARCHAR(32) NOT NULL, PASSWD VARCHAR(32) NOT NULL, CLIENTID VARCHAR(128),"
          + " PRIMARY KEY(USERID))";
 
    /** Create the role table */
-   private String CREATE_ROLE_TABLE = "CREATE TABLE JMS_ROLES (ROLEID VARCHAR(32) NOT NULL, USERID VARCHAR(32) NOT NULL,"
+   protected String CREATE_ROLE_TABLE = "CREATE TABLE JMS_ROLES (ROLEID VARCHAR(32) NOT NULL, USERID VARCHAR(32) NOT NULL,"
          + " PRIMARY KEY(USERID, ROLEID))";
 
-   private String CREATE_SUBSCRIPTION_TABLE = "CREATE TABLE JMS_SUBSCRIPTIONS (CLIENTID VARCHAR(128) NOT NULL, NAME VARCHAR(128) NOT NULL,"
+   protected String CREATE_SUBSCRIPTION_TABLE = "CREATE TABLE JMS_SUBSCRIPTIONS (CLIENTID VARCHAR(128) NOT NULL, NAME VARCHAR(128) NOT NULL,"
          + " TOPIC VARCHAR(255) NOT NULL, SELECTOR VARCHAR(255)," + " PRIMARY KEY(CLIENTID, NAME))";
 
    /** Get a subscription */
-   private String GET_SUBSCRIPTION = "SELECT TOPIC, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND NAME=?";
+   protected String GET_SUBSCRIPTION = "SELECT TOPIC, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND NAME=?";
 
    /** Get subscriptions for a topic */
-   private String GET_SUBSCRIPTIONS_FOR_TOPIC = "SELECT CLIENTID, NAME, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE TOPIC=?";
+   protected String GET_SUBSCRIPTIONS_FOR_TOPIC = "SELECT CLIENTID, NAME, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE TOPIC=?";
 
    /** Lock a subscription */
-   private String LOCK_SUBSCRIPTION = "SELECT TOPIC, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND NAME=?";
+   protected String LOCK_SUBSCRIPTION = "SELECT TOPIC, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND NAME=?";
 
    /** Insert a subscription */
-   private String INSERT_SUBSCRIPTION = "INSERT INTO JMS_SUBSCRIPTIONS (CLIENTID, NAME, TOPIC, SELECTOR) VALUES(?,?,?,?)";
+   protected String INSERT_SUBSCRIPTION = "INSERT INTO JMS_SUBSCRIPTIONS (CLIENTID, NAME, TOPIC, SELECTOR) VALUES(?,?,?,?)";
 
    /** Update a subscription */
-   private String UPDATE_SUBSCRIPTION = "UPDATE JMS_SUBSCRIPTIONS SET TOPIC=?, SELECTOR=? WHERE CLIENTID=? AND NAME=?";
+   protected String UPDATE_SUBSCRIPTION = "UPDATE JMS_SUBSCRIPTIONS SET TOPIC=?, SELECTOR=? WHERE CLIENTID=? AND NAME=?";
 
    /** Remove a subscription */
-   private String REMOVE_SUBSCRIPTION = "DELETE FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND NAME=?";
+   protected String REMOVE_SUBSCRIPTION = "DELETE FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND NAME=?";
 
    /** Get a user with the given client id */
-   private String GET_USER_BY_CLIENTID = "SELECT USERID, PASSWD, CLIENTID FROM JMS_USERS WHERE CLIENTID=?";
+   protected String GET_USER_BY_CLIENTID = "SELECT USERID, PASSWD, CLIENTID FROM JMS_USERS WHERE CLIENTID=?";
 
    /** Get a user with the given user id */
-   private String GET_USER = "SELECT PASSWD, CLIENTID FROM JMS_USERS WHERE USERID=?";
+   protected String GET_USER = "SELECT PASSWD, CLIENTID FROM JMS_USERS WHERE USERID=?";
 
    /** Populate tables with initial data */
-   private List POPULATE_TABLES = new ArrayList();
+   protected List POPULATE_TABLES = new ArrayList();
 
    public ObjectName getConnectionManager()
    {
@@ -496,6 +495,8 @@
 
       Transaction threadTx;
 
+      boolean rollback = false;
+      
       Connection connection;
 
       HashSet statements = new HashSet();
@@ -561,14 +562,7 @@
 
       void setRollbackOnly() throws JMSException
       {
-         try
-         {
-            tm.setRollbackOnly();
-         }
-         catch (Exception e)
-         {
-            throw new SpyJMSException("Could not mark the transaction for rollback.", e);
-         }
+         rollback = true;
       }
 
       void addResultSet(ResultSet rs)
@@ -624,7 +618,7 @@
 
          try
          {
-            if (tm.getStatus() == Status.STATUS_MARKED_ROLLBACK)
+            if (rollback)
             {
                tm.rollback();
             }




More information about the jboss-cvs-commits mailing list