Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dremio Pluggable Helper
protected <IFACE, IMPL extends IFACE> Class<? extends IFACE> setupPluggableService(
final Class<IFACE> bind,
final Class<IMPL> defaultBind,
final SingletonRegistry registry,
final DremioConfig config,
final ScanResult scanResult,
final String configKey) {
//If we want to make it pluggable in the future, but haven't setup a key for it, just use the default implementation
final String keyValue = StringUtils.isEmpty(configKey) ? null : config.getString(configKey);
if (keyValue == null) {
registry.bind(bind, defaultBind); + " service is configured.");
return defaultBind;
// Find class by FQN or Partial Name match
final List<String> allowedProviders = new ArrayList<>();
final Set<Class<? extends IFACE>> implementations = scanResult.getImplementations(bind);
for (Class<? extends IFACE> clazz : implementations) {
if (clazz.getName().toLowerCase().contains(keyValue)) {
registry.bind(bind, clazz); + " service is configured.");
return clazz;
final String providers = String.join(",", allowedProviders);
logger.error("Unknown value '{}' set for {}. Accepted string contains values are [{}]", keyValue, configKey, providers);
throw new RuntimeException(
String.format("Unknown service type '%s' set in config path '%s'", keyValue, configKey));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.