db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/odmg ObjectEnvelope.java ObjectEnvelopeTable.java
Date Thu, 09 Jan 2003 17:05:42 GMT
mattbaird    2003/01/09 09:05:42

  Modified:    src/java/org/apache/ojb/odmg ObjectEnvelope.java
                        ObjectEnvelopeTable.java
  Log:
  fix some proxy handling stuff in ODMG api
  
  Revision  Changes    Path
  1.15      +2 -29     jakarta-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java
  
  Index: ObjectEnvelope.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ObjectEnvelope.java	24 Nov 2002 23:24:39 -0000	1.14
  +++ ObjectEnvelope.java	9 Jan 2003 17:05:42 -0000	1.15
  @@ -79,6 +79,7 @@
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   import org.apache.ojb.broker.singlevm.LoadedObjectsRegistry;
   import org.apache.ojb.broker.util.ObjectModification;
  +import org.apache.ojb.broker.util.ProxyHelper;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.odmg.states.ModificationState;
   
  @@ -139,7 +140,7 @@
        */
       public void manage(Object obj)
       {
  -        myObj = obj;
  +        myObj = ProxyHelper.getRealObject(obj);
           try
           {
               beforeImage = getMap();
  @@ -287,11 +288,6 @@
                    * trigger the update
                    */
                   IndirectionHandler handler = (IndirectionHandler) Proxy.getInvocationHandler(temp);
  -                //if (handler.alreadyMaterialized())
  -                //{
  -                //    temp = handler.getRealSubject();
  -                //    fieldValues.put(rds,temp);
  -                //}
                   fieldValues.put(rds, handler.getIdentity());
               }
               else if ((temp!=null) && (temp instanceof VirtualProxy))
  @@ -302,11 +298,6 @@
                    * trigger the update
                    */
                   VirtualProxy proxy = (VirtualProxy) temp;
  -                //if (proxy.alreadyMaterialized())
  -                //{
  -                //    temp = proxy.getRealSubject();
  -                //    fieldValues.put(rds,temp);
  -                //}
                   fieldValues.put(rds, VirtualProxy.getIndirectionHandler(proxy).getIdentity());
               }
               else
  @@ -400,24 +391,6 @@
       public boolean needsDelete()
       {
           return this.getModificationState().needsDelete();
  -    }
  -
  -    /**
  -     * setFields sets the fields on the object.  This is used when the
  -     * transaction is aborted.
  -     */
  -    private void setFields(Map theMap)
  -            throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        ClassDescriptor mif = tx.getBroker().getClassDescriptor(myObj.getClass());
  -        FieldDescriptor[] fieldDescs = mif.getFieldDescriptions();
  -        for (int i = 0; i < fieldDescs.length; i++)
  -        {
  -            FieldDescriptor fd = fieldDescs[i];
  -            PersistentField f = fd.getPersistentField();
  -            //f.setAccessible(true);
  -            f.set(myObj, theMap.get(fd.getColumnName()));
  -        }
       }
   
       /**
  
  
  
  1.13      +19 -15    jakarta-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java
  
  Index: ObjectEnvelopeTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ObjectEnvelopeTable.java	26 Dec 2002 19:33:00 -0000	1.12
  +++ ObjectEnvelopeTable.java	9 Jan 2003 17:05:42 -0000	1.13
  @@ -72,6 +72,7 @@
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   import org.apache.ojb.broker.util.ArrayIterator;
  +import org.apache.ojb.broker.util.ProxyHelper;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.commons.lang.builder.ToStringBuilder;
  @@ -382,21 +383,24 @@
           throws IllegalAccessException
       {
           PersistenceBroker broker = transaction.getBroker();
  -        ClassDescriptor cld = broker.getClassDescriptor(objectToReorder.getObject().getClass());
  -        if (objectToReorder.needsDelete())
  -        {
  -            reorderCollection(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  -            newVector.add(id);
  -            htNewHashtable.put(id, objectToReorder);
  -            reorderReference(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  -        }
  -        else
  -        {
  -            reorderReference(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  -            newVector.add(id);
  -            htNewHashtable.put(id, objectToReorder);
  -            reorderCollection(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  -        }
  +		if (objectToReorder != null)
  +		{
  +			ClassDescriptor cld = broker.getClassDescriptor(objectToReorder.getObject().getClass());
  +			if (objectToReorder.needsDelete())
  +			{
  +				reorderCollection(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  +				newVector.add(id);
  +				htNewHashtable.put(id, objectToReorder);
  +				reorderReference(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  +			}
  +			else
  +			{
  +				reorderReference(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  +				newVector.add(id);
  +				htNewHashtable.put(id, objectToReorder);
  +				reorderCollection(htNewHashtable, newVector, objectToReorder, cld, htOldVectorPosition);
  +			}
  +		}
       }
   
       /**
  
  
  

Mime
View raw message