mirror of https://github.com/apache/druid.git
Use Module instead of generic Object in Guice related items
This commit is contained in:
parent
63df70cbe2
commit
7c8d4a7433
|
@ -88,7 +88,7 @@ public class HadoopDruidIndexerConfig
|
|||
static {
|
||||
injector = Initialization.makeInjectorWithModules(
|
||||
GuiceInjectors.makeStartupInjector(),
|
||||
ImmutableList.<Object>of(
|
||||
ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package io.druid.guice;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Guice;
|
||||
|
@ -27,15 +28,16 @@ import com.google.inject.Module;
|
|||
import io.druid.jackson.JacksonModule;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class GuiceInjectors
|
||||
{
|
||||
public static Injector makeStartupInjector()
|
||||
public static Collection<Module> makeDefaultStartupModules()
|
||||
{
|
||||
return Guice.createInjector(
|
||||
return ImmutableList.<Module>of(
|
||||
new DruidGuiceExtensions(),
|
||||
new JacksonModule(),
|
||||
new PropertiesModule(Arrays.asList("common.runtime.properties", "runtime.properties")),
|
||||
|
@ -52,29 +54,18 @@ public class GuiceInjectors
|
|||
);
|
||||
}
|
||||
|
||||
public static Injector makeStartupInjectorWithModules(Iterable<Module> modules)
|
||||
public static Injector makeStartupInjector()
|
||||
{
|
||||
return Guice.createInjector(makeDefaultStartupModules());
|
||||
}
|
||||
|
||||
public static Injector makeStartupInjectorWithModules(Iterable<? extends Module> modules)
|
||||
{
|
||||
List<Module> theModules = Lists.newArrayList();
|
||||
theModules.add(new DruidGuiceExtensions());
|
||||
theModules.add(new JacksonModule());
|
||||
theModules.add(new PropertiesModule(Arrays.asList("common.runtime.properties", "runtime.properties")));
|
||||
theModules.add(new ConfigModule());
|
||||
theModules.add(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
public void configure(Binder binder)
|
||||
{
|
||||
binder.bind(DruidSecondaryModule.class);
|
||||
JsonConfigProvider.bind(binder, "druid.extensions", ExtensionsConfig.class);
|
||||
}
|
||||
}
|
||||
);
|
||||
theModules.addAll(makeDefaultStartupModules());
|
||||
for (Module theModule : modules) {
|
||||
theModules.add(theModule);
|
||||
}
|
||||
|
||||
|
||||
return Guice.createInjector(theModules);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ public class Initialization
|
|||
}
|
||||
}
|
||||
|
||||
public static Injector makeInjectorWithModules(final Injector baseInjector, Iterable<Object> modules)
|
||||
public static Injector makeInjectorWithModules(final Injector baseInjector, Iterable<? extends Module> modules)
|
||||
{
|
||||
final ModuleList defaultModules = new ModuleList(baseInjector);
|
||||
defaultModules.addModules(
|
||||
|
|
|
@ -102,7 +102,7 @@ public class InitializationTest
|
|||
{
|
||||
Injector startupInjector = GuiceInjectors.makeStartupInjector();
|
||||
Injector injector = Initialization.makeInjectorWithModules(
|
||||
startupInjector, ImmutableList.<Object>of(
|
||||
startupInjector, ImmutableList.<com.google.inject.Module>of(
|
||||
new com.google.inject.Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -97,7 +97,7 @@ public class JettyTest
|
|||
{
|
||||
setProperties();
|
||||
Injector injector = Initialization.makeInjectorWithModules(
|
||||
GuiceInjectors.makeStartupInjector(), ImmutableList.<Object>of(
|
||||
GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -62,9 +62,9 @@ public class CliBridge extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -72,9 +72,9 @@ public class CliBroker extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -80,9 +80,9 @@ public class CliCoordinator extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -62,9 +62,9 @@ public class CliHistorical extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -66,9 +66,9 @@ public class CliInternalHadoopIndexer extends GuiceRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -67,9 +67,9 @@ public class CliMiddleManager extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -105,9 +105,9 @@ public class CliOverlord extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -101,9 +101,9 @@ public class CliPeon extends GuiceRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -45,9 +45,9 @@ public class CliRealtime extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new RealtimeModule(),
|
||||
new Module() {
|
||||
@Override
|
||||
|
|
|
@ -55,9 +55,9 @@ public class CliRealtimeExample extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new RealtimeModule(),
|
||||
new Module()
|
||||
{
|
||||
|
|
|
@ -64,9 +64,9 @@ public class CliRouter extends ServerRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new JettyHttpClientModule("druid.router.http", Router.class),
|
||||
new Module()
|
||||
{
|
||||
|
|
|
@ -62,9 +62,9 @@ public class CreateTables extends GuiceRunnable
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getModules()
|
||||
protected List<? extends Module> getModules()
|
||||
{
|
||||
return ImmutableList.<Object>of(
|
||||
return ImmutableList.<Module>of(
|
||||
new Module()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ package io.druid.cli;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.metamx.common.lifecycle.Lifecycle;
|
||||
import com.metamx.common.logger.Logger;
|
||||
import io.druid.initialization.Initialization;
|
||||
|
@ -48,7 +49,7 @@ public abstract class GuiceRunnable implements Runnable
|
|||
this.baseInjector = injector;
|
||||
}
|
||||
|
||||
protected abstract List<Object> getModules();
|
||||
protected abstract List<? extends Module> getModules();
|
||||
|
||||
public Injector makeInjector()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue