From 3b690dbc1a17aa063770d570afd1309ec5d9d795 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Feb 2026 21:12:00 +0000 Subject: [PATCH] Extract readUnbounded into separate UnboundedReadModelCapability interface Move readUnbounded() methods out of ReadModelCapability into a dedicated UnboundedReadModelCapability interface so they are no longer exposed on BoundedContext by default. Dashboard code can opt in by extending the new interface in a custom bounded context type, leveraging the existing proxy mechanism. This keeps the public API clean for application developers. https://claude.ai/code/session_012D3mi7czkMEwKXYUvi7m2s --- .../readmodels/ReadModelCapability.java | 6 --- .../UnboundedReadModelCapability.java | 41 +++++++++++++++++++ .../boundedcontext/BoundedContextImpl.java | 3 +- 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/UnboundedReadModelCapability.java diff --git a/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/ReadModelCapability.java b/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/ReadModelCapability.java index 43b25b6..3f928f1 100644 --- a/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/ReadModelCapability.java +++ b/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/ReadModelCapability.java @@ -25,10 +25,4 @@ public interface ReadModelCapability { T read ( Class> readModelClass, Object... params ); - // TODO how to hide these from other clients than the Dashboard? - - T readUnbounded ( Class> readModelClass, Tracing tracing, Object... params ); - - T readUnbounded ( Class> readModelClass, Object... params ); - } diff --git a/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/UnboundedReadModelCapability.java b/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/UnboundedReadModelCapability.java new file mode 100644 index 0000000..fdb2bb8 --- /dev/null +++ b/sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/UnboundedReadModelCapability.java @@ -0,0 +1,41 @@ +/* + * Sliceworkz Event Modeling - an opinionated Event Modeling framework in Java + * Copyright © 2025 Sliceworkz / XTi (info@sliceworkz.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package org.sliceworkz.eventmodeling.readmodels; + +import org.sliceworkz.eventmodeling.events.Tracing; + +/** + * Capability for reading models across all event streams, regardless of bounded context boundaries. + *

+ * This is intended for internal dashboard and monitoring use only. + * Application developers should use {@link ReadModelCapability#read} instead, + * which scopes queries to the bounded context's own domain event stream. + *

+ * To use this capability, define a custom bounded context interface that explicitly + * extends this interface: + *

{@code
+ * interface DashboardContext extends CQRSCapabilities, UnboundedReadModelCapability {}
+ * }
+ */ +public interface UnboundedReadModelCapability { + + T readUnbounded ( Class> readModelClass, Tracing tracing, Object... params ); + + T readUnbounded ( Class> readModelClass, Object... params ); + +} diff --git a/sliceworkz-eventmodeling-impl/src/main/java/org/sliceworkz/eventmodeling/module/boundedcontext/BoundedContextImpl.java b/sliceworkz-eventmodeling-impl/src/main/java/org/sliceworkz/eventmodeling/module/boundedcontext/BoundedContextImpl.java index dd890d6..fd2047a 100644 --- a/sliceworkz-eventmodeling-impl/src/main/java/org/sliceworkz/eventmodeling/module/boundedcontext/BoundedContextImpl.java +++ b/sliceworkz-eventmodeling-impl/src/main/java/org/sliceworkz/eventmodeling/module/boundedcontext/BoundedContextImpl.java @@ -41,6 +41,7 @@ import org.sliceworkz.eventmodeling.module.outbound.OutboundModule; import org.sliceworkz.eventmodeling.module.readmodels.ReadModelModule; import org.sliceworkz.eventmodeling.readmodels.ReadModelWithMetaData; +import org.sliceworkz.eventmodeling.readmodels.UnboundedReadModelCapability; import org.sliceworkz.eventmodeling.slices.FeatureSliceConfiguration; import org.sliceworkz.eventstore.events.EphemeralEvent; import org.sliceworkz.eventstore.events.Event; @@ -52,7 +53,7 @@ import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.MeterRegistry; -public class BoundedContextImpl implements AllCapabilities, ConsistentEventProcessor { +public class BoundedContextImpl implements AllCapabilities, UnboundedReadModelCapability, ConsistentEventProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(BoundedContextImpl.class);