
com.opencredo.concursus.domain.commands.dispatching.DispatchingCommandProcessor Maven / Gradle / Ivy
The newest version!
package com.opencredo.concursus.domain.commands.dispatching;
import com.opencredo.concursus.domain.commands.Command;
import com.opencredo.concursus.domain.commands.CommandType;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A {@link CommandProcessor} that dispatches commands to {@link CommandProcessor}s by {@link CommandType}.
*/
public final class DispatchingCommandProcessor implements CommandProcessor, CommandSubscribable {
/**
* Create a {@link DispatchingCommandProcessor} with no {@link CommandProcessor}s registered to handle commands.
* @return The constructed {@link DispatchingCommandProcessor}
*/
public static DispatchingCommandProcessor create() {
return new DispatchingCommandProcessor(new ConcurrentHashMap<>());
}
private final ConcurrentMap processorRegistry;
private DispatchingCommandProcessor(ConcurrentMap processorRegistry) {
this.processorRegistry = processorRegistry;
}
@Override
public Optional
© 2015 - 2025 Weber Informatics LLC | Privacy Policy