You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/04/23 19:36:00 UTC

[5/6] isis git commit: ISIS-1134: added "isis.services.container.disableAutoFlush" configuration property.

ISIS-1134: added "isis.services.container.disableAutoFlush" configuration property.

Also updated Asciidoc docs.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/99723820
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/99723820
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/99723820

Branch: refs/heads/master
Commit: 99723820ec4ae7f416dc2761dd783eac57da8116
Parents: 909831e
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 23 18:28:32 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 23 18:29:11 2015 +0100

----------------------------------------------------------------------
 adocs/documentation/pom.xml                     |   2 +-
 ...nce-recognized-configuration-properties.adoc |  24 +++++
 .../user-guide/user-guide-reference.adoc        |   2 +
 adocs/template/document.html.erb                |   5 +-
 .../container/DomainObjectContainerDefault.java |  31 +++++-
 ...inObjectContainerDefaultTest_allMatches.java | 104 +++++++++++++++++++
 6 files changed, 163 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/99723820/adocs/documentation/pom.xml
----------------------------------------------------------------------
diff --git a/adocs/documentation/pom.xml b/adocs/documentation/pom.xml
index ed244b9..46dc725 100644
--- a/adocs/documentation/pom.xml
+++ b/adocs/documentation/pom.xml
@@ -31,7 +31,7 @@
     <version>1.9.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
-    <name>Apache Isis Documentation</name>
+    <name>Apache Isis Docs Documentation</name>
     <description>Documentation of Isis project.</description>
     <url>http://isis.apache.org/documentation</url>
 

http://git-wip-us.apache.org/repos/asf/isis/blob/99723820/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference-recognized-configuration-properties.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference-recognized-configuration-properties.adoc b/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference-recognized-configuration-properties.adoc
new file mode 100644
index 0000000..0e9a2a2
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference-recognized-configuration-properties.adoc
@@ -0,0 +1,24 @@
+= Recognized Configuration Properties
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+IMPORTANT: TODO
+
+
+.Configuration Properties
+[cols="2,1,3", options="header"]
+|===
+|Property
+|Value
+|Description
+
+|`isis.services`
+|`FQCN`,`FQCN2`,...
+|Fully qualified class names of classes to be instantiated as domain services.  Each entry can be optionally prefixed by "n:" specifying the relative order on the menu (corresponds to `@DomainServiceLayout#menuOrder()`).
+
+|`isis.services.` `container.disableAutoFlush`
+|`true`,`_false_`
+|Whether the `DomainObjectContainer` should automatically flush pending changes prior to querying (via `allMatches()`, `firstMatch()` and so on).
+|===
+

http://git-wip-us.apache.org/repos/asf/isis/blob/99723820/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference.adoc b/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference.adoc
index f94a77a..07ed17d 100644
--- a/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference.adoc
+++ b/adocs/documentation/src/main/asciidoc/user-guide/user-guide-reference.adoc
@@ -9,6 +9,8 @@ include::user-guide-reference-recognized-methods.adoc[leveloffset=+1]
 
 include::user-guide-reference-recognized-annotations.adoc[leveloffset=+1]
 
+include::user-guide-reference-recognized-configuration-properties.adoc[leveloffset=+1]
+
 include::user-guide-reference-domain-services.adoc[leveloffset=+1]
 
 include::user-guide-reference-value-types.adoc[leveloffset=+1]

http://git-wip-us.apache.org/repos/asf/isis/blob/99723820/adocs/template/document.html.erb
----------------------------------------------------------------------
diff --git a/adocs/template/document.html.erb b/adocs/template/document.html.erb
index 7f1201f..2986460 100644
--- a/adocs/template/document.html.erb
+++ b/adocs/template/document.html.erb
@@ -214,7 +214,7 @@
 </div>
 
 <div class="row">
-    <div class="large-8 medium-8 columns">
+    <div class="large-9 medium-9 columns">
 
         <div id="doc-content">
           <%= document.content %>
@@ -231,8 +231,7 @@
 
     </div>
 
-    <div class="large-4 medium-4 columns">
-        <!-- the 'hide' class is removed by Javascript -->
+    <div class="large-3 medium-3 columns">
         <div id="toc" class="<%= attr 'toc-class', 'toc2' %>">
           <%= converter.convert_with_options @document, 'outline', :toclevels => 6  %>
         </div>

http://git-wip-us.apache.org/repos/asf/isis/blob/99723820/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
index 3734ef5..9f04a15 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
@@ -542,7 +542,13 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
     @Programmatic
     @Override
     public <T> List<T> allMatches(final Query<T> query) {
-        flush(); // auto-flush any pending changes
+        if(autoFlush) {
+            flush(); // auto-flush any pending changes
+        }
+        return submitQuery(query);
+    }
+
+    <T> List<T> submitQuery(final Query<T> query) {
         final List<ObjectAdapter> allMatching = getQuerySubmitter().allMatchingQuery(query);
         return ObjectAdapter.Util.unwrapT(allMatching);
     }
@@ -686,12 +692,35 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
 
     //region > init, shutdown
 
+    /**
+     * Normally any queries are automatically preceded by flushing pending executions.
+     *
+     * <p>
+     * This key allows this behaviour to be disabled.
+     *
+     * <p>
+     *     Originally introduced as part of ISIS-1134 (fixing memory leaks in the objectstore)
+     *     where it was found that the autoflush behaviour was causing a (now unrepeatable)
+     *     data integrity error (see <a href="https://issues.apache.org/jira/browse/ISIS-1134?focusedCommentId=14500638&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14500638">ISIS-1134 comment</a>, in the isis-module-security.
+     *     However, that this could be circumvented by removing the call to flush().
+     *     We don't want to break existing apps that might rely on this behaviour, on the
+     *     other hand we want to fix the memory leak.  Adding this configuration property
+     *     seems the most prudent way forward.
+     * </p>
+     */
+    private static final String KEY_DISABLE_AUTOFLUSH = "isis.services.container.disableAutoFlush";
+
+    private boolean autoFlush;
+
     @Programmatic
     @PostConstruct
     @Override
     public void init(Map<String, String> properties) {
         injectServicesInto(recognizer);
         recognizer.init(properties);
+
+        final boolean disableAutoFlush = Boolean.parseBoolean(properties.get(KEY_DISABLE_AUTOFLUSH));
+        this.autoFlush = !disableAutoFlush;
     }
 
     @Programmatic

http://git-wip-us.apache.org/repos/asf/isis/blob/99723820/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefaultTest_allMatches.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefaultTest_allMatches.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefaultTest_allMatches.java
new file mode 100644
index 0000000..666d060
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefaultTest_allMatches.java
@@ -0,0 +1,104 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.metamodel.services.container;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.query.Query;
+import org.apache.isis.core.metamodel.adapter.DomainObjectServices;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class DomainObjectContainerDefaultTest_allMatches {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    private DomainObjectContainerDefault container;
+
+    @Mock
+    private DomainObjectServices mockDomainObjectServices;
+
+    private boolean flushCalled;
+
+    @Before
+    public void setUp() throws Exception {
+        container = new DomainObjectContainerDefault() {
+            @Override public boolean flush() {
+                flushCalled = true;
+                return true;
+            }
+
+            @Override <T> List<T> submitQuery(final Query<T> query) {
+                return null;
+            }
+        };
+        container.setDomainObjectServices(mockDomainObjectServices);
+        context.allowing(mockDomainObjectServices);
+    }
+
+    @Test
+    public void whenAutoflush() throws Exception {
+        // given
+        Map map = new HashMap();
+        container.init(map);
+        // when
+        container.allMatches(null);
+        // then
+        assertThat(flushCalled, is(true));
+    }
+
+    @Test
+    public void whenDisableAutoflush() throws Exception {
+        // given
+        Map map = new HashMap() {{
+            put("isis.services.container.disableAutoFlush", "true");
+        }};
+        container.init(map);
+        // when
+        container.allMatches(null);
+        // then
+        assertThat(flushCalled, is(false));
+    }
+
+    @Test
+    public void whenDisableAutoflushSetToFalse() throws Exception {
+        // given
+        Map map = new HashMap() {{
+            put("isis.services.container.disableAutoFlush", "false");
+        }};
+        container.init(map);
+        // when
+        container.allMatches(null);
+        // then
+        assertThat(flushCalled, is(true));
+    }
+
+}