Class JsonConfigProvider<T>

java.lang.Object
org.apache.druid.guice.JsonConfigProvider<T>
Type Parameters:
T - type of config object to provide.
All Implemented Interfaces:
com.google.inject.Provider<T>, jakarta.inject.Provider<T>, javax.inject.Provider<T>

public class JsonConfigProvider<T> extends Object implements com.google.inject.Provider<T>
Provides a singleton value of type <T> from Properties bound in guice.

Usage

To install this provider, bind it in your guice module, like below.
 JsonConfigProvider.bind(binder, "druid.server", DruidServerConfig.class);
 

In the above case, druid.server should be a key found in the Properties bound elsewhere. The value of that key should directly relate to the fields in DruidServerConfig.class.

Implementation


The state of <T> is defined by the value of the property propertyBase. This value is a json structure, decoded via JsonConfigurator.configurate(Properties, String, Class).
An example might be if DruidServerConfig.class were
   public class DruidServerConfig
   {
  • Constructor Details

    • JsonConfigProvider

      public JsonConfigProvider(String propertyBase, Class<T> classToProvide, @Nullable Class<? extends T> defaultClass)
  • Method Details

    • bind

      public static <T> void bind(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide)
    • bindWithDefault

      public static <T> void bindWithDefault(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide, Class<? extends T> defaultClass)
    • bind

      public static <T> void bind(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide, Annotation annotation)
    • bind

      public static <T> void bind(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide, Class<? extends Annotation> annotation)
    • bind

      public static <T> void bind(com.google.inject.Binder binder, String propertyBase, Class<T> clazz, com.google.inject.Key<T> instanceKey, com.google.inject.Key<com.google.common.base.Supplier<T>> supplierKey)
    • bind

      public static <T> void bind(com.google.inject.Binder binder, String propertyBase, Class<T> clazz, Class<? extends T> defaultClass, com.google.inject.Key<T> instanceKey, com.google.inject.Key<com.google.common.base.Supplier<T>> supplierKey)
    • bindInstance

      public static <T> void bindInstance(com.google.inject.Binder binder, com.google.inject.Key<T> bindKey, T instance)
    • of

      public static <T> JsonConfigProvider<T> of(String propertyBase, Class<T> classToProvide)
    • of

      public static <T> JsonConfigProvider<T> of(String propertyBase, Class<T> classToProvide, Class<? extends T> defaultClass)
    • inject

      @Inject public void inject(Properties props, JsonConfigurator configurator)
    • get

      public T get()
      Specified by:
      get in interface com.google.inject.Provider<T>
      Specified by:
      get in interface jakarta.inject.Provider<T>
      Specified by:
      get in interface javax.inject.Provider<T>