@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(); }
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);
@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"); }
@Override protected Iterable<Module> setupModules() { ImmutableSet.Builder<Module> modules = ImmutableSet.builder(); modules.add(new OkHttpCommandExecutorServiceModule()); modules.add(new SLF4JLoggingModule()); return modules.build(); }
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(); }
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); }
@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"); }
private ContextBuilder initComputeService(String provider, String identity, String credential) { Iterable<Module> modules = ImmutableSet.<Module>of( new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule()); ContextBuilder contextBuilder = ContextBuilder.newBuilder(provider) .credentials(identity, credential) .modules(modules) .overrides(getOptions()); logger.info(String.format("Initializing %s", contextBuilder.getApiMetadata())); return contextBuilder; }
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); }
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(); }
public AwsClient() { String accessKeyId = System.getenv("AWS_ACCESS_KEY_ID"); String secretKey = System.getenv("AWS_SECRET_KEY"); String region = System.getenv("AWS_REGION"); if (StringUtils.isBlank(accessKeyId) || StringUtils.isBlank(secretKey) || StringUtils.isBlank(region)) { throw new NotFoundException("Aws Client need 3 environment variables set : AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, AWS_REGION"); } AWSEC2Api ec2Api = ContextBuilder.newBuilder("aws-ec2").credentials(accessKeyId, secretKey) .modules(ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule())).buildApi(AWSEC2Api.class); blockStoreApi = ec2Api.getElasticBlockStoreApiForRegion(region).get(); instanceApi = ec2Api.getInstanceApiForRegion(region).get(); }
protected JschSshClient createClient(final Properties props) throws UnknownHostException { Injector i = Guice.createInjector(module(), new AbstractModule() { @Override protected void configure() { bindProperties(binder(), props); } }, new SLF4JLoggingModule()); SshClient.Factory factory = i.getInstance(SshClient.Factory.class); JschSshClient ssh = JschSshClient.class.cast(factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials .builder().user("username").password("password").build())); return ssh; }
protected JschSshClient createClient(final Properties props) throws UnknownHostException { Injector i = Guice.createInjector(module(), new AbstractModule() { @Override protected void configure() { bindProperties(binder(), props); } }, new SLF4JLoggingModule()); SshClient.Factory factory = i.getInstance(SshClient.Factory.class); JschSshClient ssh = JschSshClient.class.cast(factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials .builder().user("username").password("password").build())); return ssh; }
protected SshjSshClient createClient(final Properties props) { Injector i = Guice.createInjector(module(), new AbstractModule() { @Override protected void configure() { bindProperties(binder(), props); } }, new SLF4JLoggingModule()); SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshjSshClient ssh = SshjSshClient.class.cast(factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials .builder().user("username").password("password").build())); return ssh; }
public void testConfigureBindsClient() throws UnknownHostException { Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule()); SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient connection = factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials.builder().user("username") .password("password").build()); assert connection instanceof JschSshClient; } }
public void testConfigureBindsClient() throws UnknownHostException { Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule()); SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient connection = factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials.builder().user("username") .password("password").build()); assert connection instanceof JschSshClient; } }
public void testConfigureBindsClient() { Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule()); SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient connection = factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials.builder().user("username") .password("password").build()); assert connection instanceof SshjSshClient; } }