cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r449435 - /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
Date Sun, 24 Sep 2006 16:52:13 GMT
Author: aadamchik
Date: Sun Sep 24 09:52:13 2006
New Revision: 449435

URL: http://svn.apache.org/viewvc?view=rev&rev=449435
Log:
CAY-666 - finished support for callbacks at the ClientServerChannel level

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ClientServerChannel.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=449435&r1=449434&r2=449435
==============================================================================
--- 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 09:52:13 2006
@@ -25,6 +25,7 @@
 import org.apache.cayenne.cache.QueryCache;
 import org.apache.cayenne.event.EventManager;
 import org.apache.cayenne.graph.GraphDiff;
+import org.apache.cayenne.intercept.DataChannelCallbackInterceptor;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.query.Query;
@@ -40,6 +41,7 @@
 
     protected DataContext serverContext;
     protected boolean lifecycleCallbacksEnabled;
+    protected DataChannel callbackInterceptor;
 
     public ClientServerChannel(DataDomain domain) {
         this(domain.createDataContext());
@@ -84,7 +86,7 @@
     }
 
     DataChannel getParentChannel() {
-        return serverContext;
+        return callbackInterceptor != null ? callbackInterceptor : serverContext;
     }
 
     public EntityResolver getEntityResolver() {
@@ -100,7 +102,7 @@
             GraphDiff changes,
             int syncType) {
 
-        return serverContext.onSync(null, changes, syncType);
+        return getParentChannel().onSync(null, changes, syncType);
     }
 
     /**
@@ -119,6 +121,25 @@
      * @since 3.0
      */
     public void setLifecycleCallbacksEnabled(boolean lifecycleCallbacksEnabled) {
-        this.lifecycleCallbacksEnabled = lifecycleCallbacksEnabled;
+        if (lifecycleCallbacksEnabled != this.lifecycleCallbacksEnabled) {
+            this.lifecycleCallbacksEnabled = lifecycleCallbacksEnabled;
+
+            if (lifecycleCallbacksEnabled) {
+                enableCallbacks();
+            }
+            else {
+                disableCallbacks();
+            }
+        }
+    }
+
+    void enableCallbacks() {
+        DataChannelCallbackInterceptor interceptor = new DataChannelCallbackInterceptor();
+        interceptor.setChannel(serverContext);
+        this.callbackInterceptor = interceptor;
+    }
+
+    void disableCallbacks() {
+        this.callbackInterceptor = null;
     }
 }



Mime
View raw message