cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r449417 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/remote/service/ test/java/org/apache/cayenne/ test/java/org/apache/cayenne/access/
Date Sun, 24 Sep 2006 15:53:10 GMT
Author: aadamchik
Date: Sun Sep 24 08:53:09 2006
New Revision: 449417

URL: http://svn.apache.org/viewvc?view=rev&rev=449417
Log:
CAY-666 - deprecating and disabling DataChannel events on ClientServerChannel.

Removed:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ClientServerChannelEventsTst.java
Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/service/BaseRemoteService.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextValidationTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ClientServerChannelTst.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.java?view=diff&rev=449417&r1=449416&r2=449417
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
Sun Sep 24 08:53:09 2006
@@ -24,10 +24,9 @@
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.event.EventManager;
-import org.apache.cayenne.graph.CompoundDiff;
 import org.apache.cayenne.graph.GraphDiff;
-import org.apache.cayenne.graph.GraphEvent;
 import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.query.Query;
 
 /**
@@ -40,19 +39,40 @@
 public class ClientServerChannel implements DataChannel {
 
     protected DataContext serverContext;
-    protected boolean lifecycleEventsEnabled;
-  
+    protected boolean lifecycleCallbacksEnabled;
+
     public ClientServerChannel(DataDomain domain) {
-        this(domain, false);
+        this(domain.createDataContext());
     }
 
+    ClientServerChannel(DataContext serverContext) {
+        this.serverContext = serverContext;
+    }
+
+    /**
+     * @deprecated since 3.0 as DataChannel events (incorrectly called "lifecycleEvents"
+     *             in 2.0) are no longer posted by ClientServerChannel.
+     */
     public ClientServerChannel(DataDomain domain, boolean lifecycleEventsEnabled) {
-        this(domain.createDataContext(), lifecycleEventsEnabled);
+        this(domain);
     }
 
-    ClientServerChannel(DataContext serverContext, boolean lifecycleEventsEnabled) {
-        this.serverContext = serverContext;
-        this.lifecycleEventsEnabled = lifecycleEventsEnabled;
+    /**
+     * @deprecated Since 3.0 - always returns false. This method was a misnomer referring
+     *             to DataChannel events, not lifecycle events introduced in 3.0.
+     *             Currently ClientServerChannel posts no channel events.
+     */
+    public boolean isLifecycleEventsEnabled() {
+        return false;
+    }
+
+    /**
+     * @deprecated Since 3.0 - does nothing. This method was a misnomer referring to
+     *             DataChannel events, not lifecycle events introduced in 3.0. Currently
+     *             ClientServerChannel posts no channel events.
+     */
+    public void setLifecycleEventsEnabled(boolean lifecycleEventsEnabled) {
+
     }
 
     public QueryResponse onQuery(ObjectContext context, Query query) {
@@ -71,14 +91,6 @@
         return serverContext != null ? serverContext.getEventManager() : null;
     }
 
-    public boolean isLifecycleEventsEnabled() {
-        return lifecycleEventsEnabled;
-    }
-
-    public void setLifecycleEventsEnabled(boolean lifecycleEventsEnabled) {
-        this.lifecycleEventsEnabled = lifecycleEventsEnabled;
-    }
-
     public GraphDiff onSync(
             ObjectContext originatingContext,
             GraphDiff changes,
@@ -102,15 +114,6 @@
 
         if (serverContext.hasChanges()) {
             serverContext.rollbackChanges();
-
-            if (lifecycleEventsEnabled) {
-                EventManager eventManager = getEventManager();
-                if (eventManager != null) {
-                    eventManager.postEvent(
-                            new GraphEvent(this, null),
-                            DataChannel.GRAPH_ROLLEDBACK_SUBJECT);
-                }
-            }
         }
 
         return null;
@@ -120,41 +123,32 @@
      * Applies child diff, without returning anything back.
      */
     GraphDiff onFlush(GraphDiff childDiff) {
-        serverContext.onSync(null, childDiff, DataChannel.FLUSH_NOCASCADE_SYNC);
-
-        if (lifecycleEventsEnabled) {
-            EventManager eventManager = getEventManager();
-
-            if (eventManager != null) {
-                eventManager.postEvent(
-                        new GraphEvent(this, childDiff),
-                        DataChannel.GRAPH_CHANGED_SUBJECT);
-            }
-        }
-
-        return null;
+        return serverContext.onSync(null, childDiff, DataChannel.FLUSH_NOCASCADE_SYNC);
     }
 
     /**
      * Applies child diff, and then commits.
      */
     GraphDiff onCommit(GraphDiff childDiff) {
-        GraphDiff diff = serverContext.onContextFlush(null, childDiff, true);
-
-        if (lifecycleEventsEnabled) {
-            EventManager eventManager = getEventManager();
+        return serverContext.onContextFlush(null, childDiff, true);
+    }
 
-            if (eventManager != null) {
-                CompoundDiff notification = new CompoundDiff();
-                notification.add(childDiff);
-                notification.add(diff);
-
-                eventManager.postEvent(
-                        new GraphEvent(this, notification),
-                        DataChannel.GRAPH_FLUSHED_SUBJECT);
-            }
-        }
+    /**
+     * @since 3.0
+     */
+    public boolean isLifecycleCallbacksEnabled() {
+        return lifecycleCallbacksEnabled;
+    }
 
-        return diff;
+    /**
+     * Enables or disables lifecycle event callbacks for the underlying ObjectContext used
+     * by this channel. Enabling callbacks allows server side logic to be applied to the
+     * persistent objects during select and commit operations.
+     * 
+     * @see LifecycleEventCallback
+     * @since 3.0
+     */
+    public void setLifecycleCallbacksEnabled(boolean lifecycleCallbacksEnabled) {
+        this.lifecycleCallbacksEnabled = lifecycleCallbacksEnabled;
     }
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/service/BaseRemoteService.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/service/BaseRemoteService.java?view=diff&rev=449417&r1=449416&r2=449417
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/service/BaseRemoteService.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/service/BaseRemoteService.java
Sun Sep 24 08:53:09 2006
@@ -167,7 +167,7 @@
     }
 
     protected DataChannel createChannel() {
-        return new ClientServerChannel(domain, false);
+        return new ClientServerChannel(domain);
     }
 
     /**

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsTst.java?view=diff&rev=449417&r1=449416&r2=449417
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsTst.java
Sun Sep 24 08:53:09 2006
@@ -51,7 +51,7 @@
         deleteTestData();
         createTestData("testSyncSimpleProperty");
 
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);
@@ -85,7 +85,7 @@
         deleteTestData();
         createTestData("testSyncToOneRelationship");
 
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);
@@ -122,7 +122,7 @@
         deleteTestData();
         createTestData("testSyncToManyRelationship");
 
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);
@@ -160,7 +160,7 @@
         deleteTestData();
         createTestData("testSyncToManyRelationship");
 
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);
@@ -201,7 +201,7 @@
         deleteTestData();
         createTestData("testSyncManyToManyRelationship");
 
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);
@@ -239,7 +239,7 @@
 
         deleteTestData();
 
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextValidationTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextValidationTst.java?view=diff&rev=449417&r1=449416&r2=449417
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextValidationTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneContextValidationTst.java
Sun Sep 24 08:53:09 2006
@@ -40,7 +40,7 @@
     public void testValidate() throws Exception {
 
         deleteTestData();
-        DataChannel serverChannel = new ClientServerChannel(getDomain(), false);
+        DataChannel serverChannel = new ClientServerChannel(getDomain());
         ClientChannel clientChannel = new ClientChannel(
                 new LocalConnection(serverChannel),
                 true);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ClientServerChannelTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ClientServerChannelTst.java?view=diff&rev=449417&r1=449416&r2=449417
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ClientServerChannelTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ClientServerChannelTst.java
Sun Sep 24 08:53:09 2006
@@ -78,7 +78,7 @@
         assertEquals(0, context.performQuery(query).size());
 
         // no changes...
-        ClientServerChannel channel = new ClientServerChannel(context, false);
+        ClientServerChannel channel = new ClientServerChannel(context);
         channel.onSync(context, new MockGraphDiff(), DataChannel.FLUSH_CASCADE_SYNC);
 
         assertEquals(0, context.performQuery(query).size());
@@ -98,9 +98,7 @@
         DataContext context = createDataContext();
 
         Query query = new SelectQuery("MtTable1");
-        QueryResponse response = new ClientServerChannel(context, false).onQuery(
-                null,
-                query);
+        QueryResponse response = new ClientServerChannel(context).onQuery(null, query);
 
         assertNotNull(response);
 
@@ -136,9 +134,7 @@
         DataContext context = createDataContext();
 
         Query query = new SelectQuery("MtTable3");
-        QueryResponse response = new ClientServerChannel(context, false).onQuery(
-                null,
-                query);
+        QueryResponse response = new ClientServerChannel(context).onQuery(null, query);
 
         assertNotNull(response);
 
@@ -178,7 +174,7 @@
                 query,
                 context.getEntityResolver());
 
-        QueryResponse response = new ClientServerChannel(context, false).onQuery(
+        QueryResponse response = new ClientServerChannel(context).onQuery(
                 null,
                 preprocessedQuery);
 
@@ -212,7 +208,7 @@
                 new MockDataRowStore()));
 
         QueryMessage message = new QueryMessage(new MockQuery());
-        new ClientServerChannel(context, false).onQuery(null, message.getQuery());
+        new ClientServerChannel(context).onQuery(null, message.getQuery());
         assertTrue(genericDone[0]);
     }
 
@@ -220,7 +216,7 @@
         createTestData("testPrefetching");
 
         DataContext context = createDataContext();
-        ClientServerChannel channel = new ClientServerChannel(context, false);
+        ClientServerChannel channel = new ClientServerChannel(context);
 
         SelectQuery q = new SelectQuery(ClientMtTable1.class);
         q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, true);
@@ -258,7 +254,7 @@
         createTestData("testPrefetching");
 
         DataContext context = createDataContext();
-        ClientServerChannel channel = new ClientServerChannel(context, false);
+        ClientServerChannel channel = new ClientServerChannel(context);
 
         SelectQuery q = new SelectQuery(ClientMtTable1.class);
         q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, true);



Mime
View raw message