db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/odmg/states StateOldDirty.java StateNewDirty.java ModificationState.java StateNewClean.java
Date Fri, 24 Jan 2003 22:44:10 GMT
thma        2003/01/24 14:44:10

  Modified:    src/java/org/apache/ojb/odmg/states StateOldDirty.java
                        StateNewDirty.java ModificationState.java
                        StateNewClean.java
  Log:
  optimize commiting states by not passing ObjectEnvelopes to the PB, but only very thin INSERT
and UPDATE markers
  
  Revision  Changes    Path
  1.3       +107 -106  jakarta-ojb/src/java/org/apache/ojb/odmg/states/StateOldDirty.java
  
  Index: StateOldDirty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/states/StateOldDirty.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateOldDirty.java	17 Jun 2002 19:34:32 -0000	1.2
  +++ StateOldDirty.java	24 Jan 2003 22:44:10 -0000	1.3
  @@ -1,4 +1,4 @@
  -package org.apache.ojb.odmg.states;
  +package org.apache.ojb.odmg.states;
   
   /* ====================================================================
    * The Apache Software License, Version 1.1
  @@ -53,108 +53,109 @@
    * 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 altered during tx.
  - */
  -public class StateOldDirty 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 this;
  -    }
  -
  -    /**
  -     * return resulting state after marking new
  -     */
  -    public ModificationState markNew()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking old
  -     */
  -    public ModificationState markOld()
  -    {
  -        return this;
  -    }
  -
  -    private static StateOldDirty _instance = new StateOldDirty();
  -
  -    /**
  -     * private constructor: use singleton instance
  -     */
  -    private StateOldDirty()
  -    {
  -    }
  -
  -    /**
  -     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  -     */
  -    public static StateOldDirty getInstance()
  -    {
  -        return _instance;
  -    }
  -
  -    /**
  -     * checkpoint the transaction
  -     */
  -    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -            throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.store(mod.getObject(), mod);
  -        mod.manage(mod.getObject());
  -        mod.setModificationState(StateOldClean.getInstance());
  -    }
  -
  -    /**
  -     * commit the associated transaction
  -     */
  -    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.store(mod.getObject(), mod);
  -        mod.manage(mod.getObject());
  -        mod.setModificationState(StateOldClean.getInstance());
  -    }
  -
  -    /**
  -     * rollback transaction.
  -     */
  -    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -    /*
  -     * @see ModificationState#needsUpdate()
  -     */
  -    public boolean needsUpdate()
  -    {
  -        return true;
  -    }
  -
  -}
  +
  +import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
  +import org.apache.ojb.odmg.ObjectEnvelope;
  +
  +/**
  + * this state represents old objects which have been altered during tx.
  + */
  +public class StateOldDirty 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 this;
  +    }
  +
  +    /**
  +     * return resulting state after marking new
  +     */
  +    public ModificationState markNew()
  +    {
  +        return this;
  +    }
  +
  +    /**
  +     * return resulting state after marking old
  +     */
  +    public ModificationState markOld()
  +    {
  +        return this;
  +    }
  +
  +    private static StateOldDirty _instance = new StateOldDirty();
  +
  +    /**
  +     * private constructor: use singleton instance
  +     */
  +    private StateOldDirty()
  +    {
  +    }
  +
  +    /**
  +     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  +     */
  +    public static StateOldDirty getInstance()
  +    {
  +        return _instance;
  +    }
  +
  +    /**
  +     * checkpoint the transaction
  +     */
  +    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  +            throws org.apache.ojb.broker.PersistenceBrokerException
  +    {
  +        broker.store(mod.getObject(), ObjectModificationDefaultImpl.UPDATE);
  +        mod.manage(mod.getObject());
  +        mod.setModificationState(StateOldClean.getInstance());
  +    }
  +
  +    /**
  +     * commit the associated transaction
  +     */
  +    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  +    {
  +        broker.store(mod.getObject(), ObjectModificationDefaultImpl.UPDATE);
  +        mod.manage(mod.getObject());
  +        mod.setModificationState(StateOldClean.getInstance());
  +    }
  +
  +    /**
  +     * rollback transaction.
  +     */
  +    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  +    {
  +        this.removeFromCache(mod.getObject(), broker);
  +    }
  +
  +    /*
  +     * @see ModificationState#needsUpdate()
  +     */
  +    public boolean needsUpdate()
  +    {
  +        return true;
  +    }
  +
  +}
  
  
  
  1.3       +108 -107  jakarta-ojb/src/java/org/apache/ojb/odmg/states/StateNewDirty.java
  
  Index: StateNewDirty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/states/StateNewDirty.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateNewDirty.java	17 Jun 2002 19:34:32 -0000	1.2
  +++ StateNewDirty.java	24 Jan 2003 22:44:10 -0000	1.3
  @@ -1,4 +1,4 @@
  -package org.apache.ojb.odmg.states;
  +package org.apache.ojb.odmg.states;
   
   /* ====================================================================
    * The Apache Software License, Version 1.1
  @@ -53,109 +53,110 @@
    * 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 altered during tx.
  - */
  -public class StateNewDirty extends ModificationState
  -{
  -
  -    /**
  -     * return resulting state after marking clean
  -     */
  -    public ModificationState markClean()
  -    {
  -        return StateNewClean.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking delete
  -     */
  -    public ModificationState markDelete()
  -    {
  -        return StateNewDelete.getInstance();
  -    }
  -
  -    /**
  -     * return resulting state after marking dirty
  -     */
  -    public ModificationState markDirty()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking new
  -     */
  -    public ModificationState markNew()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking old
  -     */
  -    public ModificationState markOld()
  -    {
  -        return StateOldDirty.getInstance();
  -    }
  -
  -    private static StateNewDirty _instance = new StateNewDirty();
  -
  -    /**
  -     * private constructor: use singleton instance.
  -     */
  -    private StateNewDirty()
  -    {
  -    }
  -
  -    /**
  -     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  -     */
  -    public static StateNewDirty getInstance()
  -    {
  -        return _instance;
  -    }
  -
  -    /**
  -     * object is new, thus we need an INSERT to store it
  -     */
  -    public boolean needsInsert()
  -    {
  -        return true;
  -    }
  -
  -    /**
  -     * checkpoint the ObjectModification
  -     */
  -    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -            throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.store(mod.getObject(), mod);
  -        mod.manage(mod.getObject());
  -        mod.setModificationState(StateOldClean.getInstance());
  -    }
  -
  -    /**
  -     * commit the associated transaction
  -     */
  -    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.store(mod.getObject(), mod);
  -        mod.manage(mod.getObject());
  -        mod.setModificationState(StateOldClean.getInstance());
  -    }
  -
  -    /**
  -     * rollback
  -     *
  -     */
  -    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -}
  +
  +import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
  +import org.apache.ojb.odmg.ObjectEnvelope;
  +
  +/**
  + * this state represents new objects which have been altered during tx.
  + */
  +public class StateNewDirty extends ModificationState
  +{
  +
  +    /**
  +     * return resulting state after marking clean
  +     */
  +    public ModificationState markClean()
  +    {
  +        return StateNewClean.getInstance();
  +    }
  +
  +    /**
  +     * return resulting state after marking delete
  +     */
  +    public ModificationState markDelete()
  +    {
  +        return StateNewDelete.getInstance();
  +    }
  +
  +    /**
  +     * return resulting state after marking dirty
  +     */
  +    public ModificationState markDirty()
  +    {
  +        return this;
  +    }
  +
  +    /**
  +     * return resulting state after marking new
  +     */
  +    public ModificationState markNew()
  +    {
  +        return this;
  +    }
  +
  +    /**
  +     * return resulting state after marking old
  +     */
  +    public ModificationState markOld()
  +    {
  +        return StateOldDirty.getInstance();
  +    }
  +
  +    private static StateNewDirty _instance = new StateNewDirty();
  +
  +    /**
  +     * private constructor: use singleton instance.
  +     */
  +    private StateNewDirty()
  +    {
  +    }
  +
  +    /**
  +     * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects
  +     */
  +    public static StateNewDirty getInstance()
  +    {
  +        return _instance;
  +    }
  +
  +    /**
  +     * object is new, thus we need an INSERT to store it
  +     */
  +    public boolean needsInsert()
  +    {
  +        return true;
  +    }
  +
  +    /**
  +     * checkpoint the ObjectModification
  +     */
  +    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  +            throws org.apache.ojb.broker.PersistenceBrokerException
  +    {
  +        broker.store(mod.getObject(), ObjectModificationDefaultImpl.INSERT);
  +        mod.manage(mod.getObject());
  +        mod.setModificationState(StateOldClean.getInstance());
  +    }
  +
  +    /**
  +     * commit the associated transaction
  +     */
  +    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  +    {
  +        broker.store(mod.getObject(), ObjectModificationDefaultImpl.INSERT);
  +        mod.manage(mod.getObject());
  +        mod.setModificationState(StateOldClean.getInstance());
  +    }
  +
  +    /**
  +     * rollback
  +     *
  +     */
  +    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  +    {
  +        this.removeFromCache(mod.getObject(), broker);
  +    }
  +
  +}
  
  
  
  1.4       +1 -1      jakarta-ojb/src/java/org/apache/ojb/odmg/states/ModificationState.java
  
  Index: ModificationState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/states/ModificationState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ModificationState.java	7 Sep 2002 19:57:14 -0000	1.3
  +++ ModificationState.java	24 Jan 2003 22:44:10 -0000	1.4
  @@ -141,7 +141,7 @@
           try
           {
               broker.removeFromCache(objToBeRemoved);
  -            broker.invalidate(new Identity(objToBeRemoved));
  +            broker.invalidate(new Identity(objToBeRemoved, broker));
           }
           catch (PersistenceBrokerException e)
           {
  
  
  
  1.3       +108 -107  jakarta-ojb/src/java/org/apache/ojb/odmg/states/StateNewClean.java
  
  Index: StateNewClean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/states/StateNewClean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateNewClean.java	17 Jun 2002 19:34:32 -0000	1.2
  +++ StateNewClean.java	24 Jan 2003 22:44:10 -0000	1.3
  @@ -1,4 +1,4 @@
  -package org.apache.ojb.odmg.states;
  +package org.apache.ojb.odmg.states;
   
   /* ====================================================================
    * The Apache Software License, Version 1.1
  @@ -53,109 +53,110 @@
    * 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 not been altered during tx.
  - */
  -public class StateNewClean extends ModificationState
  -{
  -
  -    /**
  -     * return resulting state after marking clean
  -     */
  -    public ModificationState markClean()
  -    {
  -        return this;
  -    }
  -
  -    /**
  -     * return resulting state after marking delete
  -     */
  -    public ModificationState markDelete()
  -    {
  -        return StateNewDelete.getInstance();
  -    }
  -
  -    /**
  -     * 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 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;
  -    }
  -
  -    /**
  -     * object is new, thus we need an INSERT to store it
  -     */
  -    public boolean needsInsert()
  -    {
  -        return true;
  -    }
  -
  -    /**
  -     * checkpoint the transaction
  -     */
  -    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  -            throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.store(mod.getObject(), mod);
  -        mod.manage(mod.getObject());
  -        mod.setModificationState(StateOldClean.getInstance());
  -    }
  -
  -
  -    /**
  -     * commit the associated transaction
  -     */
  -    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  -    {
  -        broker.store(mod.getObject(), mod);
  -        mod.manage(mod.getObject());
  -        mod.setModificationState(StateOldClean.getInstance());
  -    }
  -
  -    /**
  -     * rollback the transaction
  -     */
  -    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  -    {
  -        this.removeFromCache(mod.getObject(), broker);
  -    }
  -
  -}
  +
  +import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
  +import org.apache.ojb.odmg.ObjectEnvelope;
  +
  +/**
  + * this state represents new objects which have not been altered during tx.
  + */
  +public class StateNewClean extends ModificationState
  +{
  +
  +    /**
  +     * return resulting state after marking clean
  +     */
  +    public ModificationState markClean()
  +    {
  +        return this;
  +    }
  +
  +    /**
  +     * return resulting state after marking delete
  +     */
  +    public ModificationState markDelete()
  +    {
  +        return StateNewDelete.getInstance();
  +    }
  +
  +    /**
  +     * 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 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;
  +    }
  +
  +    /**
  +     * object is new, thus we need an INSERT to store it
  +     */
  +    public boolean needsInsert()
  +    {
  +        return true;
  +    }
  +
  +    /**
  +     * checkpoint the transaction
  +     */
  +    public void checkpoint(ObjectEnvelope mod, PersistenceBroker broker)
  +            throws org.apache.ojb.broker.PersistenceBrokerException
  +    {
  +        broker.store(mod.getObject(), ObjectModificationDefaultImpl.INSERT);
  +        mod.manage(mod.getObject());
  +        mod.setModificationState(StateOldClean.getInstance());
  +    }
  +
  +
  +    /**
  +     * commit the associated transaction
  +     */
  +    public void commit(ObjectEnvelope mod, PersistenceBroker broker) throws org.apache.ojb.broker.PersistenceBrokerException
  +    {
  +        broker.store(mod.getObject(), ObjectModificationDefaultImpl.INSERT);
  +        mod.manage(mod.getObject());
  +        mod.setModificationState(StateOldClean.getInstance());
  +    }
  +
  +    /**
  +     * rollback the transaction
  +     */
  +    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
  +    {
  +        this.removeFromCache(mod.getObject(), broker);
  +    }
  +
  +}
  
  
  

Mime
View raw message