Skip to content

Commit

Permalink
Merge pull request #1423 from SpineEventEngine/1.x-safe-requested-types
Browse files Browse the repository at this point in the history
  • Loading branch information
armiol committed Nov 23, 2021
2 parents 902ed12 + 17b33e9 commit aacba13
Show file tree
Hide file tree
Showing 30 changed files with 519 additions and 33 deletions.
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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine:spine-client:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:38 EET 2021** 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 **Mon Nov 22 15:05:52 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine:spine-core:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:38 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:38 EET 2021** 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 **Mon Nov 22 15:05:52 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine.tools:spine-model-assembler:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:38 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:39 EET 2021** 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 **Mon Nov 22 15:05:52 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine.tools:spine-model-verifier:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:39 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:39 EET 2021** 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 **Mon Nov 22 15:05:53 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine:spine-server:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:39 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:39 EET 2021** 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 **Mon Nov 22 15:05:53 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine:spine-testutil-client:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:39 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:41 EET 2021** 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 **Mon Nov 22 15:05:55 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine:spine-testutil-core:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:41 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:42 EET 2021** 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 **Mon Nov 22 15:05:56 EET 2021** 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.7.7-SNAPSHOT.6`
# Dependencies of `io.spine:spine-testutil-server:1.7.7-SNAPSHOT.7`

## 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 **Thu Nov 18 13:57:42 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Nov 18 13:57:44 EET 2021** 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 **Mon Nov 22 15:05:58 EET 2021** 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.7.7-SNAPSHOT.6</version>
<version>1.7.7-SNAPSHOT.7</version>

<inceptionYear>2015</inceptionYear>

Expand Down
7 changes: 7 additions & 0 deletions server/src/main/java/io/spine/server/EventProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

package io.spine.server;

import com.google.common.collect.ImmutableSet;
import com.google.protobuf.Any;
import io.spine.core.Version;
import io.spine.server.model.Nothing;
import io.spine.server.type.EventClass;

/**
* An object with identity which produces events.
Expand Down Expand Up @@ -60,4 +62,9 @@ public interface EventProducer {
default Nothing nothing() {
return Nothing.getDefaultInstance();
}

/**
* Obtains classes of the events produced by this object.
*/
ImmutableSet<EventClass> producedEvents();
}
12 changes: 11 additions & 1 deletion server/src/main/java/io/spine/server/SubscriptionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package io.spine.server;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -170,7 +171,16 @@ private Optional<BoundedContext> findContextOf(Subscription subscription) {
return result;
}

private Optional<BoundedContext> findContextOf(Target target) {
/**
* Searches for the Bounded Context which provides the messages of the target type.
*
* @param target
* the type which may be available through this subscription service
* @return the context which exposes the target type,
* or {@code Optional.empty} if no known context does so
*/
@VisibleForTesting /* Otherwise should have been `private`. */
Optional<BoundedContext> findContextOf(Target target) {
TypeUrl type = target.type();
BoundedContext selected = typeToContextMap.get(type);
Optional<BoundedContext> result = Optional.ofNullable(selected);
Expand Down
8 changes: 8 additions & 0 deletions server/src/main/java/io/spine/server/aggregate/Aggregate.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.protobuf.Any;
import com.google.protobuf.Empty;
import io.spine.annotation.Internal;
Expand All @@ -47,6 +48,7 @@
import io.spine.server.event.EventReactor;
import io.spine.server.event.model.EventReactorMethod;
import io.spine.server.type.CommandEnvelope;
import io.spine.server.type.EventClass;
import io.spine.server.type.EventEnvelope;

import java.util.Iterator;
Expand Down Expand Up @@ -297,6 +299,12 @@ public final BatchDispatchOutcome play(Iterable<Event> events) {
.play(events);
}

@Override
@Internal
public ImmutableSet<EventClass> producedEvents() {
return modelClass().outgoingEvents();
}

/**
* Applies passed events.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@

import com.google.common.collect.ImmutableSet;
import io.spine.core.Version;
import io.spine.server.BoundedContext;
import io.spine.server.command.model.CommandHandlerClass;
import io.spine.server.command.model.CommandHandlerMethod;
import io.spine.server.commandbus.CommandDispatcher;
import io.spine.server.dispatch.DispatchOutcomeHandler;
import io.spine.server.event.EventBus;
import io.spine.server.type.CommandClass;
import io.spine.server.type.CommandEnvelope;
import io.spine.server.type.EventClass;

import static io.spine.server.command.model.CommandHandlerClass.asCommandHandlerClass;

Expand Down Expand Up @@ -90,6 +92,17 @@ public void dispatch(CommandEnvelope envelope) {
.handle();
}

@Override
public void registerWith(BoundedContext context) {
super.registerWith(context);
context.stand().registerTypeSupplier(this);
}

@Override
public ImmutableSet<EventClass> producedEvents() {
return thisClass.commandOutput();
}

@Override
public ImmutableSet<CommandClass> messageClasses() {
return thisClass.commands();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ public Version version() {
return Versions.zero();
}

/**
* {@inheritDoc}
*
* <p>Always returns an empty set.
*/
@Override
public ImmutableSet<EventClass> producedEvents() {
return ImmutableSet.of();
}

private void postCommands(List<Command> commands) {
commandBus().post(commands, noOpObserver());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void registerWith(BoundedContext context) {
checkNotRegistered();
eventBus = context.eventBus();
system = context.systemClient().writeSide();
context.stand().registerTypeSupplier(this);
}

@Override
Expand Down Expand Up @@ -147,4 +148,9 @@ public ImmutableSet<EventClass> externalEventClasses() {
public ImmutableSet<EventClass> domesticEventClasses() {
return thisClass.domesticEvents();
}

@Override
public ImmutableSet<EventClass> producedEvents() {
return thisClass.reactionOutput();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Set;

import static com.google.common.collect.Multimaps.synchronizedSetMultimap;
import static io.spine.protobuf.AnyPacker.unpack;

/**
Expand All @@ -55,9 +56,12 @@ final class ExternalNeedsObserver
* Current set of message type URLs, requested by other parties via sending the
* {@linkplain RequestForExternalMessages configuration messages}, mapped to IDs of their origin
* bounded contexts.
*
* <p>This instance is potentially accessed from different threads,
* therefore it's made concurrency-friendly.
*/
private final Multimap<ExternalMessageType, BoundedContextName> requestedTypes =
HashMultimap.create();
synchronizedSetMultimap(HashMultimap.create());

ExternalNeedsObserver(BoundedContextName context, BusAdapter bus) {
super(context, RequestForExternalMessages.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package io.spine.server.procman;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import io.spine.annotation.Internal;
import io.spine.base.EntityState;
import io.spine.protobuf.ValidatingBuilder;
Expand Down Expand Up @@ -112,6 +113,11 @@ protected ProcessManagerClass<?> thisClass() {
return (ProcessManagerClass<?>) super.thisClass();
}

@Override
public ImmutableSet<EventClass> producedEvents() {
return thisClass().outgoingEvents();
}

/**
* {@inheritDoc}
*
Expand Down
6 changes: 6 additions & 0 deletions server/src/main/java/io/spine/server/stand/EventRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package io.spine.server.stand;

import com.google.common.collect.ImmutableSet;
import io.spine.server.EventProducer;
import io.spine.server.entity.Repository;
import io.spine.server.type.EventClass;
import io.spine.type.TypeUrl;
Expand All @@ -41,6 +42,11 @@ interface EventRegistry extends AutoCloseable {
*/
void register(Repository<?, ?> repository);

/**
* Registers the event producer in this registry.
*/
void register(EventProducer producer);

/**
* Retrieves all event {@linkplain TypeUrl types} stored in the registry.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package io.spine.server.stand;

import com.google.common.collect.ImmutableSet;
import io.spine.server.EventProducer;
import io.spine.server.entity.EventProducingRepository;
import io.spine.server.entity.Repository;
import io.spine.server.type.EventClass;
Expand Down Expand Up @@ -59,6 +60,12 @@ public void register(Repository<?, ?> repository) {
}
}

@Override
public void register(EventProducer producer) {
producer.producedEvents()
.forEach(this::putIntoMap);
}

@Override
public ImmutableSet<TypeUrl> typeSet() {
return ImmutableSet.copyOf(eventClasses.keySet());
Expand Down
12 changes: 9 additions & 3 deletions server/src/main/java/io/spine/server/stand/Stand.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import io.spine.core.Responses;
import io.spine.core.TenantId;
import io.spine.protobuf.AnyPacker;
import io.spine.server.EventProducer;
import io.spine.server.Identity;
import io.spine.server.bus.Listener;
import io.spine.server.entity.Entity;
Expand Down Expand Up @@ -376,6 +377,13 @@ public void registerTypeSupplier(Repository<?, ?> repository) {
eventRegistry.register(repository);
}

/**
* Registers the passed {@code EventProducer} as the event type supplier.
*/
public void registerTypeSupplier(EventProducer producer) {
eventRegistry.register(producer);
}

/**
* Closes the {@code Stand} performing necessary cleanups.
*/
Expand Down Expand Up @@ -504,9 +512,7 @@ private SystemReadSide systemReadSide() {
@Internal
public Stand build() {
checkState(systemReadSide != null, "SystemWriteSide is not set.");
boolean multitenant = this.multitenant == null
? false
: this.multitenant;
boolean multitenant = this.multitenant != null && this.multitenant;
if (subscriptionRegistry == null) {
subscriptionRegistry = MultitenantSubscriptionRegistry.newInstance(multitenant);
}
Expand Down

0 comments on commit aacba13

Please sign in to comment.