You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/03/26 09:46:32 UTC

[isis] branch master updated (5d6f3cd -> 0d6e7dd)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 5d6f3cd  Bump frontend-maven-plugin from 1.11.2 to 1.11.3
     new 00a1fce  ISIS-2573: xray: integrate with publishing (wip)
     new 0d6e7dd  ISIS-2589: Remove usage of deprecated Wicket API

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../publish/CommandPublisherDefault.java           |  30 +++---
 .../isis/core/runtimeservices/publish/_Xray.java   | 116 +++++++++++++++++++++
 .../publishing/jdo/JdoCommandPublishingTest.java   |   3 +-
 .../isis/viewer/wicket/ui/pages/PageAbstract.java  |  51 ++++-----
 .../isis/viewer/wicket/ui/pages/WebPageBase.java   |  12 ++-
 .../accmngt/AccountManagementPageAbstract.java     |  11 +-
 .../wicket/ui/pages/mmverror/MmvErrorPage.java     |  13 +--
 7 files changed, 172 insertions(+), 64 deletions(-)
 create mode 100644 core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/_Xray.java

[isis] 01/02: ISIS-2573: xray: integrate with publishing (wip)

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 00a1fce77466a65e8e51ea539c8d59845ea689af
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Mar 26 10:41:25 2021 +0100

    ISIS-2573: xray: integrate with publishing (wip)
---
 .../publish/CommandPublisherDefault.java           |  30 +++---
 .../isis/core/runtimeservices/publish/_Xray.java   | 116 +++++++++++++++++++++
 .../publishing/jdo/JdoCommandPublishingTest.java   |   3 +-
 3 files changed, 131 insertions(+), 18 deletions(-)

diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/CommandPublisherDefault.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/CommandPublisherDefault.java
index 3794cab..de823da 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/CommandPublisherDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/CommandPublisherDefault.java
@@ -34,10 +34,12 @@ import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.publishing.spi.CommandSubscriber;
 import org.apache.isis.commons.collections.Can;
 import org.apache.isis.commons.having.HasEnabling;
+import org.apache.isis.core.interaction.session.InteractionTracker;
 import org.apache.isis.core.metamodel.services.publishing.CommandPublisher;
 
 import lombok.NonNull;
 import lombok.RequiredArgsConstructor;
+import lombok.val;
 import lombok.extern.log4j.Log4j2;
 
 @Service
@@ -50,6 +52,7 @@ import lombok.extern.log4j.Log4j2;
 public class CommandPublisherDefault implements CommandPublisher {
     
     private final List<CommandSubscriber> subscribers;
+    private final InteractionTracker iaTracker;
     
     private Can<CommandSubscriber> enabledSubscribers;
     
@@ -60,30 +63,25 @@ public class CommandPublisherDefault implements CommandPublisher {
     }
 
     @Override
-    public void complete(final @NonNull Command command) { 
+    public void complete(final @NonNull Command command) {
         
-        if(!canPublish()) {
-            return;
-        }
-
-        if(!command.isPublishingEnabled()) {
-            return;
-        }
+        val canPublish = canPublish(command);
+        val handle = _Xray.enterCommandPublishing(iaTracker, command, canPublish, enabledSubscribers);
         
-        if(command.getLogicalMemberIdentifier() == null) {
-            // eg if seed fixtures
-            return;
+        if(canPublish) {
+            log.debug("about to PUBLISH command: {} to {}", command, enabledSubscribers);
+            enabledSubscribers.forEach(subscriber -> subscriber.onCompleted(command));    
         }
         
-        log.debug("about to PUSH command: {} to {}", command, enabledSubscribers);
-
-        enabledSubscribers.forEach(subscriber -> subscriber.onCompleted(command));
+        _Xray.exitCommandPublishing(handle);    
     }
     
     // -- HELPER
     
-    private boolean canPublish() {
-        return enabledSubscribers.isNotEmpty();
+    private boolean canPublish(final Command command) {
+        return enabledSubscribers.isNotEmpty()
+                && command.isPublishingEnabled()
+                && command.getLogicalMemberIdentifier() != null; // eg null when seed fixtures
     }
     
 
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/_Xray.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/_Xray.java
new file mode 100644
index 0000000..7c53f6f
--- /dev/null
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/publish/_Xray.java
@@ -0,0 +1,116 @@
+/*
+ *  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.runtimeservices.publish;
+
+import java.util.UUID;
+
+import javax.annotation.Nullable;
+
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.publishing.spi.CommandSubscriber;
+import org.apache.isis.commons.collections.Can;
+import org.apache.isis.commons.internal.debug.xray.XrayUi;
+import org.apache.isis.commons.internal.exceptions._Exceptions;
+import org.apache.isis.core.interaction.session.InteractionTracker;
+import org.apache.isis.core.runtime.util.XrayUtil;
+
+import lombok.Builder;
+import lombok.NonNull;
+import lombok.val;
+
+final class _Xray {
+    
+    static Handle enterCommandPublishing(
+            final @NonNull InteractionTracker iaTracker,
+            final @Nullable Command command,
+            final boolean canPublish,
+            final @NonNull Can<CommandSubscriber> enabledSubscribers) {
+        
+        if(!XrayUi.isXrayEnabled()
+                || !iaTracker.isInInteractionSession()) {
+            return null;
+        }
+        
+        final int authStackSize = iaTracker.getAuthenticationLayerCount();
+        val conversationId = iaTracker.getConversationId().orElseThrow(_Exceptions::unexpectedCodeReach);
+        
+        val handle = createHandle(conversationId, authStackSize, null, null);
+        val enteringLabel = "publishing";
+        
+        XrayUi.updateModel(model->{
+            model.lookupSequence(handle.sequenceId)
+            .ifPresent(sequence->{
+                val sequenceData = sequence.getData();
+                
+                sequenceData.alias("command-publisher", "Command-\nPublisher-\n(Default)");
+                
+                sequenceData.enter(handle.caller, "command-publisher");
+                
+                sequenceData.enter("executor", handle.callee, enteringLabel);
+            });
+        });
+        
+        return handle;
+    }
+
+
+    public static void exitCommandPublishing(final @Nullable Handle handle) {
+        
+        if(handle==null) {
+            return; // x-ray is not enabled
+        }
+        
+        XrayUi.updateModel(model->{
+            model.lookupSequence(handle.sequenceId)
+            .ifPresent(sequence->{
+                val sequenceData = sequence.getData();
+                sequenceData.exit(handle.callee, "command-publisher");
+                sequenceData.exit("executor", handle.caller);
+            });
+        });
+        
+    }
+    
+    // -- HELPER
+    
+    private static Handle createHandle(
+            final UUID interactionId,
+            final int authStackSize,
+            final String participantLabel,
+            final String enteringLabel) {
+
+        val handle = Handle.builder()
+                .sequenceId(XrayUtil.sequenceId(interactionId))
+                .caller(authStackSize>0
+                    ? XrayUtil.nestedInteractionId(authStackSize)
+                    : "thread")
+                .callee(participantLabel)
+                .build();
+        
+        return handle;
+    }
+    
+    @Builder
+    static final class Handle {
+        final @NonNull String sequenceId;
+        final @NonNull String caller;
+        final @NonNull String callee;
+    }
+    
+}
diff --git a/regressiontests/incubating/src/test/java/org/apache/isis/testdomain/applayer/publishing/jdo/JdoCommandPublishingTest.java b/regressiontests/incubating/src/test/java/org/apache/isis/testdomain/applayer/publishing/jdo/JdoCommandPublishingTest.java
index a57c0f7..d0470a9 100644
--- a/regressiontests/incubating/src/test/java/org/apache/isis/testdomain/applayer/publishing/jdo/JdoCommandPublishingTest.java
+++ b/regressiontests/incubating/src/test/java/org/apache/isis/testdomain/applayer/publishing/jdo/JdoCommandPublishingTest.java
@@ -42,7 +42,6 @@ import org.apache.isis.testdomain.applayer.publishing.conf.Configuration_usingCo
 import org.apache.isis.testdomain.conf.Configuration_usingJdo;
 import org.apache.isis.testdomain.util.CollectionAssertions;
 import org.apache.isis.testdomain.util.kv.KVStoreForTesting;
-import org.apache.isis.testing.integtestsupport.applib.IsisIntegrationTestAbstract;
 
 import lombok.val;
 
@@ -60,7 +59,7 @@ import lombok.val;
 @TestPropertySource({
     IsisPresets.UseLog4j2Test
 })
-class JdoCommandPublishingTest extends IsisIntegrationTestAbstract {
+class JdoCommandPublishingTest {
 
     @Inject private ApplicationLayerTestFactory testFactory;
     @Inject private KVStoreForTesting kvStore;

[isis] 02/02: ISIS-2589: Remove usage of deprecated Wicket API

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 0d6e7dd5163aa85ad6f8d382b53c4115509ceb1f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Mar 26 10:46:19 2021 +0100

    ISIS-2589: Remove usage of deprecated Wicket API
    
    also enables bootlint only when prototyping
---
 .../isis/viewer/wicket/ui/pages/PageAbstract.java  | 51 +++++++++-------------
 .../isis/viewer/wicket/ui/pages/WebPageBase.java   | 12 +++--
 .../accmngt/AccountManagementPageAbstract.java     | 11 ++---
 .../wicket/ui/pages/mmverror/MmvErrorPage.java     | 13 +++---
 4 files changed, 41 insertions(+), 46 deletions(-)

diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
index 0b20ce7..155dddc 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
@@ -47,9 +47,6 @@ import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.panel.EmptyPanel;
 import org.apache.wicket.model.IModel;
-import org.apache.wicket.protocol.http.ClientProperties;
-import org.apache.wicket.protocol.http.WebSession;
-import org.apache.wicket.protocol.http.request.WebClientInfo;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.request.resource.CssResourceReference;
 import org.apache.wicket.request.resource.JavaScriptResourceReference;
@@ -149,7 +146,7 @@ implements ActionPromptProvider {
 
             themeDiv = new WebMarkupContainer(ID_THEME);
             add(themeDiv);
-            String applicationName = getIsisConfiguration().getViewer().getWicket().getApplication().getName();
+            String applicationName = getConfiguration().getViewer().getWicket().getApplication().getName();
             if(applicationName != null) {
                 themeDiv.add(new CssClassAppender(CssClassAppender.asCssStyle(applicationName)));
             }
@@ -237,7 +234,7 @@ implements ActionPromptProvider {
     protected void setTitle(final String title) {
         addOrReplace(new Label(ID_PAGE_TITLE, title != null
                 ? title
-                : getIsisConfiguration().getViewer().getWicket().getApplication().getName()));
+                : getConfiguration().getViewer().getWicket().getApplication().getName()));
     }
 
     private Class<? extends Page> getSignInPage() {
@@ -263,19 +260,21 @@ implements ActionPromptProvider {
         final JGrowlBehaviour jGrowlBehaviour = new JGrowlBehaviour(getCommonContext());
         jGrowlBehaviour.renderFeedbackMessages(response);
 
-        getIsisConfiguration().getViewer().getWicket().getApplication().getCss()
-                .ifPresent(applicationCss -> {
-                    response.render(CssReferenceHeaderItem.forUrl(applicationCss));
-                });
-        getIsisConfiguration().getViewer().getWicket().getApplication().getJs()
-                .ifPresent(applicationJs -> {
-                    response.render(JavaScriptReferenceHeaderItem.forUrl(applicationJs));
-                } );
-
-        getCommonContext().getConfiguration().getViewer().getWicket().getLiveReloadUrl().ifPresent(liveReloadUrl -> {
+        getConfiguration().getViewer().getWicket().getApplication().getCss()
+        .ifPresent(applicationCss -> {
+            response.render(CssReferenceHeaderItem.forUrl(applicationCss));
+        });
+        
+        getConfiguration().getViewer().getWicket().getApplication().getJs()
+        .ifPresent(applicationJs -> {
+            response.render(JavaScriptReferenceHeaderItem.forUrl(applicationJs));
+        } );
+        
+        getConfiguration().getViewer().getWicket().getLiveReloadUrl().ifPresent(liveReloadUrl -> {
             response.render(JavaScriptReferenceHeaderItem.forUrl(liveReloadUrl));
         });
-        if(isModernBrowser()) {
+        
+        if(getSystemEnvironment().isPrototyping()) {
             addBootLint(response);
         }
 
@@ -303,24 +302,14 @@ implements ActionPromptProvider {
         return null;
     }
 
+    /**
+     * BootLint checks for malformed bootstrap CSS. It is probably only needed in PROTOTYPE mode.
+     */
     private void addBootLint(final IHeaderResponse response) {
         // rather than using the default BootlintHeaderItem.INSTANCE;
         // this allows us to assign 'form-control' class to an <a> (for x-editable styling)
-        response.render(new BootlintHeaderItem("bootlint.showLintReportForCurrentDocument(['E042'], {'problemFree': false});"));
-    }
-
-    private boolean isModernBrowser() {
-        return !isIePre9();
-    }
-
-    @SuppressWarnings("deprecation")
-    private boolean isIePre9() {
-        final WebClientInfo clientInfo = WebSession.get().getClientInfo();
-        final ClientProperties properties = clientInfo.getProperties();
-        if (properties.isBrowserInternetExplorer())
-            if (properties.getBrowserVersionMajor() < 9)
-                return true;
-        return false;
+        response.render(new BootlintHeaderItem(
+                "bootlint.showLintReportForCurrentDocument(['E042'], {'problemFree': false});"));
     }
 
     /**
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/WebPageBase.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/WebPageBase.java
index 3af58d9..680e1d1 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/WebPageBase.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/WebPageBase.java
@@ -26,6 +26,7 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;
 
 import org.apache.isis.commons.internal.base._Strings;
 import org.apache.isis.core.config.IsisConfiguration;
+import org.apache.isis.core.config.environment.IsisSystemEnvironment;
 import org.apache.isis.core.config.viewer.wicket.WebAppContextPath;
 import org.apache.isis.core.interaction.session.InteractionFactory;
 import org.apache.isis.core.runtime.context.IsisAppCommonContext;
@@ -42,7 +43,6 @@ implements HasCommonContext {
 
     private static final long serialVersionUID = 1L;
     
-    private transient IsisConfiguration isisConfiguration;
     private transient WebAppContextPath webAppContextPath;
     private transient PageClassRegistry pageClassRegistry;
     private transient IsisAppCommonContext commonContext;
@@ -65,7 +65,7 @@ implements HasCommonContext {
     // -- FAVICON SUPPORT
     
     protected void renderFavicon(IHeaderResponse response) {
-        getIsisConfiguration().getViewer().getWicket().getApplication().getFaviconUrl()
+        getConfiguration().getViewer().getWicket().getApplication().getFaviconUrl()
         .filter(_Strings::isNotEmpty)
         .map(getWebAppContextPath()::prependContextPathIfLocal)
         .ifPresent(faviconUrl->{
@@ -80,8 +80,8 @@ implements HasCommonContext {
         return commonContext = CommonContextUtils.computeIfAbsent(commonContext);
     }
     
-    public IsisConfiguration getIsisConfiguration() {
-        return isisConfiguration = computeIfAbsent(IsisConfiguration.class, isisConfiguration);
+    public IsisConfiguration getConfiguration() {
+        return getCommonContext().getConfiguration();
     }
 
     public WebAppContextPath getWebAppContextPath() {
@@ -96,6 +96,10 @@ implements HasCommonContext {
         return isisInteractionFactory = computeIfAbsent(InteractionFactory.class, isisInteractionFactory);
     }
     
+    public IsisSystemEnvironment getSystemEnvironment() {
+        return getCommonContext().getSystemEnvironment();
+    }
+    
     // -- HELPER
     
     private <X> X computeIfAbsent(Class<X> type, X existingIfAny) {
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
index 129f222..30af849 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
@@ -100,7 +100,7 @@ public class AccountManagementPageAbstract extends WebPageBase {
 
 
     private MarkupContainer addPageTitle() {
-        String applicationName = getIsisConfiguration().getViewer().getWicket().getApplication().getName();
+        String applicationName = getConfiguration().getViewer().getWicket().getApplication().getName();
         return add(new Label(ID_PAGE_TITLE, applicationName));
     }
 
@@ -120,10 +120,11 @@ public class AccountManagementPageAbstract extends WebPageBase {
         response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(
                 BootstrapJavaScriptReference.instance())));
 
-        getIsisConfiguration().getViewer().getWicket().getApplication().getCss()
-                .ifPresent(css -> response.render(CssReferenceHeaderItem.forUrl(css)));
-        getIsisConfiguration().getViewer().getWicket().getApplication().getJs()
-                .ifPresent(js -> response.render(JavaScriptReferenceHeaderItem.forUrl(js)));
+        getConfiguration().getViewer().getWicket().getApplication().getCss()
+        .ifPresent(css -> response.render(CssReferenceHeaderItem.forUrl(css)));
+        
+        getConfiguration().getViewer().getWicket().getApplication().getJs()
+        .ifPresent(js -> response.render(JavaScriptReferenceHeaderItem.forUrl(js)));
     }
 
 
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/mmverror/MmvErrorPage.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/mmverror/MmvErrorPage.java
index e15ef3f..1561446 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/mmverror/MmvErrorPage.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/mmverror/MmvErrorPage.java
@@ -69,11 +69,11 @@ public class MmvErrorPage extends WebPageBase {
     }
 
     private MarkupContainer addPageTitle() {
-        return add(new Label(ID_PAGE_TITLE, getIsisConfiguration().getViewer().getWicket().getApplication().getName()));
+        return add(new Label(ID_PAGE_TITLE, getConfiguration().getViewer().getWicket().getApplication().getName()));
     }
 
     private void addApplicationName() {
-        add(new Label(ID_APPLICATION_NAME, getIsisConfiguration().getViewer().getWicket().getApplication().getName()));
+        add(new Label(ID_APPLICATION_NAME, getConfiguration().getViewer().getWicket().getApplication().getName()));
     }
 
     private void addValidationErrors() {
@@ -95,10 +95,11 @@ public class MmvErrorPage extends WebPageBase {
         response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())));
         response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(BootstrapJavaScriptReference.instance())));
 
-        getIsisConfiguration().getViewer().getWicket().getApplication().getCss()
-                .ifPresent(css -> response.render(CssReferenceHeaderItem.forUrl(css)));
-        getIsisConfiguration().getViewer().getWicket().getApplication().getJs()
-                .ifPresent(js -> response.render(JavaScriptReferenceHeaderItem.forUrl(js)));
+        getConfiguration().getViewer().getWicket().getApplication().getCss()
+        .ifPresent(css -> response.render(CssReferenceHeaderItem.forUrl(css)));
+        
+        getConfiguration().getViewer().getWicket().getApplication().getJs()
+        .ifPresent(js -> response.render(JavaScriptReferenceHeaderItem.forUrl(js)));
     }
 
     @Override