cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r516397 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/
Date Fri, 09 Mar 2007 12:38:18 GMT
Author: aadamchik
Date: Fri Mar  9 04:38:17 2007
New Revision: 516397

URL: http://svn.apache.org/viewvc?view=rev&rev=516397
Log:
CAY-765 Programmatically overriding "use share cache" fails - 3.0 fix

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataDomainTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?view=diff&rev=516397&r1=516396&r2=516397
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Mar  9 04:38:17 2007
@@ -87,6 +87,8 @@
 CAY-751 AS400 datafields containing # in field names do not get mapped correctly
 CAY-752 Importing EOModel gives Cast Exception
 CAY-754 Local jNDI hack breaks when running with Jetty6-Maven
+CAY-764 Exception when importing an EOModel with single table inheritance
+CAY-765 Programmatically overriding "use share cache" fails
 
 API Changes
 ----------------------------------

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java?view=diff&rev=516397&r1=516396&r2=516397
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
Fri Mar  9 04:38:17 2007
@@ -312,7 +312,8 @@
     /**
      * Returns <code>true</code> if DataContexts produced by this DataDomain
are using
      * shared DataRowStore. Returns <code>false</code> if each DataContext would
work
-     * with its own DataRowStore.
+     * with its own DataRowStore. Note that this setting can be overwritten per
+     * DataContext. See {@link #createDataContext(boolean)}.
      */
     public boolean isSharedCacheEnabled() {
         return sharedCacheEnabled;
@@ -392,7 +393,7 @@
 
     /**
      * Returns snapshots cache for this DataDomain, lazily initializing it on the first
-     * call.
+     * call if 'sharedCacheEnabled' flag is true.
      */
     public synchronized DataRowStore getSharedSnapshotCache() {
         if (sharedSnapshotCache == null && sharedCacheEnabled) {
@@ -401,6 +402,21 @@
 
         return sharedSnapshotCache;
     }
+    
+    /**
+     * Returns a guaranteed non-null shared snapshot cache regardless of the
+     * 'sharedCacheEnabled' flag setting. This allows to build DataContexts that do not
+     * follow the default policy.
+     * 
+     * @since 3.0
+     */
+    synchronized DataRowStore nonNullSharedSnapshotCache() {
+        if (sharedSnapshotCache == null) {
+            this.sharedSnapshotCache = new DataRowStore(name, properties, eventManager);
+        }
+
+        return sharedSnapshotCache;
+    }
 
     /**
      * Shuts down the previous cache instance, sets cache to the new DataSowStore instance
@@ -561,7 +577,7 @@
         // for new dataRowStores use the same name for all stores
         // it makes it easier to track the event subject
         DataRowStore snapshotCache = (useSharedCache)
-                ? getSharedSnapshotCache()
+                ? nonNullSharedSnapshotCache()
                 : new DataRowStore(name, properties, eventManager);
 
         DataContext context;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataDomainTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataDomainTest.java?view=diff&rev=516397&r1=516396&r2=516397
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataDomainTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataDomainTest.java
Fri Mar  9 04:38:17 2007
@@ -177,24 +177,32 @@
                 .getSharedSnapshotCache());
     }
 
-    public void testCreateDataContextWithLocalCache() throws Exception {
+    public void testCreateDataContextWithDedicatedCache() throws Exception {
         Map properties = new HashMap();
         properties
                 .put(DataDomain.SHARED_CACHE_ENABLED_PROPERTY, Boolean.FALSE.toString());
 
         DataDomain domain = new DataDomain("d1", properties);
         assertFalse(domain.isSharedCacheEnabled());
-
-        DataContext c2 = domain.createDataContext(true);
-        assertSame(c2.getObjectStore().getDataRowCache(), domain.getSharedSnapshotCache());
+        assertNull(domain.getSharedSnapshotCache());
 
         DataContext c3 = domain.createDataContext(false);
+        assertNotNull(c3.getObjectStore().getDataRowCache());
+        assertNull(domain.getSharedSnapshotCache());
         assertNotSame(c3.getObjectStore().getDataRowCache(), domain
                 .getSharedSnapshotCache());
 
         DataContext c1 = domain.createDataContext();
+        assertNotNull(c1.getObjectStore().getDataRowCache());
+        assertNull(domain.getSharedSnapshotCache());
         assertNotSame(c1.getObjectStore().getDataRowCache(), domain
                 .getSharedSnapshotCache());
+
+        // this should trigger shared cache creation
+        DataContext c2 = domain.createDataContext(true);
+        assertNotNull(c2.getObjectStore().getDataRowCache());
+        assertNotNull(domain.getSharedSnapshotCache());
+        assertSame(c2.getObjectStore().getDataRowCache(), domain.getSharedSnapshotCache());
 
         DataContext c4 = domain.createDataContext();
         assertNotSame(c4.getObjectStore().getDataRowCache(), c1



Mime
View raw message