db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/otm/swizzle NoSwizzling.java Swizzling.java
Date Thu, 12 Jun 2003 23:40:52 GMT
olegnitz    2003/06/12 16:40:52

  Modified:    src/java/org/apache/ojb/otm/core ConcreteEditingContext.java
               src/java/org/apache/ojb/otm/kit SimpleKit.java
               src/java/org/apache/ojb/otm/swizzle NoSwizzling.java
                        Swizzling.java
  Log:
  CopySwizzling implementation
  
  Revision  Changes    Path
  1.11      +7 -9      db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java
  
  Index: ConcreteEditingContext.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ConcreteEditingContext.java	10 Jun 2003 20:42:39 -0000	1.10
  +++ ConcreteEditingContext.java	12 Jun 2003 23:40:51 -0000	1.11
  @@ -133,7 +133,7 @@
           insertInternal(pb, oid, obj, lock);
       }
   
  -    private ContextEntry insertInternal(PersistenceBroker pb, Identity oid, Object obj,
int lock)
  +    private ContextEntry insertInternal(PersistenceBroker pb, Identity oid, Object newObj,
int lock)
               throws LockingException
       {
           ContextEntry entry;
  @@ -152,7 +152,7 @@
               LockManager lockManager = LockManager.getInstance();
               lockManager.ensureLock(oid, _tx, lock, pb);
               Swizzling swizzlingStrategy = kit.getSwizzlingStrategy();
  -            Object swizzledObject = swizzlingStrategy.swizzle(obj, null);
  +            Object swizzledObject = swizzlingStrategy.swizzle(newObj, null, pb);
               entry = new ContextEntry(swizzledObject);
               _objects.put(oid, entry);
           }
  @@ -162,8 +162,8 @@
               Swizzling swizzlingStrategy = kit.getSwizzlingStrategy();
   
                   // A similar or the same object is present in the context
  -            Object contextObject = entry.object;
  -            if (swizzlingStrategy.isSameInstance(contextObject, obj))
  +            Object oldObj = entry.object;
  +            if (swizzlingStrategy.isSameInstance(oldObj, newObj))
               {
                       // The object in context is the same object attempted an insert on
                       // Ensure we have the correct lock level
  @@ -173,9 +173,7 @@
               {
                       // It is a similar but different object
                   lockManager.ensureLock(oid, _tx, lock, pb);
  -
  -                Object swizzledObject = swizzlingStrategy.swizzle(obj, contextObject);
  -                entry.object = swizzledObject;
  +                entry.object = swizzlingStrategy.swizzle(newObj, oldObj, pb);
               }
           }
           
  @@ -186,11 +184,11 @@
               // if the inserted object is materialized
               if (kit.isImplicitLockingUsed())
               {
  -                IndirectionHandler handler = getIndirectionHandler(obj);
  +                IndirectionHandler handler = getIndirectionHandler(newObj);
   
                   if (handler == null || handler.alreadyMaterialized())
                   {
  -                    lockReachableObjects(obj, pb);
  +                    lockReachableObjects(newObj, pb);
                   }
                   else
                   {
  
  
  
  1.8       +2 -2      db-ojb/src/java/org/apache/ojb/otm/kit/SimpleKit.java
  
  Index: SimpleKit.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/kit/SimpleKit.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SimpleKit.java	9 Jun 2003 18:55:26 -0000	1.7
  +++ SimpleKit.java	12 Jun 2003 23:40:51 -0000	1.8
  @@ -65,7 +65,7 @@
   import org.apache.ojb.otm.lock.map.LockMap;
   import org.apache.ojb.otm.lock.wait.LockWaitStrategy;
   import org.apache.ojb.otm.lock.wait.TimeoutStrategy;
  -import org.apache.ojb.otm.swizzle.NoSwizzling;
  +import org.apache.ojb.otm.swizzle.CopySwizzling;
   import org.apache.ojb.otm.swizzle.Swizzling;
   import org.apache.ojb.otm.transaction.LocalTransactionFactory;
   import org.apache.ojb.otm.transaction.TransactionFactory;
  @@ -97,7 +97,7 @@
       {
           super();
           _txFactory = new LocalTransactionFactory();
  -        _swizzlingStrategy = new NoSwizzling();
  +        _swizzlingStrategy = new CopySwizzling();
           _lockWaitStrategy = new TimeoutStrategy();
           _lockMap = new InMemoryLockMap();
           _copyStrategy = new SerializeObjectCopyStrategy();
  
  
  
  1.2       +26 -23    db-ojb/src/java/org/apache/ojb/otm/swizzle/NoSwizzling.java
  
  Index: NoSwizzling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/swizzle/NoSwizzling.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NoSwizzling.java	1 Feb 2003 18:39:56 -0000	1.1
  +++ NoSwizzling.java	12 Jun 2003 23:40:52 -0000	1.2
  @@ -1,37 +1,40 @@
   package org.apache.ojb.otm.swizzle;
   
  +import org.apache.ojb.broker.PersistenceBroker;
  +
   /**
    *
    * No swizzling is performed.
  - * 
  + *
    * @author <a href="mailto:rraghuram@hotmail.com">Raghu Rajah</a>
  - * 
  + *
    */
   public class NoSwizzling implements Swizzling
   {
   
  -	/**
  -	 * @see org.apache.ojb.otm.swizzle.Swizzling#swizzle(Object, Object)
  -	 */
  -	public Object swizzle(Object newObject, Object oldObject)
  -	{
  -		return newObject;
  -	}
  +    /**
  +     * @see org.apache.ojb.otm.swizzle.Swizzling#swizzle(Object, Object, PersistenceBroker)
  +     */
  +    public Object swizzle(Object newObj, Object oldObj,
  +                          PersistenceBroker pb)
  +    {
  +        return newObj;
  +    }
   
  -	/**
  -	 * @see org.apache.ojb.otm.swizzle.Swizzling#isSameInstance(Object, Object)
  -	 */
  -	public boolean isSameInstance (Object swizzledObject, Object object)
  -	{
  -		return swizzledObject == object;
  -	}
  +    /**
  +     * @see org.apache.ojb.otm.swizzle.Swizzling#isSameInstance(Object, Object)
  +     */
  +    public boolean isSameInstance(Object swizzledObject, Object object)
  +    {
  +        return (swizzledObject == object);
  +    }
   
  -	/**
  -	 * @see org.apache.ojb.otm.swizzle.Swizzling#getRealTarget(Object)
  -	 */
  -	public Object getRealTarget (Object swizzledObject)
  -	{
  -		return swizzledObject;
  -	}
  +    /**
  +     * @see org.apache.ojb.otm.swizzle.Swizzling#getRealTarget(Object)
  +     */
  +    public Object getRealTarget(Object swizzledObject)
  +    {
  +        return swizzledObject;
  +    }
   
   }
  
  
  
  1.2       +26 -22    db-ojb/src/java/org/apache/ojb/otm/swizzle/Swizzling.java
  
  Index: Swizzling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/swizzle/Swizzling.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Swizzling.java	1 Feb 2003 18:39:56 -0000	1.1
  +++ Swizzling.java	12 Jun 2003 23:40:52 -0000	1.2
  @@ -1,47 +1,51 @@
   package org.apache.ojb.otm.swizzle;
   
  +import org.apache.ojb.broker.PersistenceBroker;
  +
   /**
    *
  - * Swizzles object references as objects are displaced by other similar objects in the

  + * Swizzles object references as objects are displaced by other similar objects in the
    * EditingContext.
  - * 
  + *
    * @author <a href="mailto:rraghuram@hotmail.com">Raghu Rajah</a>
  - * 
  + *
    */
   public interface Swizzling
   {
  -    
  +
       /**
  -     * 
  +     *
        *  Swizzle object references
  -     * 
  -     *  @param newObject    the object being inserted into the EditingContext
  -     *  @param oldObject    the object present in the EditingContext
  -     *  @return             the Swizzled Object
  -     * 
  +     *
  +     *  @param newObj    the object being inserted into the EditingContext
  +     *  @param oldObj    the object present in the EditingContext
  +     *  @param pb        the PersistenceBroker that is used to get
  +     *                   persistent class info
  +     *  @return          the Swizzled Object
  +     *
        */
  -    public Object swizzle (Object newObject, Object oldObject);
  -    
  +    public Object swizzle(Object newObj, Object oldObj, PersistenceBroker pb);
  +
       /**
  -     * 
  +     *
        * Test if the given swizzled object is the same as the given object. By same object
we mean,
        * that the System.identityHashCode() of the given object is the same as that of the
object
        * represented by the swizzled object.
  -     * 
  +     *
        * @param swizzledObject        The swizzled object
        * @param object                The other object to be compared to
        * @return                      true, if they are the same. false, otherwise.
  -     * 
  +     *
        */
  -    public boolean isSameInstance (Object swizzledObject, Object object);
  -    
  +    public boolean isSameInstance(Object swizzledObject, Object object);
  +
       /**
  -     * 
  -     * Get the real object associated with the given swizzled object. 
  -     * 
  +     *
  +     * Get the real object associated with the given swizzled object.
  +     *
        * @param   swizzledObject      the swizzled object
        * @return                      the real object
  -     * 
  +     *
        */
  -    public Object getRealTarget (Object swizzledObject);
  +    public Object getRealTarget(Object swizzledObject);
   }
  
  
  

Mime
View raw message