本文整理了Java中com.google.inject.util.Modules
类的一些代码示例,展示了Modules
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Modules
类的具体详情如下:
包路径:com.google.inject.util.Modules
类名称:Modules
[英]Static utility methods for creating and working with instances of Module.
[中]用于创建和使用模块实例的静态实用程序方法。
代码示例来源:origin: Codecademy/EventHub
properties.putAll(System.getProperties());
Injector injector = Guice.createInjector(Modules.override(
new DmaIdListModule(),
new DatedEventIndexModule(),
new EventStorageModule(),
new UserStorageModule(),
new EventHubModule(properties)).with(new Module()));
final EventHubHandler eventHubHandler = injector.getInstance(EventHubHandler.class);
int port = injector.getInstance(Key.get(Integer.class, Names.named("eventhubhandler.port")));
代码示例来源:origin: com.google.inject/guice
/** Returns a new module that installs all of {@code modules}. */
public static Module combine(Module... modules) {
return combine(ImmutableSet.copyOf(modules));
}
代码示例来源:origin: apache/incubator-druid
private Injector newInjector(final Properties props)
{
List<Module> modules = ImmutableList.<Module>builder()
.addAll(GuiceInjectors.makeDefaultStartupModules())
.add(new LifecycleModule()).add(new CuratorModule()).build();
return Guice.createInjector(
Modules.override(modules).with(new Module()
{
@Override
public void configure(Binder binder)
{
binder.bind(Properties.class).toInstance(props);
}
})
);
}
代码示例来源:origin: ben-manes/caffeine
@BeforeMethod
public void beforeMethod() {
Module module = Modules.override(new CacheAnnotationsModule()).with(new CaffeineJCacheModule());
Guice.createInjector(module).injectMembers(this);
}
代码示例来源:origin: com.yahoo.vespa/standalone-container
static Container getContainer(Module... modules) {
Module activatorModule = new ActivatorModule();
List<Module> allModules = new ArrayList<>();
allModules.addAll(Arrays.asList(modules));
allModules.add(activatorModule);
StandaloneContainerApplication app = new StandaloneContainerApplication(Guice.createInjector(Modules.combine(allModules)));
return app.container();
}
代码示例来源:origin: org.jbehave/jbehave-guice
protected Injector createInjector(List<Module> modules) {
if ( injector != null ){
return injector;
}
Injector root = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
}
});
return root.createChildInjector(Modules.combine(modules));
}
代码示例来源:origin: matsim-org/matsim
@Override
public void install() {
final List<com.google.inject.Module> guiceModules = new ArrayList<>();
for (AbstractModule module : modules) {
bootstrapInjector.injectMembers(module);
guiceModules.add(module);
}
bootstrapInjector.injectMembers(abstractModule);
binder().install(Modules.override(guiceModules).with(abstractModule));
}
};
代码示例来源:origin: com.yahoo.vespa/jdisc_core
private <T extends ServerProvider, U, V> void testContainerNotReadyException(
final Adapter<T, U, V> adapter,
final Module... config)
throws Throwable {
runTest(adapter,
Modules.override(Modules.combine(config)).with(newActivateContainer(false)),
RequestType.WITHOUT_CONTENT,
new TestRequestHandler() {
@Override
public ContentChannel handle(Request request, ResponseHandler handler) {
throw new AssertionError();
}
});
}
代码示例来源:origin: embulk/embulk
@Override
public List<Module> apply(List<Module> modules) {
Module override = new Module() {
public void configure(Binder binder) {
binder.bind(BulkLoader.class).to(TestingBulkLoader.class);
registerPluginTo(binder, InputPlugin.class, "preview_result", PreviewResultInputPlugin.class);
}
};
return ImmutableList.of(Modules.override(modules).with(ImmutableList.of(override)));
}
};
代码示例来源:origin: kairosdb/kairosdb
mod = Modules.override(moduleList.get(0)).with(mod);
moduleList.set(0, mod);
m_injector = Guice.createInjector(moduleList);
代码示例来源:origin: caelum/vraptor
public void start(ServletContext context) {
this.context = context;
APPLICATION.start();
container = new GuiceContainer();
injector = Guice.createInjector(Stage.PRODUCTION, Modules.override(new VRaptorAbstractModule(context, container)).with(customModule()));
executeStereotypeHandlers();
injector.injectMembers(REQUEST);
injector.injectMembers(SESSION);
}
代码示例来源:origin: com.teradata.tempto/tempto-core
private Injector buildInjector()
{
return createInjector(combine(baseModule, statesModule(), testContextModule()));
}
代码示例来源:origin: com.yahoo.vespa/jdisc_core
private <T extends ServerProvider, U, V> void testNoBindingSetSelectedException(
final Adapter<T, U, V> adapter,
final Module... config)
throws Throwable {
runTest(adapter,
Modules.override(Modules.combine()).with(newBindingSetSelector(null)),
RequestType.WITHOUT_CONTENT,
new TestRequestHandler() {
@Override
public ContentChannel handle(Request request, ResponseHandler handler) {
throw new AssertionError();
}
});
}
代码示例来源:origin: bootique/bootique
private Module fold(RuntimeModule rm) {
RuntimeModule overriddenBy = rm.getOverriddenBy();
if (overriddenBy == null) {
trace(rm.getBqModule(), null);
return rm.getModule();
}
trace(rm.getBqModule(), overriddenBy.getBqModule());
// WARN: using recursion because fold.. is there a realistic prospect of this blowing the stack? I haven't
// seen overrides more than 2-4 levels deep.
// fold must happen in this order (overriding starts from the tail). Otherwise the algorithm will not work.
return Modules.override(rm.getModule()).with(fold(overriddenBy));
}
代码示例来源:origin: apache/incubator-druid
Module intermediateModules = Modules.override(defaultModules.getModules()).with(actualModules.getModules());
final ExtensionsConfig config = baseInjector.getInstance(ExtensionsConfig.class);
for (DruidModule module : Initialization.getFromExtensions(config, DruidModule.class)) {
extensionModules.addModule(module);
return Guice.createInjector(Modules.override(intermediateModules).with(extensionModules.getModules()));
代码示例来源:origin: xvik/dropwizard-guicey
@Override
public Injector createInjector(final Stage stage, final Iterable<? extends Module> modules) {
final Module[] override = OVERRIDING_MODULES.get();
OVERRIDING_MODULES.remove();
TOO_LATE.set(true);
if (override != null) {
printOverridingModules(override);
}
return Guice.createInjector(stage, override == null ? modules
: Lists.newArrayList(Modules.override(modules).with(override)));
}
代码示例来源:origin: org.kill-bill.billing/killbill-beatrix
@BeforeClass(groups = "slow")
public void beforeClass() throws Exception {
if (hasFailed()) {
return;
}
final Injector g = Guice.createInjector(Stage.PRODUCTION, Modules.override(new BeatrixIntegrationModule(configSource, clock)).with(new OverrideModuleForOSGI()));
g.injectMembers(this);
}
代码示例来源:origin: prestodb/tempto
private Injector buildInjector()
{
return createInjector(combine(baseModule, statesModule(), testContextModule()));
}
代码示例来源:origin: com.yahoo.vespa/jdisc_core
private <T extends ServerProvider, U, V> void testBindingNotFoundException(
final Adapter<T, U, V> adapter,
final Module... config)
throws Throwable {
runTest(adapter,
Modules.override(Modules.combine(config)).with(newServerBinding("not://found/")),
RequestType.WITHOUT_CONTENT,
new TestRequestHandler() {
@Override
public ContentChannel handle(Request request, ResponseHandler handler) {
throw new AssertionError();
}
});
}
代码示例来源:origin: HubSpot/Singularity
mainBinder.install(Modules.override(new SingularityMainModule(configuration))
.with(new Module() {
mainBinder.install(Modules.override(new SingularityMesosModule())
.with(new Module() {
内容来源于网络,如有侵权,请联系作者删除!