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/09/11 02:46:41 UTC

[isis] branch master updated: ISIS-2870: debug log UI component creation

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


The following commit(s) were added to refs/heads/master by this push:
     new 7a4ffce  ISIS-2870: debug log UI component creation
7a4ffce is described below

commit 7a4ffcebce7bf214f5c5e17eca2d88413c2fefcf
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Sep 11 04:46:32 2021 +0200

    ISIS-2870: debug log UI component creation
---
 .../common/model/components/ComponentType.java     | 13 ++++++----
 .../viewer/wicket/ui/ComponentFactoryAbstract.java | 30 ++++++++++------------
 2 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/viewers/common/src/main/java/org/apache/isis/viewer/common/model/components/ComponentType.java b/viewers/common/src/main/java/org/apache/isis/viewer/common/model/components/ComponentType.java
index 37a046f..c2e9291 100644
--- a/viewers/common/src/main/java/org/apache/isis/viewer/common/model/components/ComponentType.java
+++ b/viewers/common/src/main/java/org/apache/isis/viewer/common/model/components/ComponentType.java
@@ -18,6 +18,8 @@
  */
 package org.apache.isis.viewer.common.model.components;
 
+import org.springframework.lang.Nullable;
+
 import org.apache.isis.core.metamodel.commons.StringExtensions;
 
 /**
@@ -147,6 +149,11 @@ public enum ComponentType {
      */
     FOOTER;
 
+    @Override
+    public String toString() {
+        return getId();
+    }
+
     /**
      * Returns the {@link #name()} formatted as
      * {@link StringExtensions#toCamelCase(String) case}.
@@ -154,15 +161,11 @@ public enum ComponentType {
      * <p>
      * For example, <tt>OBJECT_EDIT</tt> becomes <tt>objectEdit</tt>.
      */
-    @Override
-    public String toString() {
-        return getId();
-    }
-
     public String getId() {
         return StringExtensions.toCamelCase(name());
     }
 
+    @Nullable
     public static ComponentType lookup(final String id) {
         for (final ComponentType componentType : values()) {
             if (componentType.getId().equals(id)) {
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/ComponentFactoryAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/ComponentFactoryAbstract.java
index 3455e63..01b8e36 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/ComponentFactoryAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/ComponentFactoryAbstract.java
@@ -28,34 +28,39 @@ import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
 
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
+import lombok.extern.log4j.Log4j2;
 
 /**
  * Adapter implementation for {@link ComponentFactory}.
  */
+@ToString
+@Log4j2
 public abstract class ComponentFactoryAbstract implements ComponentFactory {
 
     private static final long serialVersionUID = 1L;
 
+    @ToString.Exclude
     @Getter @Setter private transient IsisAppCommonContext commonContext;
 
-    private final ComponentType componentType;
-    private final String name;
+    @Getter(onMethod_ = {@Override}) private final ComponentType componentType;
+    @Getter(onMethod_ = {@Override}) private final String name;
 
     private final Class<?> componentClass;
 
-    public ComponentFactoryAbstract(final ComponentType componentType) {
+    protected ComponentFactoryAbstract(final ComponentType componentType) {
         this(componentType, null, null);
     }
 
-    public ComponentFactoryAbstract(final ComponentType componentType, final String name) {
+    protected ComponentFactoryAbstract(final ComponentType componentType, final String name) {
         this(componentType, name, null);
     }
 
-    public ComponentFactoryAbstract(final ComponentType componentType, final Class<?> componentClass) {
+    protected ComponentFactoryAbstract(final ComponentType componentType, final Class<?> componentClass) {
         this(componentType, null, componentClass);
     }
 
-    public ComponentFactoryAbstract(
+    protected ComponentFactoryAbstract(
             final ComponentType componentType,
             final String name,
             final Class<?> componentClass) {
@@ -66,11 +71,7 @@ public abstract class ComponentFactoryAbstract implements ComponentFactory {
             throw new IllegalArgumentException("specified a ComponentFactory as a componentClass... you probably meant the component instead? componentClass = " + componentClass.getName());
         }
         this.componentClass = componentClass;
-    }
-
-    @Override
-    public ComponentType getComponentType() {
-        return componentType;
+        log.debug("new factory {}", this::toString);
     }
 
     /**
@@ -105,6 +106,7 @@ public abstract class ComponentFactoryAbstract implements ComponentFactory {
 
     @Override
     public final Component createComponent(final IModel<?> model) {
+        log.debug("creating component {}", getComponentType()::toString);
         return createComponent(getComponentType().toString(), model);
     }
 
@@ -112,14 +114,8 @@ public abstract class ComponentFactoryAbstract implements ComponentFactory {
     public abstract Component createComponent(String id, IModel<?> model);
 
     @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
     public CssResourceReference getCssResourceReference() {
         return PanelUtil.cssResourceReferenceFor(componentClass);
     }
 
-
 }