Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions license-report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-client:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine:spine-client:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -399,12 +399,12 @@
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:33 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 **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).




# Dependencies of `io.spine:spine-core:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine:spine-core:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
Expand Down Expand Up @@ -763,12 +763,12 @@ This report was generated on **Mon Jan 02 10:21:33 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:34 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 **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).




# Dependencies of `io.spine.tools:spine-model-assembler:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine.tools:spine-model-assembler:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -1162,12 +1162,12 @@ This report was generated on **Mon Jan 02 10:21:34 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:35 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 **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).




# Dependencies of `io.spine.tools:spine-model-verifier:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine.tools:spine-model-verifier:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -1627,12 +1627,12 @@ This report was generated on **Mon Jan 02 10:21:35 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:35 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 **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).




# Dependencies of `io.spine:spine-server:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine:spine-server:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -2039,12 +2039,12 @@ This report was generated on **Mon Jan 02 10:21:35 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:36 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 **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).




# Dependencies of `io.spine:spine-testutil-client:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine:spine-testutil-client:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -2493,12 +2493,12 @@ This report was generated on **Mon Jan 02 10:21:36 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:39 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 **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).




# Dependencies of `io.spine:spine-testutil-core:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine:spine-testutil-core:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -2947,12 +2947,12 @@ This report was generated on **Mon Jan 02 10:21:39 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:40 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 **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).




# Dependencies of `io.spine:spine-testutil-server:1.9.0-SNAPSHOT.6`
# Dependencies of `io.spine:spine-testutil-server:1.9.0-SNAPSHOT.8`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -3445,4 +3445,4 @@ This report was generated on **Mon Jan 02 10:21:40 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Jan 02 10:21:44 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 **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).
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject.

<groupId>io.spine</groupId>
<artifactId>spine-core-java</artifactId>
<version>1.9.0-SNAPSHOT.6</version>
<version>1.9.0-SNAPSHOT.8</version>

<inceptionYear>2015</inceptionYear>

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/io/spine/server/command/Assign.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* </ul>
*
* <p>Like other message-handling methods, command handlers are designed to be called by
* the framework only. Therefore, it is recommended to declare a them as package-private.
* the framework only. Therefore, it is recommended to declare them as package-private.
* It discourages a developer from calling these methods directly from anywhere.
*
* <p>Package-private access level still declares that a command handler method is a part
Expand Down
8 changes: 8 additions & 0 deletions server/src/main/java/io/spine/server/delivery/Delivery.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,14 @@ void register(Inbox<?> inbox) {
deliveries.register(inbox);
}

/**
* Returns the registry of known message deliveries.
*/
@VisibleForTesting
InboxDeliveries registeredDeliveries() {
return deliveries;
}

/**
* Determines the shard index for the message, judging on the identifier of the entity,
* to which this message is dispatched.
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/io/spine/server/delivery/Inbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public ShardedMessageDelivery<InboxMessage> delivery() {
/**
* Unregisters this {@code Inbox} instance in the JVM-wide {@code Delivery}.
*
* After this call the messages residing in the sharded storage will not be delivered to the
* <p>After this call the messages residing in the sharded storage will not be delivered to the
* entities served by this {@code Inbox}.
*/
public void unregister() {
Expand Down
12 changes: 12 additions & 0 deletions server/src/main/java/io/spine/server/delivery/InboxDeliveries.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

package io.spine.server.delivery;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import io.spine.type.TypeUrl;

import java.util.Map;
Expand Down Expand Up @@ -83,4 +85,14 @@ void unregister(Inbox<?> inbox) {
TypeUrl entityType = inbox.entityStateType();
contents.remove(entityType.value());
}

/**
* Returns the {@code String} values of type URLs
* under which the message delivered are registered
* in this instance of {@code InboxDeliveries}.
*/
@VisibleForTesting
ImmutableSet<String> knownTypeUrls() {
return ImmutableSet.copyOf(contents.keySet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import io.spine.server.type.EventClass;
import io.spine.server.type.EventEnvelope;
import io.spine.time.TimestampTemporal;
import io.spine.type.TypeUrl;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down Expand Up @@ -195,7 +196,7 @@ private void initCache(boolean multitenant) {
*/
private void initInbox(Delivery delivery) {
inbox = delivery
.<I>newInbox(entityStateType())
.<I>newInbox(inboxStateType())
.withBatchListener(new BatchDeliveryListener<I>() {
@Override
public void onStart(I id) {
Expand All @@ -214,6 +215,20 @@ public void onEnd(I id) {
.build();
}

/**
* Returns a {@code TypeUrl} under which the entities of this repository will register
* their {@code Inbox}es.
*
* <p>Descendants may choose to customize this value in special cases.
* One of these cases is avoiding the duplication of {@code Inbox}es
* in an application-wide {@code Delivery} for the same system projection
* registered in several Bounded Contexts.
*/
@Internal
protected TypeUrl inboxStateType() {
return entityStateType();
}

private Inbox<I> inbox() {
return checkNotNull(inbox);
}
Expand Down
37 changes: 37 additions & 0 deletions server/src/main/java/io/spine/system/server/MirrorRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.spine.server.projection.ProjectionRepository;
import io.spine.server.route.EventRouting;
import io.spine.system.server.event.EntityLifecycleEvent;
import io.spine.type.TypeName;
import io.spine.type.TypeUrl;

import java.util.Iterator;
Expand All @@ -53,6 +54,7 @@
import static io.spine.system.server.Mirror.STATE_FIELD_NUMBER;
import static io.spine.system.server.Mirror.VERSION_FIELD_NUMBER;
import static io.spine.system.server.MirrorProjection.buildFilters;
import static java.lang.String.format;

/**
* The repository for {@link Mirror} projections.
Expand Down Expand Up @@ -80,6 +82,41 @@ protected void setupEventRouting(EventRouting<MirrorId> routing) {
(message, context) -> targetsFrom(message));
}

/**
* Returns the custom type URL for {@code Mirror} type to use during the {@code Inbox}
* registration in {@code Delivery}.
*
* <p>The prefix part in the resulting type URL includes the name of the Bounded Context
* in which this repository is registered.
*
* <p>It is a workaround preventing some known issues of delivering signals
* to {@code Mirror} instances in an application consisting of several Bounded Contexts.
* As long as each of the Bounded Contexts may have their own {@code Mirror}
* as a system entity, application-wide {@code Delivery} must have a way
* to distinguish the inboxes for each of such {@code Mirror} entity types.
* Inserting the name of the Bounded Context into the type URL helps to achieve this goal.
*
* <p>This type URL must be used solely for {@code Inbox}-specific set up,
* and must not be associated with any entity state types, since its "prefix" part
* is customized.
*
* <p>Please note, this feature along with {@code Mirror} itself is removed in Spine 2.x.
*/
@Internal
@Override
@SuppressWarnings("resource") /* Not using any resources from `context()`. */
protected TypeUrl inboxStateType() {
String contextName = context().name()
.value();
TypeUrl originalValue = super.inboxStateType();
String originalPrefix = originalValue.prefix();
TypeName typeName = originalValue.toTypeName();

String rawTypeUrl = format("%s@%s/%s", originalPrefix, contextName, typeName.value());
TypeUrl result = TypeUrl.parse(rawTypeUrl);
return result;
}

@Internal
@Override
protected boolean isCatchUpEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

@DisplayName("Aggregate should")
@SuppressWarnings({
"InnerClassMayBeStatic", "ClassCanBeStatic" /* JUnit nested classes cannot be static. */,
"ClassWithTooManyMethods", "OverlyCoupledClass" /* Testing a centerpiece. */
})
@DisplayName("Aggregate should")
@MuteLogging /* Explicitly triggering failures in tests. */
public class AggregateTest {

private static final ProjectId ID = ProjectId.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package io.spine.server.delivery;

import com.google.common.collect.ImmutableSet;
import io.spine.server.BoundedContext;
import io.spine.server.DefaultRepository;
import io.spine.server.ServerEnvironment;
import io.spine.server.aggregate.Aggregate;
import io.spine.server.delivery.given.InboxRegistrationTestEnv.InboxProject;
import io.spine.server.delivery.given.InboxRegistrationTestEnv.InboxTask;
import io.spine.system.server.Mirror;
import io.spine.type.TypeUrl;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static com.google.common.truth.Truth.assertWithMessage;

@DisplayName("`Inbox`es registration in `Delivery`")
@SuppressWarnings("resource" /* Ignoring the closeables for tests is OK. */)
final class InboxRegistrationTest {

private static final String MIRROR_TYPE_URL = TypeUrl.of(Mirror.class)
.toTypeName()
.value();

@Test
@DisplayName("should have no overlaps for `Aggregate` mirrors from multiple Bounded Contexts")
void registerMultipleMirrors() {
String firstContextName = "Mirror Projects";
buildContext(firstContextName, InboxProject.class);

String secondContextName = "Mirror Tasks";
buildContext(secondContextName, InboxTask.class);

InboxDeliveries deliveries = registeredDeliveries();
ImmutableSet<String> rawInboxTypes = deliveries.knownTypeUrls();
assertRegistered(firstContextName, rawInboxTypes);
assertRegistered(secondContextName, rawInboxTypes);
}

@SuppressWarnings("IfStatementMissingBreakInLoop")
private static void assertRegistered(String firstContextName,
ImmutableSet<String> rawInboxTypes) {
boolean found = false;
for (String type : rawInboxTypes) {
if (type.contains(firstContextName) && type.contains(MIRROR_TYPE_URL)) {
found = true;
}
}
assertWithMessage("`Inbox` deliveries must have an entry " +
"registered for Context `%s` and `%s` projection type.",
firstContextName, MIRROR_TYPE_URL)
.that(found)
.isTrue();
}

private static InboxDeliveries registeredDeliveries() {
return ServerEnvironment.instance()
.delivery()
.registeredDeliveries();
}

@SuppressWarnings("ResultOfMethodCallIgnored" /* Just triggering `Inbox` registration. */)
private static <A extends Aggregate<String, ?, ?>>
void buildContext(String name, Class<A> entityType) {
BoundedContext.singleTenant(name)
.add(DefaultRepository.of(entityType))
.build();
}
}
Loading