You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2023/09/26 20:42:57 UTC
[causeway] 02/02: CAUSEWAY-3610: refactors to remove InteractionServiceDefault#interactionId field
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-3610
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 9c8700853b4acb0ce8169b08832be9d98ca778b6
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Sep 26 21:42:49 2023 +0100
CAUSEWAY-3610: refactors to remove InteractionServiceDefault#interactionId field
instead delegate to currentInteraction()
---
.../causeway/core/config/CausewayConfiguration.java | 2 ++
.../command/CommandExecutorServiceDefault.java | 10 ++++++++--
.../EntityPropertyChangePublisherDefault.java | 3 +++
.../session/InteractionServiceDefault.java | 20 ++++++++------------
4 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java
index db2da54210..ae8cf6a238 100644
--- a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java
+++ b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java
@@ -916,6 +916,8 @@ public class CausewayConfiguration {
"lookup.*:fa-search",
"search.*:fa-search",
+ "send.*:fa-regular fa-paper-plane",
+
"open.*:fa-solid fa-arrow-up-right-from-square",
"close.*:fa-solid fa-regular fa-rectangle-xmark",
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/command/CommandExecutorServiceDefault.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/command/CommandExecutorServiceDefault.java
index fd3fa9e7d9..c634403fdd 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/command/CommandExecutorServiceDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/command/CommandExecutorServiceDefault.java
@@ -122,10 +122,16 @@ public class CommandExecutorServiceDefault implements CommandExecutorService {
val interaction = interactionLayerTracker.currentInteractionElseFail();
val command = interaction.getCommand();
- // replace the command with that of the DTO to be executed.
- command.updater().setInteractionId(UUID.fromString(dto.getInteractionId()));
+ // replace the command with that of the DTO to be executed
command.updater().setCommandDto(dto);
+ // ... and also its interactionId.
+ //
+ // nb: this should be sufficient; there are no other copies of interactionId to be updated.
+ // In particular, both InteractionServiceDefault#getInteractionId() and Interaction#getInteractionId() just
+ // delegate to the Command held within the Interaction;
+ command.updater().setInteractionId(UUID.fromString(dto.getInteractionId()));
+
// notify subscribers that the command is now ready for execution
command.updater().setPublishingPhase(Command.CommandPublishingPhase.READY);
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/EntityPropertyChangePublisherDefault.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/EntityPropertyChangePublisherDefault.java
index 8d9996a54c..cd77ffc77c 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/EntityPropertyChangePublisherDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/EntityPropertyChangePublisherDefault.java
@@ -26,6 +26,8 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
+import org.apache.causeway.applib.services.iactnlayer.InteractionService;
+
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
@@ -61,6 +63,7 @@ public class EntityPropertyChangePublisherDefault implements EntityPropertyChang
private final UserService userService;
private final ClockService clockService;
private final TransactionService transactionService;
+ private final InteractionService interactionService;
private final InteractionLayerTracker iaTracker;
private final Provider<HasEnlistedEntityPropertyChanges> hasEnlistedEntityPropertyChangesProvider;
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java
index d182768a39..b59d004901 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java
@@ -209,8 +209,8 @@ implements
}
if(log.isDebugEnabled()) {
- log.debug("new interaction layer created (conversation-id={}, total-layers-on-stack={}, {})",
- interactionId.get(),
+ log.debug("new interaction layer created (interactionId={}, total-layers-on-stack={}, {})",
+ currentInteraction().map(Interaction::getInteractionId).orElse(null),
interactionLayerStack.get().size(),
_Probe.currentThreadId());
}
@@ -234,8 +234,8 @@ implements
@Override
public void closeInteractionLayers() {
- log.debug("about to close the interaction stack (conversation-id={}, total-layers-on-stack={}, {})",
- interactionId.get(),
+ log.debug("about to close the interaction stack (interactionId={}, total-layers-on-stack={}, {})",
+ currentInteraction().map(Interaction::getInteractionId).orElse(null),
interactionLayerStack.get().size(),
_Probe.currentThreadId());
@@ -312,13 +312,11 @@ implements
run(InteractionContextFactory.anonymous(), runnable);
}
- // -- CONVERSATION ID
-
- private final ThreadLocal<UUID> interactionId = ThreadLocal.withInitial(()->null);
+ // -- INTERACTION ID
@Override
public Optional<UUID> getInteractionId() {
- return Optional.ofNullable(interactionId.get());
+ return currentInteraction().map(Interaction::getInteractionId);
}
// -- HELPER
@@ -365,7 +363,6 @@ implements
}
private void postInteractionOpened(final CausewayInteraction interaction) {
- interactionId.set(interaction.getInteractionId());
transactionBoundaryAwareBeans.forEach(bean->bean.beforeEnteringTransactionalBoundary(interaction));
txBoundaryHandler.onOpen(interaction);
val isSynchronizationActive = TransactionSynchronizationManager.isSynchronizationActive();
@@ -408,9 +405,9 @@ implements
private void closeInteractionLayerStackDownToStackSize(final int downToStackSize) {
- log.debug("about to close authenication stack down to size {} (conversation-id={}, total-sessions-on-stack={}, {})",
+ log.debug("about to close interaction stack down to size {} (interactionId={}, total-layers-on-stack={}, {})",
downToStackSize,
- interactionId.get(),
+ currentInteraction().map(Interaction::getInteractionId).orElse(null),
interactionLayerStack.get().size(),
_Probe.currentThreadId());
@@ -426,7 +423,6 @@ implements
if(downToStackSize == 0) {
// cleanup thread-local
interactionLayerStack.remove();
- interactionId.remove();
}
}