Author: ozeigermann
Date: Fri Jul 20 09:09:17 2007
New Revision: 558028

URL: http://svn.apache.org/viewvc?view=rev&rev=558028
Log:
Removed suspend/resume code as this is not applicable to our implementation. 
Might be reintroduced by an XA implementation later.

Added:
    
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
Modified:
    
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java

Modified: 
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java?view=diff&rev=558028&r1=558027&r2=558028
==============================================================================
--- 
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java
 (original)
+++ 
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java
 Fri Jul 20 09:09:17 2007
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.transaction;
 
-import java.util.HashSet;
-import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReadWriteLock;
 
@@ -27,7 +25,7 @@
 
 /**
  * Not thread-safe. FIXME: Should it be?
- * 
+ *  
  * @author olli
  *
  * @param <T>
@@ -35,10 +33,6 @@
 public abstract class AbstractTransactionalResourceManager<T extends 
AbstractTransactionalResourceManager.AbstractTxContext> implements 
TransactionalResourceManager {
     protected ThreadLocal<T> activeTx = new ThreadLocal<T>();
 
-    protected Set<T> activeTransactions = new HashSet<T>();
-
-    protected Set<T> suspendedTransactions = new HashSet<T>();
-
     protected abstract T createContext();
 
     /**
@@ -64,67 +58,6 @@
         return (txContext.isMarkedForRollback());
     }
 
-    /**
-     * Suspends the transaction associated to the current thread. I.e. the
-     * associated between the current thread and the transaction is deleted.
-     * This is useful when you want to continue the transaction in another
-     * thread later. Call [EMAIL PROTECTED] #resumeTransaction(TxContext)} - 
possibly in
-     * another thread than the current - to resume work on the transaction. 
<br>
-     * <br>
-     * <em>Caution:</em> When calling this method the returned identifier for
-     * the transaction is the only remaining reference to the transaction, so 
be
-     * sure to remember it or the transaction will be eventually deleted (and
-     * thereby rolled back) as garbage.
-     * 
-     * @return an identifier for the suspended transaction, will be needed to
-     *         later resume the transaction by
-     *         [EMAIL PROTECTED] #resumeTransaction(TxContext)}
-     * 
-     * @see #resumeTransaction(TxContext)
-     */
-    public T suspendTransaction() {
-        T txContext = getActiveTx();
-
-        if (txContext == null) {
-            throw new IllegalStateException("Active thread " + 
Thread.currentThread()
-                    + " not associated with a transaction!");
-        }
-
-        suspendedTransactions.add(txContext);
-        setActiveTx(null);
-        return txContext;
-    }
-
-    /**
-     * Resumes a transaction in the current thread that has previously been
-     * suspened by [EMAIL PROTECTED] #suspendTransaction()}.
-     * 
-     * @param suspendedTx
-     *            the identifier for the transaction to be resumed, delivered 
by
-     *            [EMAIL PROTECTED] #suspendTransaction()}
-     * 
-     * @see #suspendTransaction()
-     */
-    public void resumeTransaction(T suspendedTx) {
-        T txContext = getActiveTx();
-
-        if (txContext != null) {
-            throw new IllegalStateException("Active thread " + 
Thread.currentThread()
-                    + " already associated with a transaction!");
-        }
-
-        if (suspendedTx == null) {
-            throw new IllegalStateException("No transaction to resume!");
-        }
-
-        if (!suspendedTransactions.contains(suspendedTx)) {
-            throw new IllegalStateException("Transaction to resume needs to be 
suspended!");
-        }
-
-        suspendedTransactions.remove(txContext);
-        setActiveTx(suspendedTx);
-    }
-
     @Override
     public void startTransaction() {
         if (getActiveTx() != null) {
@@ -133,7 +66,6 @@
         }
         T txContent = createContext();
         setActiveTx(txContent);
-        activeTransactions.add(txContent);
 
     }
 
@@ -148,7 +80,6 @@
 
         txContext.dispose();
         setActiveTx(null);
-        activeTransactions.remove(txContext);
     }
 
     @Override

Added: 
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java?view=auto&rev=558028
==============================================================================
--- 
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
 (added)
+++ 
jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
 Fri Jul 20 09:09:17 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.transaction;
+
+
+/**
+ * Interface for something that makes up a transactional resource manager.
+ * 
+ */
+public interface TransactionalResourceManager {
+    /**
+     * TODO
+     * 
+     * @param mSecs
+     */
+    public void setTransactionTimeout(long mSecs);
+
+    /**
+     * Starts a new transaction and associates it with the current thread. All
+     * subsequent changes in the same thread made to the map are invisible from
+     * other threads until [EMAIL PROTECTED] #commitTransaction()} is called. 
Use
+     * [EMAIL PROTECTED] #rollbackTransaction()} to discard your changes. 
After calling
+     * either method there will be no transaction associated to the current
+     * thread any longer. <br>
+     * <br>
+     * <em>Caution:</em> Be careful to finally call one of those methods, as
+     * otherwise the transaction will lurk around for ever.
+     * 
+     * @see #commitTransaction()
+     * @see #rollbackTransaction()
+     */
+    public void startTransaction();
+
+
+    /**
+     * Discards all changes made in the current transaction and deletes the
+     * association between the current thread and the transaction.
+     * 
+     * @see #startTransaction()
+     * @see #commitTransaction()
+     */
+    public void rollbackTransaction();
+
+    /**
+     * Commits all changes made in the current transaction and deletes the
+     * association between the current thread and the transaction.
+     * 
+     * @see #startTransaction()
+     * @see #rollbackTransaction()
+     */
+    public void commitTransaction();
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to