commandFactories = new HashMap<Byte, ModuleCommandFactory>(1);
commandInitializers = new HashMap<Byte, ModuleCommandInitializer>(1);
moduleCommands = new HashSet<Class<? extends ReplicableCommand>>(1);
for (ModuleCommandExtensions extension : moduleCmdExtLoader) {
log.debugf("Loading module command extension SPI class: %s", extension);
ExtendedModuleCommandFactory cmdFactory = extension.getModuleCommandFactory();
ModuleCommandInitializer cmdInitializer = extension.getModuleCommandInitializer();
for (Map.Entry<Byte, Class<? extends ReplicableCommand>> command :
cmdFactory.getModuleCommands().entrySet()) {
byte id = command.getKey();
if (commandFactories.containsKey(id))
throw new IllegalArgumentException(String.format(
"Cannot use id %d for commands, as it is already in use by %s",
id, commandFactories.get(id).getClass().getName()));