use of com.google.inject.AbstractModule in project whirr by apache.
the class ComputeServiceContextBuilder method build.
public static ComputeServiceContext build(ClusterSpec spec) throws IOException {
Set<AbstractModule> wiring = ImmutableSet.of(new JschSshClientModule(), new Log4JLoggingModule());
ComputeServiceContext context = new ComputeServiceContextFactory().createContext(spec.getProvider(), spec.getIdentity(), spec.getCredential(), wiring);
return context;
}
use of com.google.inject.AbstractModule in project che by eclipse.
the class SubversionProjectImporterTest method setUp.
@Before
public void setUp() throws Exception {
// Bind components
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), ProjectImporter.class).addBinding().to(SubversionProjectImporter.class);
Multibinder.newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(SubversionProjectType.class);
Multibinder.newSetBinder(binder(), ValueProviderFactory.class).addBinding().to(SubversionValueProviderFactory.class);
bind(SshKeyProvider.class).toInstance(sshKeyProvider);
bind(ProfileDao.class).toInstance(userProfileDao);
bind(RepositoryUrlProvider.class).toInstance(repositoryUrlProvider);
}
});
// Init virtual file system
VirtualFileSystem virtualFileSystem = TestUtils.createVirtualFileSystem();
root = virtualFileSystem.getRoot();
// Create the test user
TestUtils.createTestUser(userProfileDao);
// Create the Subversion repository
repoRoot = TestUtils.createGreekTreeRepository();
projectImporter = injector.getInstance(SubversionProjectImporter.class);
}
use of com.google.inject.AbstractModule in project gerrit by GerritCodeReview.
the class SiteProgram method getDbType.
private String getDbType(Provider<DataSource> dsProvider) {
String dbProductName;
try (Connection conn = dsProvider.get().getConnection()) {
dbProductName = conn.getMetaData().getDatabaseProductName().toLowerCase();
} catch (SQLException e) {
throw new RuntimeException(e);
}
List<Module> modules = new ArrayList<>();
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(Path.class).annotatedWith(SitePath.class).toInstance(getSitePath());
}
});
modules.add(new GerritServerConfigModule());
modules.add(new DataSourceModule());
Injector i = Guice.createInjector(modules);
List<Binding<DataSourceType>> dsTypeBindings = i.findBindingsByType(new TypeLiteral<DataSourceType>() {
});
for (Binding<DataSourceType> binding : dsTypeBindings) {
Annotation annotation = binding.getKey().getAnnotation();
if (annotation instanceof Named) {
if (((Named) annotation).value().toLowerCase().contains(dbProductName)) {
return ((Named) annotation).value();
}
}
}
throw new IllegalStateException(String.format("Cannot guess database type from the database product name '%s'", dbProductName));
}
use of com.google.inject.AbstractModule in project guice by google.
the class ModuleAnnotatedMethodScannerTest method testWithSource.
public void testWithSource() throws Exception {
Module module = new AbstractModule() {
@Override
protected void configure() {
binder().withSource("source").install(new AbstractModule() {
@Override
protected void configure() {
}
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
});
}
};
Injector injector = Guice.createInjector(module, NamedMunger.module());
assertMungedBinding(injector, String.class, "foo", "foo");
}
use of com.google.inject.AbstractModule in project guice by google.
the class ModuleAnnotatedMethodScannerTest method testPrivateModule_skipSourcesForPrivateModule.
public void testPrivateModule_skipSourcesForPrivateModule() {
Injector injector = Guice.createInjector(NamedMunger.module(), new AbstractModule() {
@Override
protected void configure() {
binder().skipSources(getClass()).install(new PrivateModule() {
@Override
protected void configure() {
}
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
});
}
});
assertMungedBinding(injector, String.class, "foo", "foo");
}
Aggregations