db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/odmg TransactionImpl.java J2EETransactionImpl.java NarrowTransaction.java
Date Fri, 20 Dec 2002 02:13:40 GMT
mattbaird    2002/12/19 18:13:39

  Modified:    src/java/org/apache/ojb/odmg TransactionImpl.java
                        J2EETransactionImpl.java NarrowTransaction.java
  Log:
  enhancements to J2EE mode to handle connection being rolled back.
  
  Revision  Changes    Path
  1.31      +8 -8      jakarta-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- TransactionImpl.java	14 Dec 2002 15:01:57 -0000	1.30
  +++ TransactionImpl.java	20 Dec 2002 02:13:39 -0000	1.31
  @@ -55,13 +55,7 @@
    */
   
   
  -import org.apache.ojb.broker.Identity;
  -import org.apache.ojb.broker.ManageableCollection;
  -import org.apache.ojb.broker.PBFactoryException;
  -import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.broker.PersistenceBrokerException;
  -import org.apache.ojb.broker.PersistenceBrokerFactory;
  -import org.apache.ojb.broker.VirtualProxy;
  +import org.apache.ojb.broker.*;
   import org.apache.ojb.broker.accesslayer.IndirectionHandler;
   import org.apache.ojb.broker.accesslayer.MaterializationListener;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  @@ -578,6 +572,12 @@
               m_txStatus = Status.STATUS_MARKED_ROLLBACK;
               throw e;
           }
  +		catch (PersistenceBrokerSQLException pbse)
  +		{
  +			log.error("Could not prepare for commit: " + pbse.getMessage());
  +			m_txStatus = Status.STATUS_MARKED_ROLLBACK;
  +			throw pbse;
  +		}
           return true;
       }
   
  
  
  
  1.14      +15 -5     jakarta-ojb/src/java/org/apache/ojb/odmg/J2EETransactionImpl.java
  
  Index: J2EETransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/J2EETransactionImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- J2EETransactionImpl.java	8 Nov 2002 13:29:30 -0000	1.13
  +++ J2EETransactionImpl.java	20 Dec 2002 02:13:39 -0000	1.14
  @@ -138,22 +138,30 @@
           {
               try
               {
  -                this.prepare();
  -                commit();
  +				JTATxManager mgr = (JTATxManager)TxManagerFactory.instance();
  +				if (mgr.getJTATransaction().getStatus() == Status.STATUS_MARKED_ROLLBACK)
  +				{
  +					doAbort();				
  +				}
  +				else
  +				{
  +					this.prepare();
  +					commit();
  +				}
                   /*
                    * MBAIRD: hack to get around the lack of swizzling.
                    */
  -                getBroker().clearCache();
  +                //getBroker().clearCache();
               }
               catch (Throwable t)
               {
  -
  +				TxManagerFactory.instance().abortExternalTx(this);
  +				doAbort();
                   if (log.isDebugEnabled())
                   {
                       log.debug(t.getMessage());
                       t.printStackTrace();
                   }
  -                throw new OJBRuntimeException("beforeCompletion failed in J2EETransactionImpl",
t);
               }
               finally
               {
  @@ -185,6 +193,7 @@
           }
           catch (Exception ex)
           {
  +			TxManagerFactory.instance().abortExternalTx(this);
               // We should not reach this block
               log.warn("!! Error while commit PB-Instance, system could be in a inconsistent
condition !!");
               if (log.isDebugEnabled())
  @@ -193,6 +202,7 @@
                   ex.printStackTrace();
               }
               doAbort();
  +			doClose();
               throw new OJBRuntimeException("Unexpected error occured while commit PB", ex);
           }
       }
  
  
  
  1.3       +8 -0      jakarta-ojb/src/java/org/apache/ojb/odmg/NarrowTransaction.java
  
  Index: NarrowTransaction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/NarrowTransaction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NarrowTransaction.java	25 Sep 2002 14:49:28 -0000	1.2
  +++ NarrowTransaction.java	20 Dec 2002 02:13:39 -0000	1.3
  @@ -3,6 +3,8 @@
   import org.odmg.Transaction;
   import org.odmg.LockNotGrantedException;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.Identity;
  +import org.apache.ojb.broker.PersistenceBrokerException;
   
   /**
    *
  @@ -104,4 +106,10 @@
       {
           return tx.tryLock(obj, lockMode);
       }
  +	
  +	public Object getObjectByIdentity(Identity id)
  +			throws PersistenceBrokerException
  +	{
  +		return ((TransactionImpl)tx).getObjectByIdentity(id);
  +	}
   }
  
  
  

Mime
View raw message