This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/main by this push:
new 275cab25656 CAUSEWAY-2297: use _StableValue in Action Col
(optimization)
275cab25656 is described below
commit 275cab25656137b4017942aea8a659c388d12440
Author: andi-huber <[email protected]>
AuthorDate: Thu Jan 22 11:11:06 2026 +0100
CAUSEWAY-2297: use _StableValue in Action Col (optimization)
---
.../present/ajaxtable/columns/ActionColumn.java | 15 +++++----------
.../ajaxtable/columns/GenericColumnAbstract.java | 22 ++++++++--------------
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git
a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/ActionColumn.java
b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/ActionColumn.java
index d1deb0b53cf..f81821f6759 100644
---
a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/ActionColumn.java
+++
b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/ActionColumn.java
@@ -26,6 +26,7 @@
import org.apache.causeway.applib.Identifier;
import org.apache.causeway.applib.annotation.Where;
import org.apache.causeway.commons.collections.Can;
+import org.apache.causeway.commons.internal.base._StableValue;
import org.apache.causeway.core.metamodel.spec.ObjectSpecification;
import org.apache.causeway.core.metamodel.spec.feature.ObjectAction;
import org.apache.causeway.viewer.wicket.model.models.ActionModel;
@@ -56,7 +57,7 @@ public static Optional<ActionColumn> create(
}
private final Can<String> actionIds;
- private transient Can<ObjectAction> actions;
+ private final _StableValue<Can<ObjectAction>> actionsRef;
private final Variant collectionVariant;
private ActionColumn(
@@ -64,8 +65,8 @@ private ActionColumn(
final Can<ObjectAction> actionsForColumnRendering,
final Variant collectionVariant) {
super(elementType, "Actions");
- this.actions = actionsForColumnRendering;
- this.actionIds = actions.map(ObjectAction::getId);
+ this.actionsRef = new _StableValue<>(actionsForColumnRendering);
+ this.actionIds = actionsForColumnRendering.map(ObjectAction::getId);
this.collectionVariant = collectionVariant;
}
@@ -104,13 +105,7 @@ private ColumnActionModifier determineColumnActionModifier(
}
private Can<ObjectAction> actions() {
- synchronized(this) {
- if(actions==null) {
- var elementType = elementType();
- this.actions = actionIds.map(elementType::getActionElseFail);
- }
- }
- return actions;
+ return
actionsRef.orElseSet(()->actionIds.map(elementType()::getActionElseFail));
}
}
diff --git
a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/GenericColumnAbstract.java
b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/GenericColumnAbstract.java
index 2ef2c7c28fc..12f97a117dc 100644
---
a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/GenericColumnAbstract.java
+++
b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collection/present/ajaxtable/columns/GenericColumnAbstract.java
@@ -28,6 +28,7 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.causeway.commons.internal.base._StableValue;
import org.apache.causeway.core.metamodel.context.HasMetaModelContext;
import org.apache.causeway.core.metamodel.context.MetaModelContext;
import org.apache.causeway.core.metamodel.spec.ObjectSpecification;
@@ -51,9 +52,9 @@ public abstract class GenericColumnAbstract
implements GenericColumn, HasMetaModelContext {
private static final long serialVersionUID = 1L;
- private transient ComponentFactoryRegistry componentRegistry;
private final Class<?> elementClass;
- private transient ObjectSpecification elementType;
+ private final _StableValue<ObjectSpecification> elementTypeRef;
+ private final _StableValue<ComponentFactoryRegistry> componentRegistryRef;
protected GenericColumnAbstract(
final ObjectSpecification elementType,
@@ -66,8 +67,9 @@ protected GenericColumnAbstract(
final IModel<String> columnNameModel,
final String sortColumn) {
super(columnNameModel, sortColumn);
- this.elementType = elementType;
+ this.elementTypeRef = new _StableValue<>(elementType);
this.elementClass = elementType.getCorrespondingClass();
+ this.componentRegistryRef = new _StableValue<>();
}
@Override
@@ -95,12 +97,7 @@ public final void populateItem(
@Override
public final ObjectSpecification elementType() {
- synchronized(this) {
- if(elementType==null) {
- this.elementType =
MetaModelContext.instanceElseFail().specForTypeElseFail(elementClass);
- }
- }
- return elementType;
+ return
elementTypeRef.orElseSet(()->MetaModelContext.instanceElseFail().specForTypeElseFail(elementClass));
}
protected ComponentFactory findComponentFactory(final UiComponentType
uiComponentType, final IModel<?> model) {
@@ -108,11 +105,8 @@ protected ComponentFactory findComponentFactory(final
UiComponentType uiComponen
}
protected ComponentFactoryRegistry getComponentRegistry() {
- if(componentRegistry==null) {
- var componentFactoryRegistryAccessor =
(HasComponentFactoryRegistry) Application.get();
- componentRegistry =
componentFactoryRegistryAccessor.getComponentFactoryRegistry();
- }
- return componentRegistry;
+ return componentRegistryRef.orElseSet(()->
+ ((HasComponentFactoryRegistry)
Application.get()).getComponentFactoryRegistry());
}
}