use of org.infinispan.commands.module.ModuleCommandFactory in project infinispan by infinispan.
the class ModuleProperties method loadModuleCommandHandlers.
public void loadModuleCommandHandlers(ClassLoader cl) {
Collection<ModuleCommandExtensions> moduleCmdExtLoader = ServiceFinder.load(ModuleCommandExtensions.class, cl);
if (moduleCmdExtLoader.iterator().hasNext()) {
commandFactories = new HashMap<>(1);
moduleCommands = new HashSet<>(1);
for (ModuleCommandExtensions extension : moduleCmdExtLoader) {
log.debugf("Loading module command extension SPI class: %s", extension);
ModuleCommandFactory cmdFactory = extension.getModuleCommandFactory();
Objects.requireNonNull(cmdFactory);
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()));
commandFactories.put(id, cmdFactory);
moduleCommands.add(command.getValue());
}
}
} else {
log.debug("No module command extensions to load");
commandFactories = Collections.emptyMap();
}
}
use of org.infinispan.commands.module.ModuleCommandFactory in project infinispan by infinispan.
the class InfinispanRegionFactory method getCacheCommandFactory.
private CacheCommandFactory getCacheCommandFactory() {
final GlobalComponentRegistry globalCr = manager.getGlobalComponentRegistry();
final Map<Byte, ModuleCommandFactory> factories = globalCr.getComponent("org.infinispan.modules.command.factories");
for (ModuleCommandFactory factory : factories.values()) {
if (factory instanceof CacheCommandFactory) {
return (CacheCommandFactory) factory;
}
}
throw log.cannotInstallCommandFactory();
}
use of org.infinispan.commands.module.ModuleCommandFactory in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method getCacheCommandFactory.
private CacheCommandFactory getCacheCommandFactory() {
final GlobalComponentRegistry globalCr = manager.getGlobalComponentRegistry();
final Map<Byte, ModuleCommandFactory> factories = (Map<Byte, ModuleCommandFactory>) globalCr.getComponent("org.infinispan.modules.command.factories");
for (ModuleCommandFactory factory : factories.values()) {
if (factory instanceof CacheCommandFactory) {
return (CacheCommandFactory) factory;
}
}
throw log.cannotInstallCommandFactory();
}
Aggregations