@Provides @LazySingleton public CloudFilesApi getCloudFilesApi(final CloudFilesAccountConfig config) { log.info("Building Cloud Files Api..."); Iterable<com.google.inject.Module> modules; if (config.getUseServiceNet()) { log.info("Configuring Cloud Files Api to use the internal service network..."); modules = ImmutableSet.of(new SLF4JLoggingModule(), new InternalUrlModule()); } else { log.info("Configuring Cloud Files Api to use the public network..."); modules = ImmutableSet.of(new SLF4JLoggingModule()); } ProviderRegistry.registerProvider(CloudFilesUSProviderMetadata.builder().build()); ProviderRegistry.registerProvider(CloudFilesUKProviderMetadata.builder().build()); ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider()) .credentials(config.getUserName(), config.getApiKey()).modules(modules); CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class); log.info("Cloud Files Api built."); return cfa; }
.credentials(identity, credential) .modules(ImmutableList.<Module>of( new SLF4JLoggingModule(), new ExecutorServiceModule(executorService))) .overrides(properties);
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
private static List<AbstractModule> getModules() { return asList(new SLF4JLoggingModule(), new SshjSshClientModule()); } }
private List<AbstractModule> getModules() { return asList(new SLF4JLoggingModule(), new SshjSshClientModule()); }
Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule(), new InternalUrlModule()); ContextBuilder builder = ContextBuilder.newBuilder(PROVIDER) .modules(modules) .credentials(username, apiKey); blobStore = builder.buildView(RegionScopedBlobStoreContext.class).getBlobStore(REGION); cloudFiles = blobStore.getContext().unwrapApi(CloudFilesApi.class);
@Override protected Iterable<Module> setupModules() { ImmutableSet.Builder<Module> modules = ImmutableSet.builder(); modules.add(new OkHttpCommandExecutorServiceModule()); modules.add(new SLF4JLoggingModule()); return modules.build(); }
private BlobStoreContext createContext() { ContextBuilder builder = ContextBuilder.newBuilder(provider) .credentialsSupplier(credentials::get) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule())); if (!properties.isEmpty()) { builder.overrides(properties); } return builder.buildView(BlobStoreContext.class); }
public static BlobStore storeFromProperties(Properties properties) { String provider = properties.getProperty(Constants.PROPERTY_PROVIDER); ContextBuilder builder = ContextBuilder .newBuilder(provider) .modules(ImmutableList.<Module>of(new SLF4JLoggingModule())) .overrides(properties); BlobStoreContext context = builder.build(BlobStoreContext.class); return context.getBlobStore(); }
@Test public void testConfigure() { Injector i = Guice.createInjector(new SLF4JLoggingModule()); A a = i.getInstance(A.class); assertEquals(a.logger.getClass(), SLF4JLogger.class); assertEquals(a.logger.getCategory(), getClass().getName() + "$A"); }
protected Set<Module> modules() { ImmutableSet.Builder<Module> modules = ImmutableSet.builder(); modules.add(new ExecutorServiceModule(newDirectExecutorService())); modules.add(new OkHttpCommandExecutorServiceModule()); modules.add(new SLF4JLoggingModule()); return modules.build(); }
protected RestContext<CloudStackClient, CloudStackAsyncClient> newCloudStackContext(Provider provider) { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); return ContextBuilder.newBuilder(new CloudStackApiMetadata()) .endpoint(provider.getEndpoint().get()) .modules(ImmutableSet.of(new SLF4JLoggingModule())) .credentials(provider.getAccessKey(), provider.getSecretKey()) .overrides(overrides) .build(CloudStackApiMetadata.CONTEXT_TOKEN); }
@Override public BlobStoreContext load(Key arg0) { LOG.debug("creating new BlobStoreContext {}", arg0); ContextBuilder builder = ContextBuilder.newBuilder(arg0.provider) .credentials(arg0.identity, arg0.credential) .overrides(arg0.overrides) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule())); if (arg0.endpoint != null) builder.endpoint(arg0.endpoint); BlobStoreContext context = new IgnoreCloseBlobStoreContext( builder.buildView(BlobStoreContext.class)); LOG.info("created new BlobStoreContext {}", context); return context; }
@Override public BlobStoreContext load(Key arg0) { LOG.debug("creating new BlobStoreContext {}", arg0); ContextBuilder builder = ContextBuilder.newBuilder(arg0.provider) .credentials(arg0.identity, arg0.credential) .overrides(arg0.overrides) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule())); if (arg0.endpoint != null) builder.endpoint(arg0.endpoint); BlobStoreContext context = new IgnoreCloseBlobStoreContext( builder.buildView(BlobStoreContext.class)); LOG.info("created new BlobStoreContext {}", context); return context; }
public NeutronSecurityGroupExtensionLiveTest() { provider = "openstack-nova"; Properties overrides = setupProperties(); neutronApiContext = ContextBuilder.newBuilder("openstack-neutron") .endpoint(setIfTestSystemPropertyPresent(overrides, "openstack-nova.endpoint")) .credentials(setIfTestSystemPropertyPresent(overrides, "openstack-nova.identity"), setIfTestSystemPropertyPresent(overrides, "openstack-nova.credential")) .modules(ImmutableSet.<Module>of( new SshjSshClientModule(), new SLF4JLoggingModule()) ) .build(new TypeToken<ApiContext<NeutronApi>>() {}); }
public NovaWithNeutronComputeServiceLiveTest() { provider = "openstack-nova"; Properties overrides = setupProperties(); neutronApiContext = ContextBuilder.newBuilder("openstack-neutron") .endpoint(setIfTestSystemPropertyPresent(overrides, "openstack-nova.endpoint")) .credentials(setIfTestSystemPropertyPresent(overrides, "openstack-nova.identity"), setIfTestSystemPropertyPresent(overrides, "openstack-nova.credential")) .modules(ImmutableSet.<Module>of( new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule()) ) .build(); }