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 DatabaseImpl.java ImplementationImpl.java NamedRootsMap.java ObjectEnvelope.java ObjectEnvelopeOrdering.java ObjectEnvelopeTable.java RuntimeObject.java TransactionAbortedExceptionOJB.java TransactionImpl.java
Date Tue, 03 May 2005 17:09:05 GMT
arminw      2005/05/03 10:09:05

  Modified:    src/java/org/apache/ojb/odmg/collections Tag:
                        OJB_1_0_RELEASE DListEntry.java DListImpl.java
                        DListIterator.java DMapImpl.java DSetImpl.java
               src/java/org/apache/ojb/odmg/oql Tag: OJB_1_0_RELEASE
                        OQLQueryImpl.java
               src/java/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        DatabaseImpl.java ImplementationImpl.java
                        NamedRootsMap.java ObjectEnvelope.java
                        ObjectEnvelopeOrdering.java
                        ObjectEnvelopeTable.java RuntimeObject.java
                        TransactionAbortedExceptionOJB.java
                        TransactionImpl.java
  Log:
  use RuntimeObject for all internal calls
  fix bug, objects were not linked
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.25.2.2  +2 -3      db-ojb/src/java/org/apache/ojb/odmg/collections/DListEntry.java
  
  Index: DListEntry.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DListEntry.java,v
  retrieving revision 1.25.2.1
  retrieving revision 1.25.2.2
  diff -u -r1.25.2.1 -r1.25.2.2
  --- DListEntry.java	3 Apr 2005 02:38:45 -0000	1.25.2.1
  +++ DListEntry.java	3 May 2005 17:09:04 -0000	1.25.2.2
  @@ -149,8 +149,7 @@
                   if(realSubject != null)
                   {
                       RuntimeObject rt = new RuntimeObject(realSubject, tx, false);
  -                    tx.lockAndRegister(rt, Transaction.WRITE, true);
  -                    tx.lockAndRegisterCleanup();
  +                    tx.lockAndRegister(rt, Transaction.READ, true, tx.getRegistrationList());
                   }
               }
               else
  
  
  
  1.27.2.3  +6 -4      db-ojb/src/java/org/apache/ojb/odmg/collections/DListImpl.java
  
  Index: DListImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DListImpl.java,v
  retrieving revision 1.27.2.2
  retrieving revision 1.27.2.3
  diff -u -r1.27.2.2 -r1.27.2.3
  --- DListImpl.java	3 Apr 2005 02:38:45 -0000	1.27.2.2
  +++ DListImpl.java	3 May 2005 17:09:04 -0000	1.27.2.3
  @@ -167,12 +167,14 @@
           if (checkForOpenTransaction(tx))
           {
               RuntimeObject rt = new RuntimeObject(this, tx);
  -            tx.lockAndRegister(rt, Transaction.WRITE, false);
  +            List regList = tx.getRegistrationList();
  +            tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
   
  -            tx.lock(element, Transaction.READ);
  +            rt = new RuntimeObject(element, tx);
  +            tx.lockAndRegister(rt, Transaction.READ, true, regList);
   
               rt = new RuntimeObject(entry, tx, true);
  -            tx.lockAndRegister(rt, Transaction.WRITE, false);
  +            tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
           }
   
           // changing the position markers of entries:
  
  
  
  1.8.2.2   +4 -2      db-ojb/src/java/org/apache/ojb/odmg/collections/DListIterator.java
  
  Index: DListIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DListIterator.java,v
  retrieving revision 1.8.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- DListIterator.java	3 Apr 2005 02:38:45 -0000	1.8.2.1
  +++ DListIterator.java	3 May 2005 17:09:04 -0000	1.8.2.2
  @@ -18,6 +18,7 @@
   import java.util.ListIterator;
   
   import org.apache.ojb.odmg.TransactionImpl;
  +import org.apache.ojb.odmg.RuntimeObject;
   import org.odmg.Transaction;
   
   /**
  @@ -61,7 +62,8 @@
           TransactionImpl tx = dlist.getTransaction();
           if (tx != null)
           {
  -            tx.lock(entry, Transaction.WRITE);
  +            RuntimeObject rt = new RuntimeObject(entry, tx, true);
  +            tx.lockAndRegister(rt, Transaction.WRITE, true, tx.getRegistrationList());
           }
       }
   
  
  
  
  1.21.2.2  +10 -5     db-ojb/src/java/org/apache/ojb/odmg/collections/DMapImpl.java
  
  Index: DMapImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DMapImpl.java,v
  retrieving revision 1.21.2.1
  retrieving revision 1.21.2.2
  diff -u -r1.21.2.1 -r1.21.2.2
  --- DMapImpl.java	3 Apr 2005 02:38:45 -0000	1.21.2.1
  +++ DMapImpl.java	3 May 2005 17:09:04 -0000	1.21.2.2
  @@ -19,6 +19,7 @@
   import java.util.AbstractMap;
   import java.util.Iterator;
   import java.util.Set;
  +import java.util.List;
   
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBroker;
  @@ -147,14 +148,18 @@
               TransactionImpl tx = getTransaction();
               if ((tx != null) && (tx.isOpen()))
               {
  +                List regList = tx.getRegistrationList();
                   RuntimeObject rt = new RuntimeObject(this, tx);
  -                tx.lockAndRegister(rt, Transaction.WRITE, false);
  +                tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
   
  -                tx.lock(key, Transaction.READ);
  -                tx.lock(value, Transaction.READ);
  +                rt = new RuntimeObject(key, tx);
  +                tx.lockAndRegister(rt, Transaction.READ, true, regList);
  +
  +                rt = new RuntimeObject(value, tx);
  +                tx.lockAndRegister(rt, Transaction.READ, true, regList);
   
                   rt = new RuntimeObject(entry, tx, true);
  -                tx.lockAndRegister(rt, Transaction.WRITE, false);
  +                tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
               }
               return null;
           }
  
  
  
  1.21.2.3  +5 -3      db-ojb/src/java/org/apache/ojb/odmg/collections/DSetImpl.java
  
  Index: DSetImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DSetImpl.java,v
  retrieving revision 1.21.2.2
  retrieving revision 1.21.2.3
  diff -u -r1.21.2.2 -r1.21.2.3
  --- DSetImpl.java	3 Apr 2005 02:38:45 -0000	1.21.2.2
  +++ DSetImpl.java	3 May 2005 17:09:04 -0000	1.21.2.3
  @@ -155,13 +155,15 @@
               TransactionImpl tx = getTransaction();
               if ((tx != null) && (tx.isOpen()))
               {
  +                List regList = tx.getRegistrationList();
                   RuntimeObject rt = new RuntimeObject(this, tx);
  -                tx.lockAndRegister(rt, Transaction.WRITE, false);
  +                tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
   
  -                tx.lock(o, Transaction.READ);
  +                rt = new RuntimeObject(o, tx);
  +                tx.lockAndRegister(rt, Transaction.READ, true, regList);
   
                   rt = new RuntimeObject(entry, tx, true);
  -                tx.lockAndRegister(rt, Transaction.WRITE, false);
  +                tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
               }
               return true;
           }
  
  
  
  No                   revision
  No                   revision
  1.18.2.3  +5 -3      db-ojb/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java
  
  Index: OQLQueryImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java,v
  retrieving revision 1.18.2.2
  retrieving revision 1.18.2.3
  diff -u -r1.18.2.2 -r1.18.2.3
  --- OQLQueryImpl.java	3 Apr 2005 02:38:45 -0000	1.18.2.2
  +++ OQLQueryImpl.java	3 May 2005 17:09:04 -0000	1.18.2.3
  @@ -20,6 +20,7 @@
   import java.util.Iterator;
   import java.util.ListIterator;
   import java.util.Vector;
  +import java.util.List;
   
   import antlr.RecognitionException;
   import antlr.TokenStreamException;
  @@ -322,16 +323,17 @@
               Object toBeLocked = null;
               try
               {
  +                List regList = tx.getRegistrationList();
                   while (iter.hasNext())
                   {
                       toBeLocked = iter.next();
                       RuntimeObject rt = new RuntimeObject(toBeLocked, tx, false);
  -                    tx.lockAndRegister(rt, Transaction.WRITE, true);
  +                    tx.lockAndRegister(rt, Transaction.WRITE, true, regList);
                   }
               }
               finally
               {
  -                tx.lockAndRegisterCleanup();
  +                tx.clearRegistrationList();
               }
           }
       }
  
  
  
  No                   revision
  No                   revision
  1.26.2.5  +5 -16     db-ojb/src/java/org/apache/ojb/odmg/DatabaseImpl.java
  
  Index: DatabaseImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/DatabaseImpl.java,v
  retrieving revision 1.26.2.4
  retrieving revision 1.26.2.5
  diff -u -r1.26.2.4 -r1.26.2.5
  --- DatabaseImpl.java	3 Apr 2005 02:38:45 -0000	1.26.2.4
  +++ DatabaseImpl.java	3 May 2005 17:09:04 -0000	1.26.2.5
  @@ -281,7 +281,6 @@
           /**
            * Is DB open? ODMG 3.0 says it has to be to call makePersistent.
            */
  -
           if (!this.isOpen())
           {
               throw new DatabaseClosedException("Database is not open");
  @@ -295,15 +294,6 @@
               throw new TransactionNotInProgressException("No transaction in progress, cannot
persist");
           }
   
  -//        RuntimeObject rt;
  -//        if(odmg.isSafeMode())
  -//        {
  -//            rt = new RuntimeObject(object, getTransaction());
  -//        }
  -//        else
  -//        {
  -//            rt = new RuntimeObject(object, getTransaction(), true);
  -//        }
           RuntimeObject rt = new RuntimeObject(object, getTransaction());
           makePersistent(rt);
       }
  @@ -313,14 +303,13 @@
           TransactionImpl tx = getTransaction();
           try
           {
  -            tx.lockAndRegister(rt, Transaction.WRITE, false);
  +            tx.lockAndRegister(rt, Transaction.WRITE, false, tx.getRegistrationList());
               tx.markPersistent(rt);
           }
           catch (org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException ex)
           {
  -            log.error("Persistence object failed: " + rt.getObj(), ex);
  -            throw new org.odmg.ClassNotPersistenceCapableException(
  -                    ex.getMessage());
  +            log.error("Can't persist object: " + rt.getIdentity(), ex);
  +            throw new org.odmg.ClassNotPersistenceCapableException(ex.getMessage());
           }
       }
   
  @@ -346,7 +335,7 @@
           {
               throw new TransactionNotInProgressException("No transaction in progress, cannot
delete persistent");
           }
  -        tx.lockAndRegister(new RuntimeObject(object, tx), Transaction.WRITE, false);
  +        tx.lockAndRegister(new RuntimeObject(object, tx), Transaction.WRITE, false, tx.getRegistrationList());
           tx.markDelete(object);
       }
   }
  
  
  
  1.1.2.8   +17 -16    db-ojb/src/java/org/apache/ojb/odmg/ImplementationImpl.java
  
  Index: ImplementationImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ImplementationImpl.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- ImplementationImpl.java	3 Apr 2005 02:38:45 -0000	1.1.2.7
  +++ ImplementationImpl.java	3 May 2005 17:09:04 -0000	1.1.2.8
  @@ -30,6 +30,7 @@
   import org.apache.ojb.odmg.oql.OQLQueryImpl;
   import org.apache.ojb.odmg.locking.LockManager;
   import org.apache.ojb.odmg.locking.LockManagerFactory;
  +import org.apache.commons.lang.SerializationUtils;
   import org.odmg.DArray;
   import org.odmg.DBag;
   import org.odmg.DList;
  @@ -66,7 +67,6 @@
       private Class oqlCollectionClass;
       private boolean impliciteWriteLocks;
       private boolean implicitLocking;
  -//    private boolean safeMode;
       protected boolean cascadingDeleteOnetoOne;
       protected boolean cascadingDeleteOnetoN;
       protected boolean cascadingDeleteMtoN;
  @@ -85,7 +85,6 @@
           cascadingDeleteOnetoOne = conf.getBoolean("cascadingDeleteOneToOne", false);
           cascadingDeleteOnetoN = conf.getBoolean("cascadingDeleteOneToN", false);
           cascadingDeleteMtoN = conf.getBoolean("cascadingDeleteMToN", false);
  -//        safeMode = conf.getBoolean("safeMode", true);
           oqlCollectionClass = conf.getClass("OqlCollectionClass", ManageableArrayList.class);
           impliciteWriteLocks = ((OdmgConfiguration)conf).lockAssociationAsWrites();
           implicitLocking = ((OdmgConfiguration)conf).useImplicitLocking();
  @@ -299,7 +298,7 @@
           }
   
           oid = new Identity(obj, broker);
  -        return new String(oid.serialize());
  +        return new String(SerializationUtils.serialize(oid));
       }
   
       /**
  @@ -343,6 +342,12 @@
        * turning of implicit locking may improve performance but requires
        * additional care to make sure all changed objects are properly
        * registered to the transaction.
  +     * <br/>
  +     * [In future versions this method will set the global used
  +     * implicite locking property. The deprecated flag is set to indicate
  +     * the upcoming change in method behavior. Currently it's not possible
  +     * to change the global property specified in OJB.properties file at
  +     * runtime, only per Transaction the property can be changed]
        *
        * @deprecated use {@link TransactionExt#setImplicitLocking(boolean)} instead.
        * @param value if set to true implicit locking is enabled,
  @@ -351,13 +356,19 @@
   	public void setImplicitLocking(boolean value)
   	{
   		((TransactionExt)currentTransaction()).setImplicitLocking(value);
  +        // this.implicitLocking = value;
   	}
   
       /**
        * Returns <em>true</em> if implicit locking is enabled
  -     * for this {@link org.odmg.Implementation} instance.
  +     * for this {@link org.odmg.Implementation} instance, else <em>false</em>.
  +     * <br/>
  +     * Important: The returned value is the global used setting for all
  +     * {@link org.odmg.Transaction#lock(Object, int)} calls. Nevertheless it
  +     * is possible to set this value at runtime for the current used {@link org.odmg.Transaction}
  +     * using {@link TransactionExt#setImplicitLocking(boolean)}.
        *
  -     * @deprecated use {@link TransactionExt#isImplicitLocking()} instead.
  +     * @see TransactionExt#isImplicitLocking()
        */
       boolean isImplicitLocking()
       {
  @@ -395,14 +406,4 @@
       {
           return impliciteWriteLocks;
       }
  -
  -//    public boolean isSafeMode()
  -//    {
  -//        return safeMode;
  -//    }
  -//
  -//    public void setSafeMode(boolean safeMode)
  -//    {
  -//        this.safeMode = safeMode;
  -//    }
   }
  
  
  
  1.12.2.2  +9 -7      db-ojb/src/java/org/apache/ojb/odmg/NamedRootsMap.java
  
  Index: NamedRootsMap.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/NamedRootsMap.java,v
  retrieving revision 1.12.2.1
  retrieving revision 1.12.2.2
  diff -u -r1.12.2.1 -r1.12.2.2
  --- NamedRootsMap.java	3 Apr 2005 02:38:45 -0000	1.12.2.1
  +++ NamedRootsMap.java	3 May 2005 17:09:04 -0000	1.12.2.2
  @@ -180,13 +180,14 @@
               if(obj instanceof Identity)
               {
                   Identity objectIdentity = (Identity) obj;
  -                PersistenceBroker broker = tx.getBroker();
  -                result = broker.getObjectByIdentity(objectIdentity);
  -                // lock the object
  -                tx.lockAndRegister(new RuntimeObject(result, objectIdentity, tx, false),
Transaction.READ, false);
  +                result = tx.getBroker().getObjectByIdentity(objectIdentity);
  +                // lock the persistance capable object
  +                RuntimeObject rt = new RuntimeObject(result, objectIdentity, tx, false);
  +                tx.lockAndRegister(rt, Transaction.READ, false, tx.getRegistrationList());
               }
               else
               {
  +                // nothing else to do
                   result = obj;
               }
           }
  @@ -230,12 +231,13 @@
           else
           {
               RuntimeObject rt = new RuntimeObject(object, tx);
  -            // if the object is already persistet, chack for read lock to make sure
  +            // if the object is already persistet, check for read
  +            // lock to make sure
               // that the used object is a valid version
               // else persist the specified named object
               if(!rt.isNew())
               {
  -                tx.lockAndRegister(rt, Transaction.READ, false);
  +                tx.lockAndRegister(rt, Transaction.READ, false, tx.getRegistrationList());
               }
               else
               {
  
  
  
  1.32.2.12 +2 -2      db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java
  
  Index: ObjectEnvelope.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java,v
  retrieving revision 1.32.2.11
  retrieving revision 1.32.2.12
  diff -u -r1.32.2.11 -r1.32.2.12
  --- ObjectEnvelope.java	3 Apr 2005 11:25:19 -0000	1.32.2.11
  +++ ObjectEnvelope.java	3 May 2005 17:09:04 -0000	1.32.2.12
  @@ -585,7 +585,7 @@
                               if(oe == null)
                               {
                                   RuntimeObject rt = new RuntimeObject(newEh.value, getTx());
  -                                getTx().lockAndRegister(rt, TransactionExt.READ, false);
  +                                getTx().lockAndRegister(rt, TransactionExt.READ, false,
getTx().getRegistrationList());
                               }
                               // in any case we need to link the main object
                               addLinkOneToOne(rds, false);
  @@ -694,7 +694,7 @@
               if ((oldRefs == null) || !oldRefs.containsKey(newOid))
               {
                   ObjectEnvelope mod = buffer.getByIdentity(newOid);
  -                if(mod == null) mod = buffer.get(newObj, true);
  +                if(mod == null) mod = buffer.get(newOid, newObj, true);
                   // if the object was deleted in an previous action, mark as new
                   // to avoid deletion, else mark object as dirty to assign the FK of
                   // the main object
  
  
  
  1.1.2.4   +36 -9     db-ojb/src/java/org/apache/ojb/odmg/Attic/ObjectEnvelopeOrdering.java
  
  Index: ObjectEnvelopeOrdering.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/Attic/ObjectEnvelopeOrdering.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ObjectEnvelopeOrdering.java	7 Feb 2005 20:42:42 -0000	1.1.2.3
  +++ ObjectEnvelopeOrdering.java	3 May 2005 17:09:04 -0000	1.1.2.4
  @@ -21,8 +21,9 @@
   import java.util.List;
   import java.util.Map;
   
  +import org.apache.commons.lang.ArrayUtils;
  +import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.ojb.broker.Identity;
  -import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.core.proxy.ProxyHelper;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
  @@ -79,12 +80,12 @@
   {
       private static final int CONCRETE_EDGE_WEIGHT = 2;
       private static final int POTENTIAL_EDGE_WEIGHT = 1;
  +    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
   
       private static Logger log = LoggerFactory.getLogger(ObjectEnvelopeOrdering.class);
   
       private List originalOrder;
       private Map envelopes;
  -    private TransactionImpl transaction;
   
       private Vertex[] vertices;
       private Map edgeMap;
  @@ -99,11 +100,10 @@
        * @param envelopes a map with ObjectEnvelope-s with their respective
        *      Identity-s as key
        */
  -    public ObjectEnvelopeOrdering(TransactionImpl transaction, List originalOrder, Map
envelopes)
  +    public ObjectEnvelopeOrdering(List originalOrder, Map envelopes)
       {
           this.originalOrder = originalOrder;
           this.envelopes = envelopes;
  -        this.transaction = transaction;
       }
   
       /**
  @@ -121,6 +121,7 @@
           newOrder = new Identity[originalOrder.size()];
           newOrderIndex = 0;
   
  +        if(log.isDebugEnabled()) log.debug("Orginal order: " + originalOrder);
           // set up the vertex array in the order the envelopes were added
           List vertexList = new ArrayList(originalOrder.size());
           // int vertexIndex = 0;
  @@ -136,6 +137,10 @@
               {
                   // envelope is clean - just add identity to new order
                   newOrder[newOrderIndex++] = envelope.getIdentity();
  +                if (log.isDebugEnabled())
  +                {
  +                    log.debug("add unmodified object, newOrderList: " + ArrayUtils.toString(newOrder));
  +                }
               }
           }
           vertices = (Vertex[]) vertexList.toArray(new Vertex[vertexList.size()]);
  @@ -198,6 +203,11 @@
                       newOrder[newOrderIndex++] = vertex.getEnvelope().getIdentity();
                       vertex.markProcessed();
                       processCount++;
  +                    if (log.isDebugEnabled())
  +                    {
  +                        log.debug("add minimum edge weight - "+minIncomingEdgeWeight
  +                                + ", newOrderList: " + ArrayUtils.toString(newOrder));
  +                    }
                   }
                   vertex.resetIncomingEdgeWeight();
               }
  @@ -213,6 +223,7 @@
           if (log.isDebugEnabled())
           {
               t3 = System.currentTimeMillis();
  +            log.debug("New ordering: " + ArrayUtils.toString(newOrder));
               log.debug("Processing object envelope graph took " + (t3 - t2) + " ms");
           }
   
  @@ -239,9 +250,7 @@
        */
       private void addEdgesForVertex(Vertex vertex)
       {
  -        PersistenceBroker broker = transaction.getBroker();
  -        Object object = vertex.getEnvelope().getObject();
  -        ClassDescriptor cld = broker.getClassDescriptor(object.getClass());
  +        ClassDescriptor cld = vertex.getEnvelope().getClassDescriptor();
           Iterator rdsIter = cld.getObjectReferenceDescriptors().iterator();
           while (rdsIter.hasNext())
           {
  @@ -308,7 +317,7 @@
           Object[] refObjects;
           if (col == null || (ProxyHelper.isCollectionProxy(col) && !ProxyHelper.getCollectionProxy(col).isLoaded()))
           {
  -            refObjects = new Object[0];
  +            refObjects = EMPTY_OBJECT_ARRAY;
           }
           else
           {
  @@ -735,6 +744,15 @@
           {
               return hashCode;
           }
  +
  +        public String toString()
  +        {
  +            return new ToStringBuilder(this)
  +                    .append("initialIdentity", initialIdentity)
  +                    .append("terminalIdentity", terminalIdentity)
  +                    .append("processed", knownToBeProcessed)
  +                    .toString();
  +        }
       }
   
       /**
  @@ -782,6 +800,15 @@
           {
               return incomingEdgeWeight;
           }
  +
  +        public String toString()
  +        {
  +            return new ToStringBuilder(this)
  +                    .append("envelope", envelope)
  +                    .append("processed", processed)
  +                    .append("incomingEdgeWeight", incomingEdgeWeight)
  +                    .toString();
  +        }
       }
   
   }
  \ No newline at end of file
  
  
  
  1.32.2.18 +15 -16    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.32.2.17
  retrieving revision 1.32.2.18
  diff -u -r1.32.2.17 -r1.32.2.18
  --- ObjectEnvelopeTable.java	3 Apr 2005 11:25:19 -0000	1.32.2.17
  +++ ObjectEnvelopeTable.java	3 May 2005 17:09:04 -0000	1.32.2.18
  @@ -197,9 +197,15 @@
           catch (Exception e)
           {
               connMan.clearBatch();
  +            /*
  +            arminw:
  +            log only a warn message, because in top-level methods
  +            a error log will be done ditto
  +            */
               if(e instanceof OptimisticLockException)
               {
  -                log.warn("Optimistic lock exception while write objects", e);
  +                // make error log to show the full stack trace one time
  +                log.error("Optimistic lock exception while write objects", e);
                   // PB OptimisticLockException should be clearly signalled to the user
                   Object sourceObject = ((OptimisticLockException) e).getSourceObject();
                   throw new LockNotGrantedException("Optimistic lock exception occur, source
object was (" + sourceObject + ")," +
  @@ -458,7 +464,7 @@
       {
           if (needsCommit)
           {
  -            ObjectEnvelopeOrdering ordering = new ObjectEnvelopeOrdering(transaction, mvOrderOfIds,
mhtObjectEnvelopes);
  +            ObjectEnvelopeOrdering ordering = new ObjectEnvelopeOrdering(mvOrderOfIds,
mhtObjectEnvelopes);
               ordering.reorder();
               Identity[] newOrder = ordering.getOrdering();
               
  @@ -470,18 +476,6 @@
           }
       }
   
  -//    /**
  -//     * get Configuration
  -//     * @return OdmgConfiguration
  -//     */
  -//    private OdmgConfiguration getConfiguration()
  -//    {
  -//        OdmgConfiguration config =
  -//            (OdmgConfiguration) PersistenceBrokerFactory.getConfigurator().getConfigurationFor(
  -//                null);
  -//        return config;
  -//    }
  -
       void cascadingDependents()
       {
           Iterator it = mhtObjectEnvelopes.values().iterator();
  @@ -598,7 +592,7 @@
                           // else we have nothing to do
                           if(depMod == null)
                           {
  -                            getTransaction().lockAndRegister(rt, Transaction.WRITE, false);
  +                            getTransaction().lockAndRegister(rt, Transaction.WRITE, false,
getTransaction().getRegistrationList());
                               depMod = getByIdentity(oid);
                           }
                           if(depMod == null)
  @@ -655,7 +649,7 @@
                               ObjectEnvelope oe = getByIdentity(oid);
                               if(oe == null)
                               {
  -                                getTransaction().lockAndRegister(rt, Transaction.WRITE,
false);
  +                                getTransaction().lockAndRegister(rt, Transaction.WRITE,
false, getTransaction().getRegistrationList());
                                   oe = getByIdentity(oid);
                               }
                               if(col.isMtoNRelation())
  @@ -667,6 +661,11 @@
                               {
                                   // we mark collection reference for linking
                                   oe.addLinkOneToN(col, source.getObject(), false);
  +                                /*
  +                                arminw: The referenced object could be already persisted,
so we have
  +                                to dirty it to guarantee the setting of the FK (linking)
  +                                */
  +                                oe.setModificationState(oe.getModificationState().markDirty());
                               }
                               cascadeInsertFor(oe, alreadyPrepared);
                           }
  
  
  
  1.1.2.4   +7 -7      db-ojb/src/java/org/apache/ojb/odmg/Attic/RuntimeObject.java
  
  Index: RuntimeObject.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/Attic/RuntimeObject.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- RuntimeObject.java	3 Apr 2005 01:50:52 -0000	1.1.2.3
  +++ RuntimeObject.java	3 May 2005 17:09:04 -0000	1.1.2.4
  @@ -42,7 +42,7 @@
       {
           this.tx = tx;
           this.obj = obj;
  -        init(tx);
  +        initCld(tx);
           doIsNewObjectCheck(tx);
       }
   
  @@ -51,7 +51,7 @@
           this.tx = tx;
           this.obj = obj;
           this.isNew = isNew ? Boolean.TRUE : Boolean.FALSE;
  -        init(tx);
  +        initCld(tx);
       }
   
       public RuntimeObject(final Object obj, final Identity identity, final TransactionImpl
tx, final boolean isNew)
  @@ -60,7 +60,7 @@
           this.obj = obj;
           this.identity = identity;
           this.isNew = isNew ? Boolean.TRUE : Boolean.FALSE;
  -        init(tx);
  +        initCld(tx);
       }
   
       public RuntimeObject(final Object obj, final Identity oid, final ClassDescriptor cld,
final boolean isNew, final boolean isProxy)
  @@ -81,7 +81,7 @@
       best performance, thus create Identity object only if needed
       and do 'is new object' check only if needed.
       */
  -    private void init(final TransactionImpl tx)
  +    private void initCld(final TransactionImpl tx)
       {
           final IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj);
           if(handler != null)
  @@ -174,8 +174,8 @@
       }
   
       /**
  -     *
  -     * @return
  +     * Returns <code>true</code> if the represented object is
  +     * not yet persisted.
        */
       public boolean isNew()
       {
  
  
  
  1.4.2.2   +0 -2      db-ojb/src/java/org/apache/ojb/odmg/TransactionAbortedExceptionOJB.java
  
  Index: TransactionAbortedExceptionOJB.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/TransactionAbortedExceptionOJB.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- TransactionAbortedExceptionOJB.java	27 Nov 2004 23:46:07 -0000	1.4.2.1
  +++ TransactionAbortedExceptionOJB.java	3 May 2005 17:09:04 -0000	1.4.2.2
  @@ -61,8 +61,6 @@
   
       /**
        * Returns the cause of the exception. May be null.
  -     *
  -     * @return
        */
       public Throwable getCause()
       {
  
  
  
  1.59.2.15 +49 -45    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.59.2.14
  retrieving revision 1.59.2.15
  diff -u -r1.59.2.14 -r1.59.2.15
  --- TransactionImpl.java	3 Apr 2005 02:38:45 -0000	1.59.2.14
  +++ TransactionImpl.java	3 May 2005 17:09:04 -0000	1.59.2.15
  @@ -29,7 +29,7 @@
   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.core.PersistenceBrokerFactoryFactory;
   import org.apache.ojb.broker.core.proxy.CollectionProxy;
   import org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl;
   import org.apache.ojb.broker.core.proxy.CollectionProxyListener;
  @@ -73,7 +73,7 @@
       private boolean implicitLocking;
       private String txGUID;
       protected PersistenceBroker broker = null;
  -    private ArrayList registeredForLock = new ArrayList();
  +    private ArrayList registrationList = new ArrayList();
       private ImplementationImpl implementation;
       private NamedRootsMap namedRootsMap;
   
  @@ -219,41 +219,38 @@
       {
           if (log.isDebugEnabled()) log.debug("lock object was called on tx " + this + ",
object is " + obj.toString());
           checkOpen();
  -//        RuntimeObject rtObject;
  -//        if(getImplementation().isSafeMode())
  -//        {
  -//            rtObject = new RuntimeObject(obj, this);
  -//        }
  -//        else
  -//        {
  -//            rtObject = new RuntimeObject(obj, this, false);
  -//        }
           RuntimeObject rtObject = new RuntimeObject(obj, this);
  -        lockAndRegister(rtObject, lockMode, true);
  -        registeredForLock.clear();
  +        lockAndRegister(rtObject, lockMode, true, getRegistrationList());
       }
   
       /**
  -     * This method have to called after use of {@link #lockAndRegister(RuntimeObject, int,
boolean)}
  -     * with enabled cascading register.
  +     * Returns an empty List for registration of processed object Identity.
        */
  -    public void lockAndRegisterCleanup()
  +    public ArrayList getRegistrationList()
       {
  -        registeredForLock.clear();
  +        clearRegistrationList();
  +        return registrationList;
       }
   
       /**
  -     * Lock and register the specified object, make sure that after use the
  -     * method {@link #clearRegisteredForLock()} was called to cleanup, when
  -     * cascade <em>true</em> is specified.
  +     * Clears the list of processed object Identity.
        */
  -    public void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade)
  +    public void clearRegistrationList()
  +    {
  +        registrationList.clear();
  +    }
  +
  +    /**
  +     * Lock and register the specified object, make sure that when cascading locking and
register
  +     * is enabled to specify a List to register the already processed object Identiy.
  +     */
  +    public void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade,
List registeredObjects)
       {
           // if current object was already locked, do nothing
           // avoid endless loops when circular object references are used
  -        if(!registeredForLock.contains(rtObject.getIdentity()))
  +        if(!registeredObjects.contains(rtObject.getIdentity()))
           {
  -            if(cascade) registeredForLock.add(rtObject.getIdentity());
  +            if(cascade) registeredObjects.add(rtObject.getIdentity());
               try
               {
                   // perform the lock on the object
  @@ -264,7 +261,7 @@
                   }
                   // now register specified object + register and lock recursive all referenced
objects
                   // after we locked the object, register it to detect status and changes
while tx
  -                register(rtObject, lockMode, cascade);
  +                register(rtObject, lockMode, cascade, registeredObjects);
               }
               catch (Throwable t)
               {
  @@ -455,7 +452,7 @@
           // we should do that, because same tx instance
           // could be used several times
           broker = null;
  -        registeredForLock.clear();
  +        clearRegistrationList();
           unmaterializedLocks.clear();
           txStatus = Status.STATUS_NO_TRANSACTION;
       }
  @@ -689,7 +686,7 @@
           }
           catch (RuntimeException e)
           {
  -            log.error("Could not prepare for commit: " + e.getMessage());
  +            log.error("Could not prepare for commit", e);
               txStatus = Status.STATUS_MARKED_ROLLBACK;
               throw e;
           }
  @@ -832,7 +829,7 @@
        * recursively all associations (a implicite lock is acquired for associations). This
method
        * expect that the main object is already locked!!!
        */
  -    private synchronized void register(RuntimeObject rtObject, int lockMode, boolean cascade)
  +    private synchronized void register(RuntimeObject rtObject, int lockMode, boolean cascade,
List registeredObjects)
               throws LockNotGrantedException, PersistenceBrokerException
       {
           Object objectToRegister = rtObject.getObj();
  @@ -875,6 +872,15 @@
           // no Proxy and is not null, register real object
           if (objectToRegister != null)
           {
  +            // register associated 1:1 objects
  +            if(cascade)
  +            {
  +                // it's save to call RTO#getObjMaterialized because we know that
  +                // the object is a non-null normal object or an materialized proxy
  +                // and the method returns in any case the real object
  +                lockAndRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(),
getImpliciteLockType(lockMode), registeredObjects);
  +            }
  +
               ObjectEnvelope envelope = objectEnvelopeTable.getByIdentity(rtObject.getIdentity());
               // if we found an envelope, object is already registered --> we do nothing
               // than refreshing the object!
  @@ -903,24 +909,24 @@
                   // signal ObjectEnvelope that a WRITE lock is already acquired
                   envelope.setWriteLocked(true);
               }
  -            // register associated objects
  +            // register associated 1:n and m:n objects
               if(cascade)
               {
                   // it's save to call RTO#getObjMaterialized because we know that
                   // the object is a non-null normal object or an materialized proxy
                   // and the method returns in any case the real object
  -                lockAndRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(),
getImpliciteLockType(lockMode));
  -                lockAndRegisterCollections(rtObject.getCld(), rtObject.getObjMaterialized(),
getImpliciteLockType(lockMode));
  +                //lockAndRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(),
getImpliciteLockType(lockMode), registeredObjects);
  +                lockAndRegisterCollections(rtObject.getCld(), rtObject.getObjMaterialized(),
getImpliciteLockType(lockMode), registeredObjects);
               }
           }
       }
   
       /**
  -     * we only use the registeredForLock map if the object is not a proxy. During the
  +     * we only use the registrationList map if the object is not a proxy. During the
        * reference locking, we will materialize objects and they will enter the registered
for
        * lock map.
        */
  -    private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int
lockMode) throws LockNotGrantedException
  +    private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int
lockMode, List registeredObjects) throws LockNotGrantedException
       {
           if (implicitLocking)
           {
  @@ -933,16 +939,16 @@
                   {
                       boolean isProxy = ProxyHelper.isProxy(refObj);
                       RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false)
: new RuntimeObject(refObj, this);
  -                    if (!registeredForLock.contains(rt.getIdentity()))
  +                    if (!registrationList.contains(rt.getIdentity()))
                       {
  -                        lockAndRegister(rt, lockMode, true);
  +                        lockAndRegister(rt, lockMode, true, registeredObjects);
                       }
                   }
               }
           }
       }
   
  -    private void lockAndRegisterCollections(ClassDescriptor cld, Object sourceObject, int
lockMode) throws LockNotGrantedException
  +    private void lockAndRegisterCollections(ClassDescriptor cld, Object sourceObject, int
lockMode, List registeredObjects) throws LockNotGrantedException
       {
           if (implicitLocking)
           {
  @@ -987,7 +993,10 @@
                                       item = handler.getRealSubject();
                                   }
                               }
  -                            lockAndRegister(rt, lockMode, true);
  +                            if (!registrationList.contains(rt.getIdentity()))
  +                            {
  +                                lockAndRegister(rt, lockMode, true, registeredObjects);
  +                            }
                           }
                       }
                       catch (LockNotGrantedException e)
  @@ -1042,7 +1051,7 @@
               }
               ClassDescriptor cld = getBroker().getClassDescriptor(materializedObject.getClass());
               RuntimeObject rt = new RuntimeObject(materializedObject, oid, cld, false, false);
  -            lockAndRegister(rt, Transaction.READ, false);
  +            lockAndRegister(rt, Transaction.READ, false, getRegistrationList());
           }
           catch (Throwable t)
           {
  @@ -1116,7 +1125,7 @@
               try
               {
                   checkForDB();
  -                broker = PersistenceBrokerFactory.createPersistenceBroker(curDB.getPBKey());
  +                broker = PersistenceBrokerFactoryFactory.instance().createPersistenceBroker(curDB.getPBKey());
               }
               catch (PBFactoryException e)
               {
  @@ -1207,7 +1216,7 @@
                   Identity oid = getBroker().serviceIdentity().buildIdentity(o);
                   ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o));
                   RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o));
  -                lockAndRegister(rt, Transaction.READ, false);
  +                lockAndRegister(rt, Transaction.READ, false, getRegistrationList());
               }
           }
           unregisterFromCollectionProxy(colProxy);
  @@ -1366,11 +1375,6 @@
           return (parentLockMode == Transaction.WRITE && impliciteWriteLocks) ? Transaction.WRITE
: Transaction.READ;
       }
   
  -    void clearRegisteredForLock()
  -    {
  -        registeredForLock.clear();
  -    }
  -
       //============================================================
       // inner class
       //============================================================
  
  
  

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