You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2005/04/03 04:11:29 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerFactorySyncImpl.java

arminw      2005/04/02 18:11:29

  Modified:    src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
                        PersistenceBrokerFactorySyncImpl.java
  Log:
  minor changes, improve error handling
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.3   +16 -7     db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerFactorySyncImpl.java
  
  Index: PersistenceBrokerFactorySyncImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerFactorySyncImpl.java,v
  retrieving revision 1.7.2.2
  retrieving revision 1.7.2.3
  diff -u -r1.7.2.2 -r1.7.2.3
  --- PersistenceBrokerFactorySyncImpl.java	27 Nov 2004 23:46:32 -0000	1.7.2.2
  +++ PersistenceBrokerFactorySyncImpl.java	3 Apr 2005 02:11:29 -0000	1.7.2.3
  @@ -106,25 +106,27 @@
               throw new PBFactoryException("Can't create PB instance, failure while lookup" +
                       " running JTA transaction",e);
           }
  -        PersistenceBrokerSyncImpl result = null;
  +        PersistenceBrokerSyncImpl obtainedBroker = null;
  +        PersistenceBrokerSyncHandle result;
           if (tx != null)
           {
  -            result = txRegistry.findBroker(tx, pbKey);
  +            obtainedBroker = txRegistry.findBroker(tx, pbKey);
           }
   
  -        if(result == null || result.isClosed())
  +        if(obtainedBroker == null || obtainedBroker.isClosed())
           {
               // we have to lookup new PB instance with wrapped with handle
               // method #wrapRequestedBrokerInstance wraps the new instance
               // with a handle
  -            return super.createPersistenceBroker(pbKey);
  +            result = (PersistenceBrokerSyncHandle) super.createPersistenceBroker(pbKey);
           }
           else
           {
               // we found a PB instance that was already in use within the same JTA-tx
               // so we only return a new handle
  -            return new PersistenceBrokerSyncHandle(result);
  +            result = new PersistenceBrokerSyncHandle(obtainedBroker);
           }
  +        return result;
       }
   
       protected PersistenceBroker wrapBrokerWithPoolingHandle(PersistenceBroker broker, KeyedObjectPool pool)
  @@ -176,7 +178,14 @@
           }
           catch (Exception e)
           {
  -            throw new PBFactoryException("Error while try to participate in JTA transaction", e);
  +            if(e instanceof PBFactoryException)
  +            {
  +                throw (PBFactoryException) e;
  +            }
  +            else
  +            {
  +                throw new PBFactoryException("Error while try to participate in JTA transaction", e);
  +            }
           }
           return new PersistenceBrokerSyncHandle(pb);
       }
  
  
  

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