use of com.google.inject.assistedinject.FactoryModuleBuilder in project guice by google.
the class SubpackageTest method testPrivateFallbackOnly.
@Test
public void testPrivateFallbackOnly() throws Exception {
// Private fallback only works on JDKs below 17. On 17+ it's disabled.
assumeTrue(JAVA_VERSION < 17);
setAllowMethodHandleWorkaround(false);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().build(ConcreteAssistedWithOverride.Factory.class));
}
});
LogRecord record = Iterables.getOnlyElement(logRecords);
assertThat(record.getMessage()).contains("Please pass a `MethodHandles.lookup()`");
ConcreteAssistedWithOverride.Factory factory = injector.getInstance(ConcreteAssistedWithOverride.Factory.class);
factory.create("foo");
AbstractAssisted.Factory<ConcreteAssistedWithOverride, String> factoryAbstract = factory;
factoryAbstract.create("foo");
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project guice by google.
the class SubpackageTest method testHandleWorkaroundOnly.
@Test
public void testHandleWorkaroundOnly() throws Exception {
setAllowPrivateLookupFallback(false);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().build(ConcreteAssistedWithOverride.Factory.class));
}
});
LogRecord record = Iterables.getOnlyElement(logRecords);
assertThat(record.getMessage()).contains("Please pass a `MethodHandles.lookup()`");
ConcreteAssistedWithOverride.Factory factory = injector.getInstance(ConcreteAssistedWithOverride.Factory.class);
factory.create("foo");
AbstractAssisted.Factory<ConcreteAssistedWithOverride, String> factoryAbstract = factory;
factoryAbstract.create("foo");
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project gerrit by GerritCodeReview.
the class LuceneIndexModuleOnInit method configure.
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(AccountIndex.class, LuceneAccountIndex.class).build(AccountIndex.Factory.class));
install(new FactoryModuleBuilder().implement(GroupIndex.class, LuceneGroupIndex.class).build(GroupIndex.Factory.class));
install(new IndexModuleOnInit());
bind(AutoFlush.class).toInstance(AutoFlush.DISABLED);
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project gerrit by GerritCodeReview.
the class DeleteZombieDrafts method getSysInjector.
private Injector getSysInjector() {
List<Module> modules = new ArrayList<>();
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(Path.class).annotatedWith(SitePath.class).toInstance(getSitePath());
bind(ConsoleUI.class).toInstance(ConsoleUI.getInstance(false));
bind(String.class).annotatedWith(SecureStoreClassName.class).toProvider(Providers.of(getConfiguredSecureStoreClass()));
bind(MetricMaker.class).to(DisabledMetricMaker.class);
install(new FactoryModuleBuilder().build(DeleteZombieCommentsRefs.Factory.class));
}
});
modules.add(new GerritServerConfigModule());
modules.add(new SchemaModule());
return Guice.createInjector(modules);
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.
the class ServerBindings method bindInterfaces.
private void bindInterfaces() {
bind(AlertSender.class).to(FormattedEmailAlertSender.class);
bind(StreamRouter.class);
install(new FactoryModuleBuilder().implement(StreamRouterEngine.class, StreamRouterEngine.class).build(StreamRouterEngine.Factory.class));
bind(ActivityWriter.class).to(SystemMessageActivityWriter.class);
bind(PersistedInputs.class).to(PersistedInputsImpl.class);
bind(RoleService.class).to(RoleServiceImpl.class).in(Scopes.SINGLETON);
OptionalBinder.newOptionalBinder(binder(), ClusterIdFactory.class).setDefault().to(RandomUUIDClusterIdFactory.class);
}
Aggregations