diff --git a/license-report.md b/license-report.md index 7e03af01249..c7ce3d15446 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine:spine-client:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -399,12 +399,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:45 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:37:58 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-core:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine:spine-core:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -763,12 +763,12 @@ This report was generated on **Fri Feb 03 15:42:45 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:45 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:37:58 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-assembler:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine.tools:spine-model-assembler:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1162,12 +1162,12 @@ This report was generated on **Fri Feb 03 15:42:45 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:46 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:37:59 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-verifier:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine.tools:spine-model-verifier:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1627,12 +1627,12 @@ This report was generated on **Fri Feb 03 15:42:46 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:46 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:38:00 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-server:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine:spine-server:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2039,12 +2039,12 @@ This report was generated on **Fri Feb 03 15:42:46 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:47 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:38:00 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-client:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine:spine-testutil-client:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2493,12 +2493,12 @@ This report was generated on **Fri Feb 03 15:42:47 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:50 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:38:03 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-core:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine:spine-testutil-core:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2947,12 +2947,12 @@ This report was generated on **Fri Feb 03 15:42:50 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:52 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Feb 07 12:38:05 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-server:1.9.0-SNAPSHOT.8` +# Dependencies of `io.spine:spine-testutil-server:1.9.0-SNAPSHOT.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3445,4 +3445,4 @@ This report was generated on **Fri Feb 03 15:42:52 WET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 03 15:42:56 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Tue Feb 07 12:38:09 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 10e1fa0b313..021c7db8b5d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.9.0-SNAPSHOT.8 +1.9.0-SNAPSHOT.9 2015 diff --git a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java index 4bc486e53af..9b32aeb91f4 100644 --- a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java +++ b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java @@ -37,6 +37,7 @@ import io.spine.server.ContextAware; import io.spine.server.ServerEnvironment; import io.spine.server.event.EventDispatcher; +import io.spine.server.tenant.TenantAwareRunner; import io.spine.server.transport.ChannelId; import io.spine.server.transport.Publisher; import io.spine.server.transport.PublisherHub; @@ -245,7 +246,8 @@ void dispatchLocally(Event event) { * Dispatches the given event via the local {@code EventBus} and observes the acknowledgement. */ void dispatchLocally(Event event, StreamObserver ackObserver) { - bus.dispatch(event, ackObserver); + TenantAwareRunner.with(event.tenant()) + .run(() -> bus.dispatch(event, ackObserver)); } /** diff --git a/server/src/main/java/io/spine/server/integration/ThirdPartyContext.java b/server/src/main/java/io/spine/server/integration/ThirdPartyContext.java index ea35d42d4e8..c5db36c2d46 100644 --- a/server/src/main/java/io/spine/server/integration/ThirdPartyContext.java +++ b/server/src/main/java/io/spine/server/integration/ThirdPartyContext.java @@ -53,7 +53,7 @@ * @implSpec Note that a {@code ThirdPartyContext} sends a request for external messages to * other contexts. The {@code ThirdPartyContext} never consumes external messages itself, * but requires the other Bounded Contexts to send their requests, so that the publishing - * channels are open. Depending of the implementation of + * channels are open. Depending on the implementation of * {@link io.spine.server.transport.TransportFactory transport}, creating * a {@code ThirdPartyContext} may be an expensive operation. Thus, it is recommended that * the instances of this class are reused and {@linkplain #close() closed} when they are diff --git a/server/src/test/java/io/spine/server/integration/ThirdPartyContextTest.java b/server/src/test/java/io/spine/server/integration/ThirdPartyContextTest.java index 7a385484dc0..92725dfe606 100644 --- a/server/src/test/java/io/spine/server/integration/ThirdPartyContextTest.java +++ b/server/src/test/java/io/spine/server/integration/ThirdPartyContextTest.java @@ -82,9 +82,7 @@ void prepareContext() { @AfterEach void closeContext() throws Exception { context.close(); - ServerEnvironment - .instance() - .reset(); + resetServerEnvironment(); } @Test @@ -213,11 +211,16 @@ void domesticSubscriber() { @Test @DisplayName("in a multitenant environment") void multitenant() { + /* Getting rid of the class-level repositories and bounded contexts. */ + resetServerEnvironment(); + DocumentRepository documentRepository = new DocumentRepository(); - BoundedContextBuilder + BoundedContext boundedContext = BoundedContextBuilder .assumingTests(true) .add(documentRepository) .build(); + assertThat(boundedContext.isMultitenant()) + .isTrue(); UserId johnDoe = userId(); TenantId acmeCorp = TenantId .newBuilder() @@ -248,6 +251,12 @@ void multitenant() { assertThat(cyberdyneDailyReport).isEmpty(); } + private static void resetServerEnvironment() { + ServerEnvironment + .instance() + .reset(); + } + private static void postForSingleTenant(UserId actor, EventMessage event) { try (ThirdPartyContext uploads = ThirdPartyContext.singleTenant("Imports")) { uploads.emittedEvent(event, actor); diff --git a/server/src/test/java/io/spine/server/integration/given/DocumentRepository.java b/server/src/test/java/io/spine/server/integration/given/DocumentRepository.java index 3e2cc882590..4f9c42e0cd2 100644 --- a/server/src/test/java/io/spine/server/integration/given/DocumentRepository.java +++ b/server/src/test/java/io/spine/server/integration/given/DocumentRepository.java @@ -32,9 +32,12 @@ import io.spine.server.integration.PaperDocumentScanned; import io.spine.server.route.EventRouting; +import java.util.Optional; +import java.util.Set; + import static io.spine.server.route.EventRoute.withId; -public class DocumentRepository extends AggregateRepository { +public final class DocumentRepository extends AggregateRepository { @Override protected void setupImportRouting(EventRouting routing) { @@ -45,7 +48,31 @@ protected void setupImportRouting(EventRouting routing) { @Override protected void setupEventRouting(EventRouting routing) { super.setupEventRouting(routing); - routing.route(OpenOfficeDocumentUploaded.class, - (message, context) -> withId(message.getId())); + routing.route(OpenOfficeDocumentUploaded.class, (message, context) -> route(message)); + } + + /** + * Routes an external event to the instances of {@link DocumentAggregate}. + * + *

This method includes an explicit call to repository's {@code find(..)} method. + * This is done to ensure that even in multi-tenant environment such a call + * is available, meaning that the {@code TenantId} is present in scope + * of runtime execution context. + * + *

Corresponding tests are available + * in {@link io.spine.server.integration.IntegrationBrokerTest IntegrationBrokerTest}. + * + * @param event + * event to route + * @return set of identifiers + */ + private Set route(OpenOfficeDocumentUploaded event) { + DocumentId id = event.getId(); + Optional aggregate = find(id); + if (!aggregate.isPresent()) { + _debug().log("`Document` aggregate is not found by ID `%s`. " + + "Creating a new instance.", id); + } + return withId(id); } } diff --git a/version.gradle.kts b/version.gradle.kts index 3f8b9f046e6..787f1cf6b9a 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -34,7 +34,7 @@ /** * Version of this library. */ -val coreJava = "1.9.0-SNAPSHOT.8" +val coreJava = "1.9.0-SNAPSHOT.9" /** * Versions of the Spine libraries that `core-java` depends on.