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 PBCapsule.java
Date Sat, 31 Dec 2005 18:29:11 GMT
arminw      2005/12/31 10:29:11

  Modified:    src/java/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        PBCapsule.java
  Log:
  fix OJB-85, use this class only for read operations
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.6.2.2   +17 -18    db-ojb/src/java/org/apache/ojb/odmg/PBCapsule.java
  
  Index: PBCapsule.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/PBCapsule.java,v
  retrieving revision 1.6.2.1
  retrieving revision 1.6.2.2
  diff -u -r1.6.2.1 -r1.6.2.2
  --- PBCapsule.java	21 Dec 2005 22:29:21 -0000	1.6.2.1
  +++ PBCapsule.java	31 Dec 2005 18:29:11 -0000	1.6.2.2
  @@ -24,6 +24,17 @@
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.odmg.Transaction;
   
  +/**
  + * ONLY VALID FOR READ OPERATIONS! Capsulates the way to obtain
  + * PersistenceBroker instances when a odmg-tx is running or
  + * not - Do not forget to call the destroy() method after use.
  + * When a transaction was found we use the PersistenceBroker instance
  + * shipped with the Transaction (via {@link HasBroker}), else we try
  + * to obtain a broker using the given {@link org.apache.ojb.broker.PBKey}
  + * directly from the {@link org.apache.ojb.broker.PersistenceBrokerFactory}.
  + *
  + * @version $Id$
  + */
   public final class PBCapsule
   {
       private static Logger log = LoggerFactory.getLogger(PBCapsule.class);
  @@ -32,7 +43,7 @@
       PBKey pbKey;
       Transaction tx;
       boolean needsTxCommit = false;
  -    boolean needsPBCommit = false;
  +    boolean needsClose = false;
       boolean isIlleagal = false;
   
       public PBCapsule(final PBKey pbKey, final Transaction tx)
  @@ -60,12 +71,7 @@
                   log.debug("No running transaction found, try to get " +
                           "PersistenceBroker instance via PBKey " + pbKey);
               broker = obtainBroker();
  -            // begin tx on the PB instance
  -            if (!broker.isInTransaction())
  -            {
  -                broker.beginTransaction();
  -                needsPBCommit = true;
  -            }
  +            needsClose = true;
           }
           else
           {
  @@ -88,21 +94,14 @@
               if (log.isDebugEnabled()) log.debug("Indicated to commit tx");
               tx.commit();
           }
  -        else if (needsPBCommit)
  +        else if (needsClose)
           {
  -            if (log.isDebugEnabled()) log.debug("Indicated to commit PersistenceBroker");
  -            try
  -            {
  -                broker.commitTransaction();
  -            }
  -            finally
  -            {
  -                if (broker != null) broker.close();
  -            }
  +            if (log.isDebugEnabled()) log.debug("Indicated to close PersistenceBroker");
  +            if (broker != null) broker.close();
           }
           isIlleagal = true;
           needsTxCommit = false;
  -        needsPBCommit = false;
  +        needsClose = false;
       }
   
       /**
  
  
  

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