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 2003/11/13 15:52:40 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/odmg/locking ReadUncommittedStrategy.java

arminw      2003/11/13 06:52:40

  Modified:    src/test/org/apache/ojb/odmg PersonWithArrayTest.java
               src/java/org/apache/ojb/odmg ObjectEnvelopeTable.java
                        ObjectEnvelope.java
               src/java/org/apache/ojb/odmg/states StateOldDelete.java
                        StateOldClean.java StateNewDelete.java
                        StateNewClean.java ModificationState.java
               src/java/org/apache/ojb/odmg/locking
                        ReadUncommittedStrategy.java
  Removed:     src/java/org/apache/ojb/odmg LoadedObjectsRegistry.java
  Log:
  - remove LoadedObjectsRegistry
  - remove of LOR fix bug in test cases
  - remove blank lines in serveral classes
  
  Email send to dev-list, why need to
  remove this class
  ***********************************
  Hi all,
  
  while try to fix an odmg test case I
  stumble across LoadedObjectRegistry (LOR)used
  in the odmg-api.
  A comment in this class says:
  
  <snip>
  * This is a helper class which registers all objects loaded
   * from database. It is used by ODMG layer to determine the state of
   * objects: if an object was not loaded from database then it is new.
   * Note: objects remain registered even after they are deleted. This
   * is necessary to prevent creation of deleted objects by another
   * thread, see <a href="http://archives.apache.org/eyebrowse/ReadMsg?listId=106&msgNo=1382">this<a>
   * for details.
   *
  </snip>
  
  I read (is this the same message?)
  http://nagoya.apache.org/eyebrowse/ReadMsg?listName=ojb-user@db.apache.org&msgNo=1382
  and found
  http://nagoya.apache.org/eyebrowse/ReadMsg?listName=ojb-user@db.apache.org&msgNo=1453
  so LoadedObjectRegistry was not needed to solve this problem.
  
  <snip>
   * is necessary to prevent creation of deleted objects by another
   * thread
  </snip>
  
  I think this problem couldn't be solved by LoadedObjectRegistry.
  If an application server is used all objects will be serialized
  and we never will find the "same" object in LOR.
  Or in an clustered environment this will not work too, because
  LOR is not a distributed service.
  
  But if I comment out LOR the test case will be fixed.
  
  Revision  Changes    Path
  1.4       +14 -9     db-ojb/src/test/org/apache/ojb/odmg/PersonWithArrayTest.java
  
  Index: PersonWithArrayTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/PersonWithArrayTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PersonWithArrayTest.java	8 Aug 2003 20:38:25 -0000	1.3
  +++ PersonWithArrayTest.java	13 Nov 2003 14:52:40 -0000	1.4
  @@ -7,6 +7,7 @@
   
   import junit.framework.TestCase;
   import org.apache.ojb.broker.TestHelper;
  +import org.apache.ojb.broker.Identity;
   import org.odmg.Database;
   import org.odmg.Implementation;
   import org.odmg.ODMGException;
  @@ -143,9 +144,9 @@
           //open database
           db.open(databaseName, Database.OPEN_READ_WRITE);
   
  -        Person father = createPerson(firstnameFather, "testStoreThreePersons_1", null, null);
  -        Person child_1 = createPerson(firstnameChild_1, "testStoreThreePersons_1", null, null);
  -        Person child_2 = createPerson(firstnameChild_2, "testStoreThreePersons_1", null, null);
  +        Person father = createPerson(firstnameFather, "testStoreThreePersons_2", null, null);
  +        Person child_1 = createPerson(firstnameChild_1, "testStoreThreePersons_2", null, null);
  +        Person child_2 = createPerson(firstnameChild_2, "testStoreThreePersons_2", null, null);
   
           Person[] children = new Person[]{child_1, child_2};
           father.setChildren(children);
  @@ -214,6 +215,10 @@
           assertEquals("Exactly one element in result set", 0, result.size());
       }
   
  +    /**
  +     * Seems the locking order of objects is mandatory in this
  +     * case. This test fails
  +     */
       public void testStoreDeleteThreePersons_3() throws Exception
       {
           String postfix = "_" + System.currentTimeMillis();
  @@ -226,9 +231,9 @@
           //open database
           db.open(databaseName, Database.OPEN_READ_WRITE);
   
  -        Person father = createPerson(firstnameFather, "testStoreThreePersons_1", null, null);
  -        Person child_1 = createPerson(firstnameChild_1, "testStoreThreePersons_1", null, null);
  -        Person child_2 = createPerson(firstnameChild_2, "testStoreThreePersons_1", null, null);
  +        Person father = createPerson(firstnameFather, "testStoreThreePersons_3", null, null);
  +        Person child_1 = createPerson(firstnameChild_1, "testStoreThreePersons_3", null, null);
  +        Person child_2 = createPerson(firstnameChild_2, "testStoreThreePersons_3", null, null);
   
           Person[] children = new Person[]{child_1, child_2};
           father.setChildren(children);
  @@ -243,8 +248,8 @@
            */
           Transaction tx = odmg.newTransaction();
           tx.begin();
  -        tx.lock(child_2, Transaction.WRITE);
           tx.lock(child_1, Transaction.WRITE);
  +        tx.lock(child_2, Transaction.WRITE);
           tx.lock(father, Transaction.WRITE);
           tx.commit();
   
  @@ -261,7 +266,7 @@
   
           assertEquals("Exactly one element in result set", 1, result.size());
           Person returnedFather = (Person) result.iterator().next();
  -        // should retrieve new instance
  +        // should retrieve new instance, cause we clear the cache
           assertTrue("not same", returnedFather != father);
           Person[] returnedChildren = returnedFather.getChildren();
           assertNotNull(returnedChildren);
  @@ -327,4 +332,4 @@
           String[] arr = {CLASS.getName()};
           junit.textui.TestRunner.main(arr);
       }
  -}
  \ No newline at end of file
  +}
  
  
  
  1.27      +1 -2      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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ObjectEnvelopeTable.java	28 Jul 2003 14:34:20 -0000	1.26
  +++ ObjectEnvelopeTable.java	13 Nov 2003 14:52:40 -0000	1.27
  @@ -244,8 +244,7 @@
       }
   
   	/**
  -	 * commit all envelopes against the current broker
  -	 * @param broker the PB to persist all objects
  +	 * 
   	 */
   	private void setCleanState()
   	{
  
  
  
  1.23      +65 -91    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ObjectEnvelope.java	28 Jul 2003 08:14:43 -0000	1.22
  +++ ObjectEnvelope.java	13 Nov 2003 14:52:40 -0000	1.23
  @@ -59,18 +59,9 @@
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
    *
    */
  -import java.io.Serializable;
  -import java.lang.reflect.InvocationTargetException;
  -import java.lang.reflect.Method;
  -
  -import java.util.Collection;
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.Map;
  -
   import org.apache.ojb.broker.Identity;
  -import org.apache.ojb.broker.VirtualProxy;
   import org.apache.ojb.broker.PersistenceBrokerException;
  +import org.apache.ojb.broker.VirtualProxy;
   import org.apache.ojb.broker.accesslayer.IndirectionHandler;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
  @@ -83,6 +74,13 @@
   import org.apache.ojb.odmg.states.ModificationState;
   import org.odmg.ODMGRuntimeException;
   
  +import java.io.Serializable;
  +import java.lang.reflect.Proxy;
  +import java.util.Collection;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.Map;
  +
   //#ifdef JDK13
   import java.lang.reflect.Proxy;
   //#else
  @@ -97,11 +95,13 @@
    */
   public class ObjectEnvelope implements ObjectModification, Serializable
   {
  +    /**
  +     * The objects modification state, e.g. Old and Clean
  +     */
  +    private ModificationState modificationState = null;
   
       /**
  -     *
        * myObj holds the object we are wrapping.
  -     *
        */
       private transient Object myObj;
   
  @@ -112,15 +112,8 @@
        * end of the transaction.
        */
       private transient Map beforeImage;
  -
       private transient TransactionImpl tx;
   
  -	public void close()
  -	{
  -		myObj = null;
  -		beforeImage = null;
  -		tx = null;
  -	}
       /**
        *
        * Create a wrapper by providing an Object.
  @@ -132,6 +125,12 @@
           setInitialModificationState();
       }
   
  +    public void close()
  +	{
  +		myObj = null;
  +		beforeImage = null;
  +		tx = null;
  +	}
   
       /**
        * Manage an object.
  @@ -222,14 +221,7 @@
       }
   
       /**
  -     * The objects modification state, e.g. Old and Clean
  -     */
  -    private ModificationState modificationState = null;
  -
  -    /**
  -     *
        * getMap() will return the image of the Object.
  -     *
        */
       private Map getMap() throws PersistenceBrokerException
       {
  @@ -337,31 +329,6 @@
           return fieldValues;
       }
   
  -    private Long timeStamp()
  -	    throws IllegalAccessException
  -    {
  -		Long retval = new Long(0);
  -		if (myObj != null)
  -		{
  -			try
  -			{
  -				Class c = getObject().getClass();
  -				Method m = c.getMethod("getTimeStamp",null);
  -				if (m != null)
  -					retval = (Long) m.invoke(myObj,null);
  -			}
  -			catch (NoSuchMethodException nsmEx)
  -			{
  -				LoggerFactory.getDefaultLogger().debug("No Such Method for object: " + myObj.getClass().getName());
  -			}
  -			catch (InvocationTargetException itEx)
  -			{
  -				LoggerFactory.getDefaultLogger().debug("InvocationTargetException: " + myObj.getClass().getName());
  -			}
  -		}
  -        return retval;
  -    }
  -
       /**
        * returns the Modification-state.
        * @return org.apache.ojb.server.states.ModificationState
  @@ -405,49 +372,56 @@
           ModificationState initialState = null;
           Object result;
   
  -        if (LoadedObjectsRegistry.isRegistered(myObj))
  +// remove LOR from code base
  +//        if (LoadedObjectsRegistry.isRegistered(myObj))
  +//        {
  +//            initialState = org.apache.ojb.odmg.states.StateOldClean.getInstance();
  +//        }
  +//        else
  +//        {
  +//            ...
  +//        }
  +
  +        /*
  +        arminw:
  +        TODO: check out
  +        initial point to register used objects
  +        DO we really need LoadedObjectsRegistry???
  +        arminw:
  +        remove LOR from code base
  +        */
  +        // LoadedObjectsRegistry.register(myObj);
  +
  +        Identity id = new Identity(myObj, tx.getBroker());
  +
  +        try
           {
  -            initialState = org.apache.ojb.odmg.states.StateOldClean.getInstance();
  +            // try to lookup the object.
  +            result = tx.getBroker().getObjectByIdentity(id);
  +        }
  +        catch (PersistenceBrokerException ex)
  +        {
  +            LoggerFactory.getDefaultLogger().error("ObjectEnvelope: ", ex);
  +            throw new ODMGRuntimeException(ex.getMessage());
  +        }
  +        if (result == null)
  +        {
  +            // if object is not already persistent it must be marked as new
  +            // it must be marked as dirty because it must be stored even if it will not modified during tx
  +            initialState = org.apache.ojb.odmg.states.StateNewDirty.getInstance();
  +        }
  +        else if (tx.isDeleted(id))
  +        {
  +            // if object is already persistent it will be marked as old.
  +            // it is marked as dirty as it has been deleted during tx and now it is inserted again,
  +            // possibly with new field values.
  +            initialState = org.apache.ojb.odmg.states.StateOldDirty.getInstance();
           }
           else
           {
  -            /*
  -            arminw:
  -            TODO: check out
  -            initial point to register used objects
  -            */
  -            LoadedObjectsRegistry.register(myObj);
  -            Identity id = new Identity(myObj, tx.getBroker());
  -
  -            try
  -            {
  -                // try to lookup the object.
  -                result = tx.getBroker().getObjectByIdentity(id);
  -            }
  -            catch (PersistenceBrokerException ex)
  -            {
  -                LoggerFactory.getDefaultLogger().error("ObjectEnvelope: ", ex);
  -                throw new ODMGRuntimeException(ex.getMessage());
  -            }
  -            if (result == null)
  -            {
  -                // if object is not already persistent it must be marked as new
  -                // it must be marked as dirty because it must be stored even if it will not modified during tx
  -                initialState = org.apache.ojb.odmg.states.StateNewDirty.getInstance();
  -            }
  -            else if (tx.isDeleted(id))
  -            {
  -                // if object is already persistent it will be marked as old.
  -                // it is marked as dirty as it has been deleted during tx and now it is inserted again,
  -                // possibly with new field values.
  -                initialState = org.apache.ojb.odmg.states.StateOldDirty.getInstance();
  -            }
  -            else
  -            {
  -                // if object is already persistent it will be marked as old.
  -                // it is marked as clean as it has not been modified during tx already
  -                initialState = org.apache.ojb.odmg.states.StateOldClean.getInstance();
  -            }
  +            // if object is already persistent it will be marked as old.
  +            // it is marked as clean as it has not been modified during tx already
  +            initialState = org.apache.ojb.odmg.states.StateOldClean.getInstance();
           }
           // remember it:
           modificationState = initialState;
  @@ -554,7 +528,7 @@
   			 * Now set all collections back. But we only stored DirtyMarks.
   			 * So what can be rolledback.?
   			 */
  -			Iterator collections = mif.getCollectionDescriptors().iterator();
  +			// Iterator collections = mif.getCollectionDescriptors().iterator();
       	}
       }
   }
  
  
  
  1.3       +1 -164    db-ojb/src/java/org/apache/ojb/odmg/states/StateOldDelete.java
  
  Index: StateOldDelete.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateOldDelete.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateOldDelete.java	17 Jun 2002 19:34:32 -0000	1.2
  +++ StateOldDelete.java	13 Nov 2003 14:52:40 -0000	1.3
  @@ -1,164 +1 @@
  -package org.apache.ojb.odmg.states;
  -
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.odmg.ObjectEnvelope;
  -
  -/**
  - * this state represents old objects which have been marked for deletion during tx.
  - */
  -public class StateOldDelete extends ModificationState
  -{
  -
  -    /**
  -     * return resulting state after marking clean
  -     */
  -    public ModificationState markClean()
  -    {
  -        return StateOldClean.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking delete
  -     */
  -    public ModificationState markDelete()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking dirty
  -     */
  -    public ModificationState markDirty()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking new
  -     */
  -    public ModificationState markNew()
  -    {
  -        return StateNewDelete.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking old
  -     */
  -    public ModificationState markOld()
  -    {
  -        return this;
  -    }
  -    
  -    /**
  -     * returns true is this state requires DELETE
  -     * @return boolean
  -     */
  -    public boolean needsDelete()
  -    {
  -        return true;
  -    }
  -    
  -
  -    private static StateOldDelete _instance = new StateOldDelete();
  -
  -    /**
  -     * private constructor: use singleton instance
  -     */
  -    private StateOldDelete()
  -    {
  -    }
  -
  -    /**
  -     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  -     */
  -    public static StateOldDelete getInstance()
  -    {
  -        return _instance;
  -    }
  -
  -    /**
  -     * rollback the transaction
  -     */
  -    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -            throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.delete(mod.getObject());
  -    }
  -
  -    /**
  -     * commit the associated transaction
  -     */
  -    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.delete(mod.getObject());
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -    /**
  -     * Method declaration
  -     *
  -     *
  -     * @param mod
  -     *
  -     *
  -     */
  -    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -}
  +package org.apache.ojb.odmg.states;


/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerException;

import org.apache.ojb.odmg.ObjectEnvelope;

/**
 * this state represents old objects which have been marked for deletion during tx.
 */
public class StateOldDelete extends ModificationState
{
    private static StateOldDelete _instance = new StateOldDelete();

    /**
     * private constructor: use singleton instance
     */
    private StateOldDelete()
    {
    }

    /**
     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
     */
    public static StateOldDelete getInstance()
    {
        return _instance;
    }

    /**
     * return resulting state after marking clean
     */
    public ModificationState markClean()
    {
        return StateOldClean.getInstance();
    }

    /**
     * return resulting state after marking delete
     */
    public ModificationState markDelete()
    {
        return this;
    }

    /**
     * return resulting state after marking dirty
     */
    public ModificationState markDirty()
    {
        return this;
    }

    /**
     * return resulting state after marking new
     */
    public ModificationState markNew()
    {
        return StateNewDelete.getInstance();
    }

    /**
     * return resulting state after marking old
     */
    public ModificationState markOld()
    {
        return this;
    }

    /**
     * returns true is this state requires DELETE
     * @return boolean
     */
    public boolean needsDelete()
    {
        return true;
    }

    /**
     * rollback the transaction
     */
    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
            throws org.apache.ojb.broker.PersistenceBrokerException
    {
        broker.delete(mod.getObject());
    }

    /**
     * commit the associated transaction
     */
    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws PersistenceBrokerException
    {
        broker.delete(mod.getObject());
        this.removeFromCache(mod.getObject(), broker);
    }

    /**
     *
     */
    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
    {
        this.removeFromCache(mod.getObject(), broker);
    }
}

  \ No newline at end of file
  
  
  
  1.3       +1 -150    db-ojb/src/java/org/apache/ojb/odmg/states/StateOldClean.java
  
  Index: StateOldClean.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateOldClean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateOldClean.java	17 Jun 2002 19:34:32 -0000	1.2
  +++ StateOldClean.java	13 Nov 2003 14:52:40 -0000	1.3
  @@ -1,150 +1 @@
  -package org.apache.ojb.odmg.states;
  -
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.odmg.ObjectEnvelope;
  -
  -/**
  - * this state represents old Objects (i.e. already persistent but not changed during tx)
  - * --> no need to do anything for commit or rollback
  - */
  -public class StateOldClean extends ModificationState
  -{
  -
  -    /**
  -     * return resulting state after marking clean
  -     */
  -    public ModificationState markClean()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking delete
  -     */
  -    public ModificationState markDelete()
  -    {
  -        return StateOldDelete.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking dirty
  -     */
  -    public ModificationState markDirty()
  -    {
  -        return StateOldDirty.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking new
  -     */
  -    public ModificationState markNew()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking old
  -     */
  -    public ModificationState markOld()
  -    {
  -        return this;
  -    }
  -
  -    private static StateOldClean _instance = new StateOldClean();
  -
  -    /**
  -     * private constructor: use singleton instance
  -     */
  -    private StateOldClean()
  -    {
  -    }
  -
  -    /**
  -     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  -     */
  -    public static StateOldClean getInstance()
  -    {
  -        return _instance;
  -    }
  -
  -    /**
  -     * rollback the ObjectModification
  -     */
  -    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -    }
  -
  -    /**
  -     * commit the associated transaction
  -     */
  -    public void commit(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -    }
  -
  -    /**
  -     * Method declaration
  -     *
  -     *
  -     * @param mod
  -     *
  -     *
  -     */
  -    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -    }
  -
  -}
  +package org.apache.ojb.odmg.states;


/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

import org.apache.ojb.broker.PersistenceBroker;

import org.apache.ojb.odmg.ObjectEnvelope;

/**
 * this state represents old Objects (i.e. already persistent but not changed during tx)
 * --> no need to do anything for commit or rollback
 */
public class StateOldClean extends ModificationState
{
    private static StateOldClean _instance = new StateOldClean();

    /**
     * private constructor: use singleton instance
     */
    private StateOldClean()
    {

    }

    /**
     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
     */
    public static StateOldClean getInstance()
    {
        return _instance;
    }

    /**
     * return resulting state after marking clean
     */
    public ModificationState markClean()
    {
        return this;
    }

    /**
     * return resulting state after marking delete
     */
    public ModificationState markDelete()
    {
        return StateOldDelete.getInstance();
    }

    /**
     * return resulting state after marking dirty
     */
    public ModificationState markDirty()
    {
        return StateOldDirty.getInstance();
    }

    /**
     * return resulting state after marking new
     */
    public ModificationState markNew()
    {
        return this;
    }

    /**
     * return resulting state after marking old
     */
    public ModificationState markOld()
    {
        return this;
    }

    /**
     * rollback the ObjectModification
     */
    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
    {

    }

    /**
     * commit the associated transaction
     */
    public void commit(ObjectEnvelope mod, PersistenceBroker broker)
    {

    }

    /**
     *
     */
    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
    {

    }
}

  \ No newline at end of file
  
  
  
  1.3       +1 -161    db-ojb/src/java/org/apache/ojb/odmg/states/StateNewDelete.java
  
  Index: StateNewDelete.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateNewDelete.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateNewDelete.java	17 Jun 2002 19:34:32 -0000	1.2
  +++ StateNewDelete.java	13 Nov 2003 14:52:40 -0000	1.3
  @@ -1,161 +1 @@
  -package org.apache.ojb.odmg.states;
  -
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.odmg.ObjectEnvelope;
  -
  -/**
  - * this state represents new objects which have been mrked for deletion during tx.
  - */
  -public class StateNewDelete extends ModificationState
  -{
  -
  -    /**
  -     * return resulting state after marking clean
  -     */
  -    public ModificationState markClean()
  -    {
  -        return StateNewClean.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking delete
  -     */
  -    public ModificationState markDelete()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking dirty
  -     */
  -    public ModificationState markDirty()
  -    {
  -        return StateNewDirty.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking new
  -     */
  -    public ModificationState markNew()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking old
  -     */
  -    public ModificationState markOld()
  -    {
  -        return StateOldDelete.getInstance();
  -    }
  -    
  -    /**
  -     * returns true is this state requires DELETE
  -     * @return boolean
  -     */
  -    public boolean needsDelete()
  -    {
  -        return true;
  -    }
  -    
  -
  -    private static StateNewDelete _instance = new StateNewDelete();
  -
  -    /**
  -     * private constructor: use singleton instance
  -     */
  -    private StateNewDelete()
  -    {
  -    }
  -
  -    /**
  -     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  -     */
  -    public static StateNewDelete getInstance()
  -    {
  -        return _instance;
  -    }
  -
  -    /**
  -     * rollback the ObjectModification
  -     */
  -    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -    }
  -
  -    /**
  -     * commit ObjectModification
  -     */
  -    public void commit(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -    /**
  -     * Method declaration
  -     *
  -     *
  -     * @param mod
  -     *
  -     *
  -     */
  -    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -}
  +package org.apache.ojb.odmg.states;


/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

import org.apache.ojb.broker.PersistenceBroker;

import org.apache.ojb.odmg.ObjectEnvelope;

/**
 * this state represents new objects which have been mrked for deletion during tx.
 */
public class StateNewDelete extends ModificationState
{
    private static StateNewDelete _instance = new StateNewDelete();

    /**
     * return resulting state after marking clean
     */
    public ModificationState markClean()
    {
        return StateNewClean.getInstance();
    }

    /**
     * return resulting state after marking delete
     */
    public ModificationState markDelete()
    {
        return this;
    }

    /**
     * return resulting state after marking dirty
     */
    public ModificationState markDirty()
    {
        return StateNewDirty.getInstance();
    }

    /**
     * return resulting state after marking new
     */
    public ModificationState markNew()
    {
        return this;
    }

    /**
     * return resulting state after marking old
     */
    public ModificationState markOld()
    {
        return StateOldDelete.getInstance();
    }

    /**
     * returns true is this state requires DELETE
     * @return boolean
     */
    public boolean needsDelete()
    {
        return true;
    }

    /**
     * private constructor: use singleton instance
     */
    private StateNewDelete()
    {
    }

    /**
     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
     */
    public static StateNewDelete getInstance()
    {
        return _instance;
    }

    /**
     * rollback the ObjectModification
     */
    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
    {
    }

    /**
     * commit ObjectModification
     */
    public void commit(ObjectEnvelope mod, PersistenceBroker broker)
    {
        this.removeFromCache(mod.getObject(), broker);
    }

    /**
     *
     */
    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
    {
        this.removeFromCache(mod.getObject(), broker);
    }
}

  \ No newline at end of file
  
  
  
  1.4       +16 -17    db-ojb/src/java/org/apache/ojb/odmg/states/StateNewClean.java
  
  Index: StateNewClean.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateNewClean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StateNewClean.java	24 Jan 2003 22:44:10 -0000	1.3
  +++ StateNewClean.java	13 Nov 2003 14:52:40 -0000	1.4
  @@ -63,6 +63,22 @@
    */
   public class StateNewClean extends ModificationState
   {
  +    private static StateNewClean _instance = new StateNewClean();
  +
  +    /**
  +     * private constructor: we use singleton instances
  +     */
  +    private StateNewClean()
  +    {
  +    }
  +
  +    /**
  +     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  +     */
  +    public static StateNewClean getInstance()
  +    {
  +        return _instance;
  +    }
   
       /**
        * return resulting state after marking clean
  @@ -102,23 +118,6 @@
       public ModificationState markOld()
       {
           return StateOldClean.getInstance();
  -    }
  -
  -    private static StateNewClean _instance = new StateNewClean();
  -
  -    /**
  -     * private constructor: we use singleton instances
  -     */
  -    private StateNewClean()
  -    {
  -    }
  -
  -    /**
  -     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  -     */
  -    public static StateNewClean getInstance()
  -    {
  -        return _instance;
       }
   
       /**
  
  
  
  1.8       +26 -22    db-ojb/src/java/org/apache/ojb/odmg/states/ModificationState.java
  
  Index: ModificationState.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/ModificationState.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ModificationState.java	28 Jul 2003 08:14:43 -0000	1.7
  +++ ModificationState.java	13 Nov 2003 14:52:40 -0000	1.8
  @@ -58,12 +58,13 @@
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.odmg.ObjectEnvelope;
  -import org.apache.ojb.odmg.LoadedObjectsRegistry;
  +
  +import java.io.Serializable;
   
   /**
    * Describes an objects transactional state regarding commiting and rollbacking
    */
  -public abstract class ModificationState extends Object implements java.io.Serializable
  +public abstract class ModificationState extends Object implements Serializable
   {
   
       public ModificationState()
  @@ -96,6 +97,23 @@
       public abstract ModificationState markOld();
   
       /**
  +     *
  +     */
  +    public abstract void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  +            throws PersistenceBrokerException;
  +
  +    /**
  +     *
  +     */
  +    public abstract void commit(ObjectEnvelope mod, PersistenceBroker broker)
  +            throws PersistenceBrokerException;
  +
  +    /**
  +     *
  +     */
  +    public abstract void rollback(ObjectEnvelope mod, PersistenceBroker broker);
  +
  +    /**
        * return a String representation
        * @return java.lang.String
        */
  @@ -145,30 +163,16 @@
               TODO: check out
               objects must also be remove from
               LoadedObjectsRegistry - Fix by Jamie Burns ????
  +
  +            arminw:
  +            remove LOR from code base
               */
  -            LoadedObjectsRegistry.remove(objToBeRemoved);
  +            // LoadedObjectsRegistry.remove(objToBeRemoved);
           }
           catch (PersistenceBrokerException e)
           {
  -            LoggerFactory.getDefaultLogger().error("Could not remove object from cache. obj was " +
  -                    objToBeRemoved + ",  used PB " + broker, e);
  +            LoggerFactory.getDefaultLogger().error("[" + this.getClass().getName() + "]" +
  +                    " Can't remove object from cache. obj was " + objToBeRemoved + ",  used PB " + broker, e);
           }
       }
  -
  -    /**
  -     *
  -     */
  -    public abstract void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -            throws PersistenceBrokerException;
  -
  -    /**
  -     *
  -     */
  -    public abstract void commit(ObjectEnvelope mod, PersistenceBroker broker)
  -            throws PersistenceBrokerException;
  -
  -    /**
  -     *
  -     */
  -    public abstract void rollback(ObjectEnvelope mod, PersistenceBroker broker);
   }
  
  
  
  1.3       +1 -184    db-ojb/src/java/org/apache/ojb/odmg/locking/ReadUncommittedStrategy.java
  
  Index: ReadUncommittedStrategy.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/locking/ReadUncommittedStrategy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReadUncommittedStrategy.java	17 Jun 2002 19:34:31 -0000	1.2
  +++ ReadUncommittedStrategy.java	13 Nov 2003 14:52:40 -0000	1.3
  @@ -1,184 +1 @@
  -package org.apache.ojb.odmg.locking;
  -
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -import org.apache.ojb.odmg.TransactionImpl;
  -
  -/**
  - * The implementation of the Uncommited Reads Locking strategy.
  - * This strategy is the loosest of them all.  It says
  - * you shouldn't need to get any Read locks whatsoever,
  - * but since it will probably try to get them, it will
  - * always give it to them.
  - *
  - * Locks are obtained on modifications to the database and held until end of
  - * transaction (EOT). Reading from the database does not involve any locking.
  - *
  - * Allows:
  - * Dirty Reads
  - * Non-Repeatable Reads
  - * Phantom Reads
  - *
  - * @author Thomas Mahler & David Dixon-Peugh
  - */
  -public class ReadUncommittedStrategy extends AbstractLockStrategy
  -{
  -
  -    /**
  -     * acquire a read lock on Object obj for Transaction tx.
  -     * @param tx the transaction requesting the lock
  -     * @param obj the Object to be locked
  -     * @return true if successful, else false
  -     * When we read Uncommitted, we don't care about Reader locks
  -     */
  -    public boolean readLock(TransactionImpl tx, Object obj)
  -    {
  -        return true;
  -    }
  -
  -    /**
  -     * acquire a write lock on Object obj for Transaction tx.
  -     * @param tx the transaction requesting the lock
  -     * @param obj the Object to be locked
  -     * @return true if successful, else false
  -     *
  -     */
  -    public boolean writeLock(TransactionImpl tx, Object obj)
  -    {
  -        LockEntry writer = getWriter(obj);
  -        if (writer == null)
  -        {
  -            if (setWriter(tx, obj))
  -                return true;
  -            else
  -                return writeLock(tx, obj);
  -        }
  -        if (writer.isOwnedBy(tx))
  -        {
  -            return true;    // If I'm the writer, then I can write.
  -        }
  -
  -        return false;
  -
  -    }
  -
  -    /**
  -     * acquire a lock upgrade (from read to write) lock on Object obj for Transaction tx.
  -     * @param tx the transaction requesting the lock
  -     * @param obj the Object to be locked
  -     * @return true if successful, else false
  -     *
  -     */
  -    public boolean upgradeLock(TransactionImpl tx, Object obj)
  -    {
  -        LockEntry writer = getWriter(obj);
  -        if (writer == null)
  -        {
  -            if (setWriter(tx, obj))
  -                return true;
  -            else
  -                return upgradeLock(tx, obj);
  -        }
  -        if (writer.isOwnedBy(tx))
  -        {
  -            return true;    // If I already have Write, then I've upgraded.
  -        }
  -        return false;
  -
  -    }
  -
  -    /**
  -     * release a lock on Object obj for Transaction tx.
  -     * @param tx the transaction releasing the lock
  -     * @param obj the Object to be unlocked
  -     * @return true if successful, else false
  -     *
  -     */
  -    public boolean releaseLock(TransactionImpl tx, Object obj)
  -    {
  -        LockEntry writer = getWriter(obj);
  -        if (writer != null && writer.isOwnedBy(tx))
  -        {
  -            removeWriter(writer);
  -
  -            return true;
  -        }
  -        // readlocks cannot (and need not) be released, thus:
  -        return true;
  -    }
  -
  -    /**
  -     * checks whether the specified Object obj is read-locked by Transaction tx.
  -     * @param tx the transaction
  -     * @param obj the Object to be checked
  -     * @return true if lock exists, else false
  -     */
  -    public boolean checkRead(TransactionImpl tx, Object obj)
  -    {
  -        return true;
  -    }
  -
  -    /**
  -     * checks whether the specified Object obj is write-locked by Transaction tx.
  -     * @param tx the transaction
  -     * @param obj the Object to be checked
  -     * @return true if lock exists, else false
  -     */
  -    public boolean checkWrite(TransactionImpl tx, Object obj)
  -    {
  -        LockEntry writer = getWriter(obj);
  -        return (writer != null && writer.isOwnedBy(tx));
  -    }
  -}
  +package org.apache.ojb.odmg.locking;


/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

import org.apache.ojb.odmg.TransactionImpl;

/**
 * The implementation of the Uncommited Reads Locking strategy.
 * This strategy is the loosest of them all.  It says
 * you shouldn't need to get any Read locks whatsoever,
 * but since it will probably try to get them, it will
 * always give it to them.
 *
 * Locks are obtained on modifications to the database and held until end of
 * transaction (EOT). Reading from the database does not involve any locking.
 *
 * Allows:
 * Dirty Reads
 * Non-Repeatable Reads
 * Phantom Reads
 *
 * @author Thomas Mahler & David Dixon-Peugh
 */
public class ReadUncommittedStrategy extends AbstractLockStrategy
{
    /**
     * acquire a read lock on Object obj for Transaction tx.
     * @param tx the transaction requesting the lock
     * @param obj the Object to be locked
     * @return true if successful, else false
     * When we read Uncommitted, we don't care about Reader locks
     */
    public boolean readLock(TransactionImpl tx, Object obj)
    {
        return true;
    }

    /**
     * acquire a write lock on Object obj for Transaction tx.
     * @param tx the transaction requesting the lock
     * @param obj the Object to be locked
     * @return true if successful, else false
     *
     */
    public boolean writeLock(TransactionImpl tx, Object obj)
    {
        LockEntry writer = getWriter(obj);
        if (writer == null)
        {
            if (setWriter(tx, obj))
                return true;
            else
                return writeLock(tx, obj);
        }
        if (writer.isOwnedBy(tx))
        {
            return true;    // If I'm the writer, then I can write.
        }
        return false;
    }

    /**
     * acquire a lock upgrade (from read to write) lock on Object obj for Transaction tx.
     * @param tx the transaction requesting the lock
     * @param obj the Object to be locked
     * @return true if successful, else false
     *
     */
    public boolean upgradeLock(TransactionImpl tx, Object obj)
    {
        LockEntry writer = getWriter(obj);
        if (writer == null)
        {
            if (setWriter(tx, obj))
                return true;
            else
                return upgradeLock(tx, obj);
        }
        if (writer.isOwnedBy(tx))
        {
            return true;    // If I already have Write, then I've upgraded.
        }
        return false;
    }

    /**
     * release a lock on Object obj for Transaction tx.
     * @param tx the transaction releasing the lock
     * @param obj the Object to be unlocked
     * @return true if successful, else false
     *
     */
    public boolean releaseLock(TransactionImpl tx, Object obj)
    {
        LockEntry writer = getWriter(obj);
        if (writer != null && writer.isOwnedBy(tx))
        {
            removeWriter(writer);
            return true;
        }
        // readlocks cannot (and need not) be released, thus:
        return true;
    }

    /**
     * checks whether the specified Object obj is read-locked by Transaction tx.
     * @param tx the transaction
     * @param obj the Object to be checked
     * @return true if lock exists, else false
     */
    public boolean checkRead(TransactionImpl tx, Object obj)
    {
        return true;
    }

    /**
     * checks whether the specified Object obj is write-locked by Transaction tx.
     * @param tx the transaction
     * @param obj the Object to be checked
     * @return true if lock exists, else false
     */
    public boolean checkWrite(TransactionImpl tx, Object obj)
    {
        LockEntry writer = getWriter(obj);
        return (writer != null && writer.isOwnedBy(tx));
    }
}


  \ No newline at end of file
  
  
  

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