db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/odmg LocalTxManager.java TransactionTable.java
Date Sat, 18 Dec 2004 13:41:56 GMT
arminw      2004/12/18 05:41:56

  Modified:    src/java/org/apache/ojb/odmg LocalTxManager.java
  Removed:     src/java/org/apache/ojb/odmg TransactionTable.java
  Log:
  use class as inner class, remove unused class
  
  Revision  Changes    Path
  1.7       +78 -8     db-ojb/src/java/org/apache/ojb/odmg/LocalTxManager.java
  
  Index: LocalTxManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/LocalTxManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalTxManager.java	14 Nov 2004 09:37:20 -0000	1.6
  +++ LocalTxManager.java	18 Dec 2004 13:41:56 -0000	1.7
  @@ -1,9 +1,5 @@
   package org.apache.ojb.odmg;
   
  -import org.apache.ojb.broker.util.logging.Logger;
  -import org.apache.ojb.broker.util.logging.LoggerFactory;
  -import org.odmg.TransactionNotInProgressException;
  -
   /* Copyright 2002-2004 The Apache Software Foundation
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
  @@ -18,10 +14,22 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +
  +import java.util.Hashtable;
  +
  +import org.odmg.Transaction;
  +import org.odmg.TransactionNotInProgressException;
  +
  +/**
  + * In a non-appserver environment, without a transaction manager, we can
  + * safely associate the current ODMG transaction with the calling thread.
  + *
  + * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  + * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
  + * @version $Id$
  + */
   public class LocalTxManager implements OJBTxManager
   {
  -    private Logger log = LoggerFactory.getLogger(LocalTxManager.class);
  -
       /**
        * Internal table which provides mapping between threads and transactions.
        * This is required because a Thread can join a Transaction already in
  @@ -41,11 +49,12 @@
   
       /**
        * Returns the current transaction for the calling thread.
  -     * @throws org.odmg.TransactionNotInProgressException {@link org.odmg.TransactionNotInProgressException}
if no transaction was found.
  +     *
  +     * @throws org.odmg.TransactionNotInProgressException if no transaction was found.
        */
       public TransactionImpl getCurrentTransaction()
       {
  -        TransactionImpl tx = (TransactionImpl) tx_table.get(Thread.currentThread());
  +        TransactionImpl tx = tx_table.get(Thread.currentThread());
           if (tx == null)
           {
               throw new TransactionNotInProgressException(
  @@ -87,5 +96,66 @@
       	/**
       	 * no op
       	 */
  +    }
  +
  +
  +    //=======================================================
  +    // inner class
  +    //=======================================================
  +    /**
  +     * TransactionTable provides a mapping between the calling
  +     * thread and the Transaction it is currently using.
  +     * One thread can be joined with one transaction at
  +     * a certain point in time. But a thread can join with
  +     * different transactions subsequently.
  +     * This mapping from threads to Transactions is based on ODMG.
  +     *
  +     * @author Thomas Mahler & David Dixon-Peugh
  +     */
  +    static final class TransactionTable
  +    {
  +        /**
  +         * the internal Hashtable mapping Transactions to threads
  +         */
  +        private Hashtable m_table = new Hashtable();
  +
  +        /**
  +         * Creates new TransactionTable
  +         */
  +        public TransactionTable()
  +        {
  +        }
  +
  +        /**
  +         * Retreive a Transaction associated with a thread.
  +         *
  +         * @param key_thread The thread to lookup.
  +         * @return The transaction associated with the thread.
  +         */
  +        public TransactionImpl get(Thread key_thread)
  +        {
  +            return (TransactionImpl) m_table.get(key_thread);
  +        }
  +
  +        /**
  +         * Store the Thread/Transaction pair in the TransactionTable
  +         *
  +         * @param key_thread Thread that the transaction will be associated to
  +         * @param value_tx   Transaction to be associated with the thread
  +         */
  +        public void put(Thread key_thread, TransactionImpl value_tx)
  +        {
  +            m_table.put(key_thread, value_tx);
  +        }
  +
  +        /**
  +         * Remove the entry for the thread
  +         *
  +         * @param key_thread Thread to be removed.
  +         */
  +        public void remove(Thread key_thread)
  +        {
  +            m_table.remove(key_thread);
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message