cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r560578 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/access/event/ test/java/org/apache/art/oneway/ test/java/org/apache/cayenne/access/
Date Sat, 28 Jul 2007 17:41:15 GMT
Author: aadamchik
Date: Sat Jul 28 10:41:14 2007
New Revision: 560578

URL: http://svn.apache.org/viewvc?view=rev&rev=560578
Log:
CAY-828 Remove DataContextTransactionEventListener, DataObjectTransactionEventListener, DataContextEvent

Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContextFlushEventHandler.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextEvent.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextTransactionEventListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataObjectTransactionEventListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEventsTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/art/oneway/Artist.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?view=diff&rev=560578&r1=560577&r2=560578
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
Sat Jul 28 10:41:14 2007
@@ -39,19 +39,16 @@
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.DeleteDenyException;
 import org.apache.cayenne.Fault;
-import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.QueryResponse;
-import org.apache.cayenne.access.event.DataContextEvent;
 import org.apache.cayenne.access.util.IteratedSelectObserver;
 import org.apache.cayenne.cache.QueryCache;
 import org.apache.cayenne.cache.QueryCacheFactory;
 import org.apache.cayenne.conf.Configuration;
 import org.apache.cayenne.event.EventManager;
-import org.apache.cayenne.event.EventSubject;
 import org.apache.cayenne.graph.CompoundDiff;
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.graph.GraphEvent;
@@ -102,17 +99,6 @@
  */
 public class DataContext extends BaseContext implements DataChannel {
 
-    // DataContext events
-    public static final EventSubject WILL_COMMIT = EventSubject.getSubject(
-            DataContext.class,
-            "DataContextWillCommit");
-    public static final EventSubject DID_COMMIT = EventSubject.getSubject(
-            DataContext.class,
-            "DataContextDidCommit");
-    public static final EventSubject DID_ROLLBACK = EventSubject.getSubject(
-            DataContext.class,
-            "DataContextDidRollback");
-
     /**
      * A holder of a DataContext bound to the current thread.
      * 
@@ -121,12 +107,6 @@
     // TODO: Andrus, 11/7/2005 - should we use InheritableThreadLocal instead?
     protected static final ThreadLocal threadDataContext = new ThreadLocal();
 
-    // event posting default for new DataContexts
-    private static boolean transactionEventsEnabledDefault;
-
-    // enable/disable event handling for individual instances
-    private boolean transactionEventsEnabled;
-
     // Set of DataContextDelegates to be notified.
     private DataContextDelegate delegate;
 
@@ -257,8 +237,6 @@
         // use a setter to properly initialize EntityResolver
         setChannel(channel);
 
-        this.setTransactionEventsEnabled(transactionEventsEnabledDefault);
-
         // inject self as parent context
         if (objectStore != null) {
             this.objectStore = objectStore;
@@ -968,7 +946,7 @@
      * 
      * @throws CayenneRuntimeException if object id doesn't match any records, or if there
      *             is more than one object is fetched.
-     * @deprecated since 3.0 use {@link ObjectIdQuery} with appropraite refresh settings.
+     * @deprecated since 3.0 use {@link ObjectIdQuery} with appropriate refresh settings.
      */
     public DataObject refetchObject(ObjectId oid) {
 
@@ -1134,8 +1112,6 @@
         // prevent multiple commits occuring simulteneously
         synchronized (objectStore) {
 
-            DataContextFlushEventHandler eventHandler = null;
-
             ObjectStoreGraphDiff changes = objectStore.getChanges();
             boolean noop = isValidatingObjectsOnCommit()
                     ? changes.validateAndCheckNoop()
@@ -1147,12 +1123,6 @@
                 return new CompoundDiff();
             }
 
-            if (isTransactionEventsEnabled()) {
-                eventHandler = new DataContextFlushEventHandler(this);
-                eventHandler.registerForDataContextEvents();
-                fireWillCommit();
-            }
-
             try {
                 GraphDiff returnChanges = getChannel().onSync(this, changes, syncType);
 
@@ -1166,9 +1136,6 @@
                     objectStore.postprocessAfterCommit(returnChanges);
                 }
 
-                // this is a legacy event ... will deprecate in 2.0
-                fireTransactionCommitted();
-
                 // this event is caught by peer nested DataContexts to synchronize the
                 // state
                 fireDataChannelCommitted(this, changes);
@@ -1183,8 +1150,6 @@
             }
             // "catch" is needed to unwrap OptimisticLockExceptions
             catch (CayenneRuntimeException ex) {
-                fireTransactionRolledback();
-
                 Throwable unwound = Util.unwindException(ex);
 
                 if (unwound instanceof CayenneRuntimeException) {
@@ -1194,12 +1159,6 @@
                     throw new CayenneRuntimeException("Commit Exception", unwound);
                 }
             }
-            finally {
-
-                if (isTransactionEventsEnabled()) {
-                    eventHandler.unregisterFromDataContextEvents();
-                }
-            }
         }
     }
 
@@ -1397,34 +1356,6 @@
     }
 
     /**
-     * Sets default for posting transaction events by new DataContexts.
-     * 
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
-     *             later 3.0 milestones.
-     */
-    public static void setTransactionEventsEnabledDefault(boolean flag) {
-        transactionEventsEnabledDefault = flag;
-    }
-
-    /**
-     * Enables or disables posting of transaction events by this DataContext.
-     * 
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
-     *             later 3.0 milestones.
-     */
-    public void setTransactionEventsEnabled(boolean flag) {
-        this.transactionEventsEnabled = flag;
-    }
-
-    /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
-     *             later 3.0 milestones.
-     */
-    public boolean isTransactionEventsEnabled() {
-        return this.transactionEventsEnabled;
-    }
-
-    /**
      * Returns <code>true</code> if the ObjectStore uses shared cache of a parent
      * DataDomain.
      * 
@@ -1452,43 +1383,6 @@
      */
     public void setValidatingObjectsOnCommit(boolean flag) {
         this.validatingObjectsOnCommit = flag;
-    }
-
-    /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
-     *             later 3.0 milestones.
-     */
-    void fireWillCommit() {
-        // post event: WILL_COMMIT
-        if (this.transactionEventsEnabled) {
-            DataContextEvent commitChangesEvent = new DataContextEvent(this);
-            getEventManager().postEvent(commitChangesEvent, DataContext.WILL_COMMIT);
-        }
-    }
-
-    /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
-     *             later 3.0 milestones.
-     */
-    void fireTransactionRolledback() {
-        // post event: DID_ROLLBACK
-        if ((this.transactionEventsEnabled)) {
-            DataContextEvent commitChangesEvent = new DataContextEvent(this);
-            getEventManager().postEvent(commitChangesEvent, DataContext.DID_ROLLBACK);
-        }
-    }
-
-    /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
-     *             later 3.0 milestones.
-     */
-    void fireTransactionCommitted() {
-        // old-style event
-        if ((this.transactionEventsEnabled)) {
-            DataContextEvent commitChangesEvent = new DataContextEvent(this);
-            getEventManager().postEvent(commitChangesEvent, DataContext.DID_COMMIT);
-        }
-
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/art/oneway/Artist.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/art/oneway/Artist.java?view=diff&rev=560578&r1=560577&r2=560578
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/art/oneway/Artist.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/art/oneway/Artist.java
Sat Jul 28 10:41:14 2007
@@ -18,10 +18,8 @@
  ****************************************************************/
 package org.apache.art.oneway;
 
-import org.apache.cayenne.access.event.DataContextEvent;
-import org.apache.cayenne.access.event.DataObjectTransactionEventListener;
 
-public class Artist extends org.apache.art.oneway.auto._Artist implements DataObjectTransactionEventListener
{
+public class Artist extends org.apache.art.oneway.auto._Artist {
     private boolean _receivedWillCommit = false;
     private boolean _receivedDidCommit = false;
 
@@ -32,14 +30,6 @@
         super();
     }
 
-    public void didCommit(DataContextEvent event) {
-        _receivedDidCommit = true;
-    }
-
-    public void willCommit(DataContextEvent event) {
-        _receivedWillCommit = true;
-    }
-
     public boolean receivedDidCommit() {
         return _receivedDidCommit;
     }
@@ -68,5 +58,4 @@
     public void setSomeOtherObjectProperty(Object object) {
         someOtherObjectProperty = object;
     }
-
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java?view=diff&rev=560578&r1=560577&r2=560578
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
Sat Jul 28 10:41:14 2007
@@ -30,7 +30,6 @@
 import org.apache.cayenne.DataObject;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.DataRow;
-import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
@@ -119,18 +118,6 @@
 
         context.setUserProperty("ABC", object);
         assertSame(object, context.getUserProperty("ABC"));
-    }
-
-    /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
-     *             removed in later 3.0 milestones.
-     */
-    public void testTransactionEventsEnabled() {
-        DataContext context = createDataContext();
-        context.setTransactionEventsEnabled(false);
-        assertFalse(context.isTransactionEventsEnabled());
-        context.setTransactionEventsEnabled(true);
-        assertTrue(context.isTransactionEventsEnabled());
     }
 
     public void testHasChangesNew() {



Mime
View raw message