db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/odmg TransactionAbortedExceptionOJB.java TransactionImpl.java ObjectEnvelopeTable.java J2EETransactionImpl.java
Date Sat, 26 Apr 2003 09:13:35 GMT
thma        2003/04/26 02:13:35

  Modified:    src/java/org/apache/ojb/odmg TransactionImpl.java
                        ObjectEnvelopeTable.java J2EETransactionImpl.java
  Added:       src/java/org/apache/ojb/odmg
                        TransactionAbortedExceptionOJB.java
  Log:
  By providing a new subclass to org.odmg.TransactionAbortedexception we are now able to throw
nested exceptions to the user. This my be helpful in identifying database related problems.
Credits to Charles Anthony.
  
  Revision  Changes    Path
  1.41      +5 -5      db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- TransactionImpl.java	18 Apr 2003 17:38:37 -0000	1.40
  +++ TransactionImpl.java	26 Apr 2003 09:13:35 -0000	1.41
  @@ -186,7 +186,7 @@
           if (curDB == null || !curDB.isOpen())
           {
               log.error("Transaction without a associated open Database.");
  -            throw new TransactionAbortedException(
  +            throw new TransactionAbortedExceptionOJB(
                       "No open database found. Open the database before handling transactions");
           }
       }
  @@ -480,7 +480,7 @@
               else
               {
                   log.error(t);
  -                throw new TransactionAbortedException(t.getMessage());
  +                throw new TransactionAbortedExceptionOJB(t);
               }
           }
       }
  @@ -545,7 +545,7 @@
               prepare();
               // Never commit transaction that has been marked for rollback
               if (m_txStatus == Status.STATUS_MARKED_ROLLBACK)
  -                throw new TransactionAbortedException("persist.markedRollback");
  +                throw new TransactionAbortedExceptionOJB("persist.markedRollback");
               if (m_txStatus != Status.STATUS_PREPARED)
                   throw new IllegalStateException("persist.missingPrepare");
   
  @@ -586,7 +586,7 @@
       protected boolean prepare() throws TransactionAbortedException, LockNotGrantedException
       {
           if (m_txStatus == Status.STATUS_MARKED_ROLLBACK)
  -            throw new TransactionAbortedException("persist.markedRollback");
  +            throw new TransactionAbortedExceptionOJB("persist.markedRollback");
           if (m_txStatus != Status.STATUS_ACTIVE)
               throw new IllegalStateException("persist.noTransaction");
           try
  
  
  
  1.24      +4 -4      db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java
  
  Index: ObjectEnvelopeTable.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ObjectEnvelopeTable.java	18 Apr 2003 17:38:37 -0000	1.23
  +++ ObjectEnvelopeTable.java	26 Apr 2003 09:13:35 -0000	1.24
  @@ -201,10 +201,10 @@
   	            // PB OptimisticLockException should be clearly signalled to the user
               	throw new LockNotGrantedException(t.getMessage());
               }
  -			else
  -			{
  -            	throw new TransactionAbortedException(t.getMessage());
  -			}
  +			      else
  +            {
  +                    throw new TransactionAbortedExceptionOJB(t);
  +            }
           }
           finally
           {
  
  
  
  1.19      +2 -2      db-ojb/src/java/org/apache/ojb/odmg/J2EETransactionImpl.java
  
  Index: J2EETransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/J2EETransactionImpl.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- J2EETransactionImpl.java	9 Apr 2003 08:17:41 -0000	1.18
  +++ J2EETransactionImpl.java	26 Apr 2003 09:13:35 -0000	1.19
  @@ -230,6 +230,6 @@
               setInExternTransaction(false);
           }
           //Hack, throw this Exception to notify client of abort, without changing API
  -        throw new TransactionAbortedException("Internal ODMG transaction was aborted");
  +        throw new TransactionAbortedExceptionOJB("Internal ODMG transaction was aborted");
       }
   }
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/odmg/TransactionAbortedExceptionOJB.java
  
  Index: TransactionAbortedExceptionOJB.java
  ===================================================================
  package org.apache.ojb.odmg;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.odmg.TransactionAbortedException;
  
  /**
   * This specialised exception allows us to capture the cause of an 
   * ODMG TransactionAbortedException. This, in turn,
   * gives the "catcher" of the exception the ability to take different 
   * courses of action dependent upon why the transaction was aborted. <p>
   * This exception has been created as a subclass of 
   * org.odmg.TransactionAbortedException so that we don't
   * <ul>
   * <li>Modify the ODMG exception - as it is defined by the ODMG spec
   * <li>Break the spec by throwing a non ODMG exception
   * </ul>
   *
   * @author Charles Anthony
   */
  public class TransactionAbortedExceptionOJB extends TransactionAbortedException
  {
    /**
     * The cause of a TransactionAbortedException
     */
    private Throwable cause;
  
    public TransactionAbortedExceptionOJB()
    {
      super();
    }
  
    public TransactionAbortedExceptionOJB(String msg)
    {
      super(msg);
    }
  
    public TransactionAbortedExceptionOJB(Throwable cause)
    {
      this.cause = cause;
    }
  
    /**
     * Returns the cause of the exception. May be null.
     * @return
     */
    public Throwable getCause()
    {
      return cause;
    }
  }
  
  
  

Mime
View raw message