本文整理汇总了Java中com.google.inject.AbstractModule类的典型用法代码示例。如果您正苦于以下问题:Java AbstractModule类的具体用法?Java AbstractModule怎么用?Java AbstractModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractModule类属于com.google.inject包,在下文中一共展示了AbstractModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mainExceptionTest
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Test(expected = ConfigException.class)
public void mainExceptionTest() throws Exception {
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
bind(AccessService.class).toInstance(accessServiceMock);
bind(InformationService.class).toInstance(informationServiceMock);
bind(TemplateService.class).toInstance(templateServiceMock);
bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(10);
bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(10);
bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
bind(Double.class).annotatedWith(Names.named("placeWidth")).toInstance(1200d);
bind(PositionDTO.class).annotatedWith(Names.named("startPosition")).toInstance(new PositionDTO());
}
});
//given
PowerMockito.mockStatic(Guice.class);
Mockito.when(Guice.createInjector((AbstractModule)anyObject())).thenReturn(injector);
doThrow(new ApiException()).when(accessServiceMock).addTokenOnConfiguration(false, null ,null);
Main.main(new String[]{"-nifi","http://localhost:8080/nifi-api","-branch","\"root>N2\"","-conf","adr","-m","undeploy"});
}
示例2: newIsisWicketModule
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(ComponentFactoryRegistrar.class).to(MyComponentFactoryRegistrar.class);
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("RotaBuilder");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("RotaBuilder");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
// if uncommented, then overrides isis.appManifest in config file.
// bind(AppManifest.class).toInstance(new DomainAppAppManifest());
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例3: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ServerFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IWorldServer.class);
bind(IWorldServer.class).to(IUT2004Server.class);
bind(IUT2004Server.class).to(UT2004TCServer.class);
}
});
}
示例4: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ServerFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IWorldServer.class);
bind(IWorldServer.class).to(IUT2004Server.class);
bind(IUT2004Server.class).to(UT2004HSServer.class);
}
});
}
示例5: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ObserverFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IUT2004Observer.class);
// THIS tells guice it should instantiate our class and not default one
bind(IUT2004Observer.class).to(HSObserver.class);
}
});
}
示例6: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ServerFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IWorldServer.class);
bind(IWorldServer.class).to(IUT2004Server.class);
bind(IUT2004Server.class).to(UT2004TagServer.class);
}
});
}
示例7: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ServerFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IWorldServer.class);
bind(IWorldServer.class).to(IUT2004Server.class);
bind(IUT2004Server.class).to(UT2004VIPServer.class);
}
});
}
示例8: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ObserverFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IUT2004Observer.class);
// THIS tells guice it should instantiate our class and not default one
bind(IUT2004Observer.class).to(CSObserver.class);
}
});
}
示例9: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(
new AbstractModule() {
@Override
protected void configure() {
bind(ICommandSerializer.class).to(StringCommandSerializer.class);
bind(IAct.class).to(Act.class);
bind(IWorldReaderProvider.class).to(IWorldConnection.class);
bind(IWorldWriterProvider.class).to(IWorldConnection.class);
}
}
);
}
示例10: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldConnection.class).to(SocketConnection.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(SocketConnection.CONNECTION_DEPENDENCY)).toProvider(connectionDependenciesProvider);
bind(ISocketConnectionAddress.class).annotatedWith(Names.named(SocketConnection.CONNECTION_ADDRESS_DEPENDENCY)).toProvider((Provider<ISocketConnectionAddress>) getAddressProvider());
bind(IWorldMessageParser.class).to(UT2004Parser.class);
bind(ItemTypeTranslator.class).to(UT2004ItemTypeTranslator.class);
bind(IYylex.class).to(IUT2004Yylex.class);
bind(IUT2004Yylex.class).to(Yylex.class);
bind(IYylexObserver.class).to(IYylexObserver.LogObserver.class);
bind(UT2004AgentParameters.class).toProvider(getAgentParamsProvider());
}
});
}
示例11: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ObserverFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IUT2004Observer.class);
bind(IUT2004Observer.class).to(UT2004Observer.class);
}
});
}
示例12: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(ServerFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(UT2004WorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004WorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IWorldServer.class);
bind(IWorldServer.class).to(IUT2004Server.class);
bind(IUT2004Server.class).to(UT2004Server.class);
}
});
}
示例13: configureModules
import com.google.inject.AbstractModule; //导入依赖的package包/类
@Override
protected void configureModules() {
super.configureModules();
addModule(new AbstractModule() {
@Override
public void configure() {
bind(IWorldMessageTranslator.class).to(BotFSM.class);
bind(IWorldView.class).to(IVisionWorldView.class);
bind(IVisionWorldView.class).to(ILockableVisionWorldView.class);
bind(ILockableWorldView.class).to(ILockableVisionWorldView.class);
bind(ILockableVisionWorldView.class).to(UT2004SyncLockableWorldView.class);
bind(ComponentDependencies.class).annotatedWith(Names.named(UT2004SyncLockableWorldView.WORLDVIEW_DEPENDENCY)).toProvider(worldViewDependenciesProvider);
bind(IAgent.class).to(IAgent3D.class);
bind(IAgent3D.class).to(IUT2004Bot.class);
bind(IUT2004Bot.class).to(UT2004Bot.class);
if (botControllerClass != null) {
bind(IUT2004BotController.class).to(botControllerClass);
}
bind(UT2004BotParameters.class).toProvider((Provider<? extends UT2004BotParameters>) getAgentParamsProvider());
}
});
}
示例14: setUp
import com.google.inject.AbstractModule; //导入依赖的package包/类
@BeforeEach
public void setUp() {
Injector injector =
Guice.createInjector(
Modules.override(
new DatasetModule(), new CannedDatasetsModule(), new ConfigurationModule())
.with(
new MongoOverrideModule(),
new AbstractModule() {
@Override
protected void configure() {
bind(CannedDatasetsLoader.class)
.toInstance(Mockito.mock(CannedDatasetsLoader.class));
}
}));
injector.injectMembers(this);
when(mongoProvider.provide()).thenReturn(getMongoClient());
}
示例15: trueMain
import com.google.inject.AbstractModule; //导入依赖的package包/类
private static void trueMain(String[] argv) throws IOException {
final Parameters params = Parameters.loadSerifStyle(new File(argv[0]));
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
try {
bind(EREToKBPEventOntologyMapper.class)
.toInstance(EREToKBPEventOntologyMapper.create2016Mapping());
} catch (IOException ioe) {
throw new TACKBPEALException(ioe);
}
}
@Provides
ERELoader ereLoader() {
return ERELoader.builder().build();
}
}).getInstance(DerivedQuerySelector2016.class)
.go(params.copyNamespace("com.bbn.tac.eal"));
}