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
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,31 @@
})
public class TestActorRequestFactory extends ActorRequestFactory {

/**
* Creates a new factory with the specified actor and time zone.
*
* @param actor
* the ID of the user who performs operations
* @param zoneId
* the time zone in which the actor operates
*/
public TestActorRequestFactory(UserId actor, ZoneId zoneId) {
super(ActorRequestFactory.newBuilder()
.setActor(actor)
.setZoneId(zoneId)
);
}

/**
* Creates a new factory with the specified tenant, actor and time zone.
*
* @param tenantId
* the ID of the tenant in a multi-tenant application
* @param actor
* the ID of the user who performs operations
* @param zoneId
* the time zone in which the actor operates
*/
public TestActorRequestFactory(@Nullable TenantId tenantId, UserId actor, ZoneId zoneId) {
super(ActorRequestFactory.newBuilder()
.setTenantId(tenantId)
Expand All @@ -68,29 +86,74 @@ public TestActorRequestFactory(@Nullable TenantId tenantId, UserId actor, ZoneId
);
}

/**
* Creates a new factory with an actor ID created from the string and specified time zone.
*
* @param actor
* the string to create actor ID from
* @param zoneId
* the time zone in which the actor operates
*/
public TestActorRequestFactory(String actor, ZoneId zoneId) {
this(GivenUserId.of(actor), zoneId);
}

/**
* Creates a new factory using the test class name as the actor ID and system default time zone.
*
* @param testClass
* the class whose name will be used as the actor ID
*/
public TestActorRequestFactory(Class<?> testClass) {
this(testClass.getName(), ZoneIds.systemDefault());
}

/**
* Creates a new factory with the specified actor and system default time zone.
*
* @param actor
* the ID of the user who performs operations
*/
public TestActorRequestFactory(UserId actor) {
this(actor, ZoneIds.systemDefault());
}

/**
* Creates a new factory with the specified actor, tenant and system default time zone.
*
* @param actor
* the ID of the user who performs operations
* @param tenantId
* the ID of the tenant in a multi-tenant application
*/
public TestActorRequestFactory(UserId actor, TenantId tenantId) {
this(tenantId, actor, ZoneIds.systemDefault());
}

/**
* Creates a new factory using the test class name as the actor ID,
* specified tenant and system default time zone.
*
* @param testClass
* the class whose name will be used as the actor ID
* @param tenantId
* the ID of the tenant in a multi-tenant application
*/
public TestActorRequestFactory(Class<?> testClass, TenantId tenantId) {
this(tenantId,
GivenUserId.of(testClass.getName()),
ZoneIds.systemDefault());
}

/** Creates new command with the passed timestamp. */
/**
* Creates a new command with the given message and timestamp.
*
* @param message
* the command message
* @param timestamp
* the time when the command was created
* @return new command instance with the specified timestamp
*/
public Command createCommand(CommandMessage message, Timestamp timestamp) {
var command = command().create(message);
return withTimestamp(command, timestamp);
Expand All @@ -111,6 +174,13 @@ private static Command withTimestamp(Command command, Timestamp timestamp) {
return result;
}

/**
* Creates a new command with the given message.
*
* @param message
* the command message
* @return new command instance
*/
public Command createCommand(CommandMessage message) {
var command = command().create(message);
return command;
Expand Down
24 changes: 12 additions & 12 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-client:2.0.0-SNAPSHOT.348`
# Dependencies of `io.spine:spine-client:2.0.0-SNAPSHOT.349`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -1085,14 +1085,14 @@

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Thu Nov 06 20:06:57 WET 2025** using
This report was generated on **Tue Nov 11 19:50:43 WET 2025** 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-client-testlib:2.0.0-SNAPSHOT.348`
# Dependencies of `io.spine.tools:spine-client-testlib:2.0.0-SNAPSHOT.349`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -2273,14 +2273,14 @@ This report was generated on **Thu Nov 06 20:06:57 WET 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Thu Nov 06 20:06:57 WET 2025** using
This report was generated on **Tue Nov 11 19:50:43 WET 2025** 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:2.0.0-SNAPSHOT.348`
# Dependencies of `io.spine:spine-core:2.0.0-SNAPSHOT.349`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -3301,14 +3301,14 @@ This report was generated on **Thu Nov 06 20:06:57 WET 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Thu Nov 06 20:06:57 WET 2025** using
This report was generated on **Tue Nov 11 19:50:43 WET 2025** 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-core-testlib:2.0.0-SNAPSHOT.348`
# Dependencies of `io.spine.tools:spine-core-testlib:2.0.0-SNAPSHOT.349`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -4375,14 +4375,14 @@ This report was generated on **Thu Nov 06 20:06:57 WET 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Thu Nov 06 20:06:57 WET 2025** using
This report was generated on **Tue Nov 11 19:50:43 WET 2025** 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:2.0.0-SNAPSHOT.348`
# Dependencies of `io.spine:spine-server:2.0.0-SNAPSHOT.349`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -5479,14 +5479,14 @@ This report was generated on **Thu Nov 06 20:06:57 WET 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Thu Nov 06 20:06:57 WET 2025** using
This report was generated on **Tue Nov 11 19:50:43 WET 2025** 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-server-testlib:2.0.0-SNAPSHOT.348`
# Dependencies of `io.spine.tools:spine-server-testlib:2.0.0-SNAPSHOT.349`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -6719,6 +6719,6 @@ This report was generated on **Thu Nov 06 20:06:57 WET 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Thu Nov 06 20:06:57 WET 2025** using
This report was generated on **Tue Nov 11 19:50:43 WET 2025** 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 @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
<groupId>io.spine</groupId>
<artifactId>spine-core-jvm</artifactId>
<version>2.0.0-SNAPSHOT.348</version>
<version>2.0.0-SNAPSHOT.349</version>

<inceptionYear>2015</inceptionYear>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public abstract class AggregateRepository<I,
private final Supplier<CommandRouting<I>> commandRouting;

/** The routing schema for events to which aggregates react. */
private final EventRouting<I> eventRouting;
private final Supplier<EventRouting<I>> eventRouting;

/**
* The routing for event import, which by default obtains the target aggregate ID as the
* {@linkplain io.spine.core.EventContext#getProducerId() producer ID} of the event.
*/
private final EventRouting<I> eventImportRouting;
private final Supplier<EventRouting<I>> eventImportRouting;

/**
* The {@link Inbox} for the messages, which are sent to the instances managed by this
Expand All @@ -134,8 +134,12 @@ public abstract class AggregateRepository<I,
protected AggregateRepository() {
super();
this.commandRouting = memoize(() -> CommandRouting.newInstance(idClass()));
this.eventRouting = EventRouting.withDefaultByProducerId();
this.eventImportRouting = EventRouting.withDefaultByProducerId();
this.eventRouting = memoize(
() -> EventRouting.withDefaultByProducerIdOrFirstField(idClass())
);
this.eventImportRouting = memoize(
() -> EventRouting.withDefaultByProducerIdOrFirstField(idClass())
);
}

/**
Expand Down Expand Up @@ -174,7 +178,7 @@ public void registerWith(BoundedContext context) {
private void setupRouting() {
doSetupCommandRouting();
doSetupEventRouting();
setupImportRouting(eventImportRouting);
setupImportRouting(eventImportRouting.get());
}

private void doSetupCommandRouting() {
Expand All @@ -185,8 +189,8 @@ private void doSetupCommandRouting() {
}

private void doSetupEventRouting() {
EventRoutingSetup.apply(entityClass(), eventRouting);
setupEventRouting(eventRouting);
EventRoutingSetup.apply(entityClass(), eventRouting.get());
setupEventRouting(eventRouting.get());
}

@Override
Expand Down Expand Up @@ -478,7 +482,7 @@ private RouteFn<? extends EventMessage, EventContext, I> eventImportRouting() {
* if {@link #eventImportRouting} returns more than one ID
*/
private I idForImported(EventMessage message, EventContext context) {
var ids = eventImportRouting.invoke(message, context);
var ids = eventImportRouting.get().invoke(message, context);
var numberOfTargets = ids.size();
var messageType = message.getClass()
.getName();
Expand Down Expand Up @@ -515,7 +519,7 @@ private CommandRouting<I> commandRouting() {
* Obtains event routing instance used by this repository.
*/
private EventRouting<I> eventRouting() {
return eventRouting;
return eventRouting.get();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
import io.spine.server.type.EventEnvelope;

import java.util.Set;
import java.util.function.Supplier;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Suppliers.memoize;

/**
* Abstract base for repositories that deliver events to entities they manage.
Expand All @@ -56,11 +58,13 @@ public abstract class EventDispatchingRepository<I,
extends DefaultRecordBasedRepository<I, E, S>
implements EventDispatcher {

private final EventRouting<I> eventRouting;
private final Supplier<EventRouting<I>> eventRouting;

protected EventDispatchingRepository() {
super();
this.eventRouting = EventRouting.withDefaultByProducerId();
this.eventRouting = memoize(
() -> EventRouting.withDefaultByProducerIdOrFirstField(idClass())
);
}

/**
Expand All @@ -76,8 +80,8 @@ public void registerWith(BoundedContext context) {
context.internalAccess()
.registerEventDispatcher(this);

EventRoutingSetup.apply(entityClass(), eventRouting);
setupEventRouting(eventRouting);
EventRoutingSetup.apply(entityClass(), eventRouting.get());
setupEventRouting(eventRouting.get());
}

/**
Expand Down Expand Up @@ -129,7 +133,7 @@ public final DispatchOutcome dispatch(EventEnvelope event) {
* @return a set of IDs of projections to dispatch the given event to
*/
protected Set<I> route(EventEnvelope event) {
var targets = route(eventRouting, event);
var targets = route(eventRouting.get(), event);
@SuppressWarnings("unchecked")
var result = (Set<I>) targets.orElse(ImmutableSet.of());
return result;
Expand Down
5 changes: 2 additions & 3 deletions server/src/main/kotlin/io/spine/server/route/ByFirstField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ internal class ByFirstField<I : Any, M : Routable, C : SignalContext>(
/**
* Obtains a descriptor of the first field of the passed.
*
* @throws IllegalStateException
* if the passed message does not declare fields, or
* the field is a repeated field or a map
* @throws IllegalStateException if the passed message does not declare fields, or
* the field is a repeated field or a map.
*/
@Suppress("ThrowsCount")
private fun fieldIn(message: M): FieldDescriptor {
Expand Down
Loading
Loading