cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r471974 - /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/ClientChannel.java
Date Tue, 07 Nov 2006 02:57:53 GMT
Author: aadamchik
Date: Mon Nov  6 18:57:53 2006
New Revision: 471974

URL: http://svn.apache.org/viewvc?view=rev&rev=471974
Log:
CAY-703 Cache EntityResolver in the ClientChannel

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/ClientChannel.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/ClientChannel.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/ClientChannel.java?view=diff&rev=471974&r1=471973&r2=471974
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/ClientChannel.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/ClientChannel.java
Mon Nov  6 18:57:53 2006
@@ -52,6 +52,7 @@
 
     protected ClientConnection connection;
     protected EventManager eventManager;
+    protected EntityResolver entityResolver;
     protected boolean channelEventsEnabled;
 
     EventBridge remoteChannelListener;
@@ -95,7 +96,7 @@
                 setupRemoteChannelListener();
             }
             catch (CayenneRuntimeException e) {
-                
+
             }
         }
     }
@@ -115,8 +116,6 @@
 
         if (context != null) {
 
-            // **** notice using EntityResolver from the context, as this channel does not
-            // cache it...
             EntityResolver resolver = context.getEntityResolver();
             QueryMetadata info = query.getMetaData(resolver);
 
@@ -221,8 +220,23 @@
         return replyDiff;
     }
 
+    /**
+     * Returns EntityResolver obtained from the server. On first access, this method sends
+     * a message to the server to retrieve the EntityResolver. On subsequent calls locally
+     * cached resolver is used.
+     */
     public EntityResolver getEntityResolver() {
-        return (EntityResolver) send(new BootstrapMessage(), EntityResolver.class);
+        if (entityResolver == null) {
+            synchronized (this) {
+                if (entityResolver == null) {
+                    entityResolver = (EntityResolver) send(
+                            new BootstrapMessage(),
+                            EntityResolver.class);
+                }
+            }
+        }
+
+        return entityResolver;
     }
 
     /**



Mime
View raw message