Package org.apache.druid.guice
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>,javax.inject.Provider<T>
public class JsonConfigProvider<T> extends Object implements com.google.inject.Provider<T>
Provides a singleton value of type<T>fromPropertiesbound 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.servershould be a key found in thePropertiesbound elsewhere. The value of that key should directly relate to the fields inDruidServerConfig.class.Implementation
The state of<T>is defined by the value of the propertypropertyBase. This value is a json structure, decoded viaJsonConfigurator.configurate(Properties, String, Class).
An example might be if DruidServerConfig.class werepublic class DruidServerConfig {
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> voidbind(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide)static <T> voidbind(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)static <T> voidbind(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide, Annotation annotation)static <T> voidbind(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide, Class<? extends Annotation> annotation)static <T> voidbind(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)static <T> voidbindInstance(com.google.inject.Binder binder, com.google.inject.Key<T> bindKey, T instance)static <T> voidbindWithDefault(com.google.inject.Binder binder, String propertyBase, Class<T> classToProvide, Class<? extends T> defaultClass)Tget()voidinject(Properties props, JsonConfigurator configurator)static <T> JsonConfigProvider<T>of(String propertyBase, Class<T> classToProvide)static <T> JsonConfigProvider<T>of(String propertyBase, Class<T> classToProvide, Class<? extends T> defaultClass)
-
-
-
Method Detail
-
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)
-
-