Search in sources :

Example 1 with ProcessManagerRepository

use of io.spine.server.procman.ProcessManagerRepository 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));
    }
}
Also used : EventDispatcher(io.spine.server.event.EventDispatcher) ProcessManagerRepository(io.spine.server.procman.ProcessManagerRepository) DelegatingCommandDispatcher(io.spine.server.commandbus.DelegatingCommandDispatcher) CommandDispatcher(io.spine.server.commandbus.CommandDispatcher)

Aggregations

CommandDispatcher (io.spine.server.commandbus.CommandDispatcher)1 DelegatingCommandDispatcher (io.spine.server.commandbus.DelegatingCommandDispatcher)1 EventDispatcher (io.spine.server.event.EventDispatcher)1 ProcessManagerRepository (io.spine.server.procman.ProcessManagerRepository)1