use of io.spine.server.event.EventDispatcher in project core-java by SpineEventEngine.
the class BoundedContext method register.
/**
* Registers the passed repository with the {@code BoundedContext}.
*
* <p>If the repository does not have a storage assigned, it will be initialized
* using the {@code StorageFactory} associated with this bounded context.
*
* @param repository the repository to register
* @param <I> the type of IDs used in the repository
* @param <E> the type of entities or aggregates
* @see Repository#initStorage(StorageFactory)
*/
@SuppressWarnings("ChainOfInstanceofChecks")
public <// OK here since ways of registering are way too different
I, E extends Entity<I, ?>> void register(Repository<I, E> repository) {
checkStorageAssigned(repository);
guard.register(repository);
if (repository instanceof CommandDispatcher) {
commandBus.register((CommandDispatcher) repository);
}
if (repository instanceof ProcessManagerRepository) {
final ProcessManagerRepository procmanRepo = (ProcessManagerRepository) repository;
commandBus.register(DelegatingCommandDispatcher.of(procmanRepo));
}
if (repository instanceof EventDispatcher) {
eventBus.register((EventDispatcher) repository);
}
if (managesVersionableEntities(repository)) {
stand.registerTypeSupplier(cast(repository));
}
}
Aggregations