You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/05/29 17:52:06 UTC

[GitHub] [incubator-druid] esevastyanov commented on a change in pull request #7789: Druid basic authentication class composition config

esevastyanov commented on a change in pull request #7789: Druid basic authentication class composition config
URL: https://github.com/apache/incubator-druid/pull/7789#discussion_r288693182
 
 

 ##########
 File path: extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/BasicSecurityDruidModule.java
 ##########
 @@ -168,6 +211,33 @@ public static BasicAuthorizerCacheNotifier createAuthorizerCacheNotifier(final I
     );
   }
 
+  /**
+   * Returns the instance provided either by a config property or coordinator-run class or default class.
+   * The order of check corresponds to the order of method params.
+   */
+  @Nullable
+  public static <T> T getInstance(
+      Injector injector,
+      String configClassName,
+      Class<? extends T> classRunByCoordinator,
+      Class<? extends T> defaultClass
+  ) throws ClassNotFoundException
+  {
+    if (configClassName != null) {
+      // ClassCastException is thrown in case of a mismatch, configuration fix is required.
+      @SuppressWarnings("unchecked")
+      final T instance = (T) injector.getInstance(Class.forName(configClassName));
+      return instance;
+    }
+    if (classRunByCoordinator != null && isCoordinator(injector)) {
+      return injector.getInstance(classRunByCoordinator);
+    }
+    if (defaultClass != null) {
+      return injector.getInstance(defaultClass);
+    }
+    return null;
 
 Review comment:
   Null is for backward compatibility (for cases when a specific component is not needed)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org