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>
Provides a singleton value of type
In the above case,
The state of
An example might be if DruidServerConfig.class were
<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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidstatic <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) get()voidinject(Properties props, JsonConfigurator configurator) static <T> JsonConfigProvider<T> static <T> JsonConfigProvider<T>
-
Constructor Details
-
JsonConfigProvider
-
-
Method Details
-
bind
-
bindWithDefault
-
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
-
bind
-
bindInstance
public static <T> void bindInstance(com.google.inject.Binder binder, com.google.inject.Key<T> bindKey, T instance) -
of
-
of
public static <T> JsonConfigProvider<T> of(String propertyBase, Class<T> classToProvide, Class<? extends T> defaultClass) -
inject
-
get
-