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/broker/accesslayer ConnectionManagerIF.java ConnectionManagerImpl.java
Date Tue, 28 Oct 2003 14:12:44 GMT
arminw      2003/10/28 06:12:44

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ConnectionManagerIF.java ConnectionManagerImpl.java
  Log:
  - update javadoc
  - minor intern changes
  
  Revision  Changes    Path
  1.11      +2 -2      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java
  
  Index: ConnectionManagerIF.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ConnectionManagerIF.java	30 Jan 2003 15:12:57 -0000	1.10
  +++ ConnectionManagerIF.java	28 Oct 2003 14:12:44 -0000	1.11
  @@ -116,8 +116,8 @@
       public void releaseConnection();
   
       /**
  -     * Sets the batch mode on or off.
  -     * @param the batch mode.
  +     * Sets the batch mode on (<code>true</code>) or
  +     * off (<code>false</code>).
        */
       public void setBatchMode(boolean mode);
   
  
  
  
  1.8       +29 -22    db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java
  
  Index: ConnectionManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionManagerImpl.java	6 Jun 2003 20:12:54 -0000	1.7
  +++ ConnectionManagerImpl.java	28 Oct 2003 14:12:44 -0000	1.8
  @@ -60,6 +60,7 @@
   import org.apache.ojb.broker.TransactionAbortedException;
   import org.apache.ojb.broker.TransactionInProgressException;
   import org.apache.ojb.broker.TransactionNotInProgressException;
  +import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
   import org.apache.ojb.broker.metadata.MetadataManager;
   import org.apache.ojb.broker.platforms.Platform;
  @@ -74,6 +75,7 @@
   /**
    * Manages Connection ressources.
    *
  + * @see ConnectionManagerIF
    * @author Thomas Mahler
    * @version $Id$
    */
  @@ -118,11 +120,11 @@
       /**
        * Returns the underlying connection, requested at the
        * {@link org.apache.ojb.broker.accesslayer.ConnectionFactory}.
  -     * PB.beginTransaction() opens a single jdbc connection via 
  +     * PB.beginTransaction() opens a single jdbc connection via
   	 * serviceConnectionManager().localBegin().
  -	 * If you call ask serviceConnectionManager().getConnection() later 
  +	 * If you call ask serviceConnectionManager().getConnection() later
   	 * it returns the already opened connection.
  -	 * the PB instance will close the connection during 
  +	 * the PB instance will close the connection during
   	 * commitTransaction() or abortTransaction().
        */
       public Connection getConnection() throws LookupException
  @@ -164,7 +166,6 @@
        */
       public void localBegin()
       {
  -//        if (log.isDebugEnabled()) log.debug("begin was called");
           if (this.isInLocalTransaction)
           {
               throw new TransactionInProgressException("Connection is already in transaction");
  @@ -181,6 +182,7 @@
                */
               throw new PersistenceBrokerException(e.getMessage(), e);
           }
  +        if (log.isDebugEnabled()) log.debug("localBegin was called for con " + connection);
           if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE)
           {
               if (log.isDebugEnabled()) log.debug("Try to change autoCommit state to 'false'");
  @@ -194,7 +196,7 @@
        */
       public void localCommit()
       {
  -//        if (log.isDebugEnabled()) log.debug("commit was called");
  +        if (log.isDebugEnabled()) log.debug("commit was called");
           if (!this.isInLocalTransaction)
           {
               throw new TransactionNotInProgressException("Not in transaction, call begin()
before commit()");
  @@ -219,11 +221,7 @@
           finally
           {
               this.isInLocalTransaction = false;
  -            if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
&&
  -                    originalAutoCommitState == true)
  -            {
  -                platform.changeAutoCommitState(jcd, con, true);
  -            }
  +            restoreAutoCommitState();
               this.releaseConnection();
           }
       }
  @@ -257,19 +255,28 @@
           }
           finally
           {
  -            try
  -            {
  -                if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
&&
  -                        originalAutoCommitState == true && !con.isClosed())
  -                {
  -                    platform.changeAutoCommitState(jcd, con, true);
  -                }
  -            }
  -            catch (SQLException e)
  +            restoreAutoCommitState();
  +            this.releaseConnection();
  +        }
  +    }
  +
  +    /**
  +     * Reset autoCommit state.
  +     */
  +    protected void restoreAutoCommitState()
  +    {
  +        try
  +        {
  +            if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
  +                    && originalAutoCommitState == true && con != null &&
!con.isClosed())
               {
  -                log.info("Could not change autoCommit state while rollback was called:
"+e.getMessage());
  +                platform.changeAutoCommitState(jcd, con, true);
               }
  -            this.releaseConnection();
  +        }
  +        catch (SQLException e)
  +        {
  +            // should never be reached
  +            throw new OJBRuntimeException("Restore of connection autocommit state failed",
e);
           }
       }
   
  
  
  

---------------------------------------------------------------------
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