mirror of https://github.com/apache/druid.git
add compositemodule
This commit is contained in:
parent
34ab911399
commit
22d8a4b872
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.druid.initialization;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.Module;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.inject.Binder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CompositeDruidModule implements DruidModule
|
||||||
|
{
|
||||||
|
protected final DruidModule[] modules;
|
||||||
|
|
||||||
|
public CompositeDruidModule(DruidModule... modules)
|
||||||
|
{
|
||||||
|
this.modules = modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Module> getJacksonModules()
|
||||||
|
{
|
||||||
|
ImmutableList.Builder<Module> builder = ImmutableList.builder();
|
||||||
|
for (DruidModule druidModule : modules) {
|
||||||
|
builder.addAll(druidModule.getJacksonModules());
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(Binder binder)
|
||||||
|
{
|
||||||
|
for (DruidModule druidModule : modules) {
|
||||||
|
binder.install(druidModule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,6 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import org.apache.druid.guice.BuiltInTypesModule;
|
|
||||||
import org.apache.druid.guice.LazySingleton;
|
import org.apache.druid.guice.LazySingleton;
|
||||||
import org.apache.druid.initialization.ServerInjectorBuilderTest.TestDruidModule;
|
import org.apache.druid.initialization.ServerInjectorBuilderTest.TestDruidModule;
|
||||||
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
|
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
|
||||||
|
@ -68,6 +67,5 @@ public class TestSqlModule extends TestDruidModule
|
||||||
binder.bind(AuthenticatorMapper.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_MAPPER);
|
binder.bind(AuthenticatorMapper.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_MAPPER);
|
||||||
binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
|
binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
|
||||||
binder.bind(Escalator.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR);
|
binder.bind(Escalator.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR);
|
||||||
binder.install(new BuiltInTypesModule());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,14 @@ import com.google.inject.Binder;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import org.apache.druid.guice.BuiltInTypesModule;
|
||||||
import org.apache.druid.guice.DruidInjectorBuilder;
|
import org.apache.druid.guice.DruidInjectorBuilder;
|
||||||
import org.apache.druid.guice.ExpressionModule;
|
import org.apache.druid.guice.ExpressionModule;
|
||||||
import org.apache.druid.guice.LazySingleton;
|
import org.apache.druid.guice.LazySingleton;
|
||||||
import org.apache.druid.guice.SegmentWranglerModule;
|
import org.apache.druid.guice.SegmentWranglerModule;
|
||||||
import org.apache.druid.guice.StartupInjectorBuilder;
|
import org.apache.druid.guice.StartupInjectorBuilder;
|
||||||
|
import org.apache.druid.initialization.CompositeDruidModule;
|
||||||
import org.apache.druid.initialization.CoreInjectorBuilder;
|
import org.apache.druid.initialization.CoreInjectorBuilder;
|
||||||
import org.apache.druid.initialization.DruidModule;
|
|
||||||
import org.apache.druid.initialization.ServiceInjectorBuilder;
|
import org.apache.druid.initialization.ServiceInjectorBuilder;
|
||||||
import org.apache.druid.java.util.common.RE;
|
import org.apache.druid.java.util.common.RE;
|
||||||
import org.apache.druid.java.util.common.io.Closer;
|
import org.apache.druid.java.util.common.io.Closer;
|
||||||
|
@ -545,22 +546,23 @@ public class SqlTestFramework
|
||||||
* This is an intermediate solution: the ultimate solution is to create things
|
* This is an intermediate solution: the ultimate solution is to create things
|
||||||
* in Guice itself.
|
* in Guice itself.
|
||||||
*/
|
*/
|
||||||
private class TestSetupModule implements DruidModule
|
private class TestSetupModule extends CompositeDruidModule
|
||||||
{
|
{
|
||||||
private final Builder builder;
|
private final Builder builder;
|
||||||
|
|
||||||
public TestSetupModule(Builder builder)
|
public TestSetupModule(Builder builder)
|
||||||
{
|
{
|
||||||
|
super(new BuiltInTypesModule(), new TestSqlModule());
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Binder binder)
|
public void configure(Binder binder)
|
||||||
{
|
{
|
||||||
|
super.configure(binder);
|
||||||
binder.bind(DruidOperatorTable.class).in(LazySingleton.class);
|
binder.bind(DruidOperatorTable.class).in(LazySingleton.class);
|
||||||
binder.bind(DataSegment.PruneSpecsHolder.class).toInstance(DataSegment.PruneSpecsHolder.DEFAULT);
|
binder.bind(DataSegment.PruneSpecsHolder.class).toInstance(DataSegment.PruneSpecsHolder.DEFAULT);
|
||||||
binder.bind(DefaultColumnFormatConfig.class).toInstance(new DefaultColumnFormatConfig(null, null));
|
binder.bind(DefaultColumnFormatConfig.class).toInstance(new DefaultColumnFormatConfig(null, null));
|
||||||
binder.install(new TestSqlModule());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
Loading…
Reference in New Issue