Examples of ContextBuilder


Examples of org.jclouds.ContextBuilder

                        + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
         }

      ProviderMetadata pm = createProviderMetadata();

      ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder
            .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden")));
      return builder;
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

   protected void initializeComputeContext() {
      if (computeContext != null)
         computeContext.close();
      Properties overrides = setupComputeProperties();
      ContextBuilder builder = ContextBuilder.newBuilder(computeProvider)
               .credentials(computeIdentity, computeCredential).overrides(overrides).modules(setupModules());
      if (computeApiversion != null)
         builder.apiVersion(computeApiversion);
      if (computeBuildversion != null)
         builder.buildVersion(computeBuildversion);

      computeContext = builder.buildView(ComputeServiceContext.class);
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

   protected ApiMetadata createApiMetadata() {
      return null;
   }

   protected Injector createInjector(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
      ContextBuilder builder = null;
      if (provider != null)
         try {
            builder = ContextBuilder.newBuilder(provider).credentials(identity, credential);
         } catch (NoSuchElementException e) {
            Logger
                     .getAnonymousLogger()
                     .warning(
                              "provider ["
                                       + provider
                                       + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
         }
      if (builder == null) {
         ProviderMetadata pm = createProviderMetadata();
         ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden");

         builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(am);
      }
      ApiMetadata am = builder.getApiMetadata();
      if (am instanceof HttpApiMetadata) {
         this.api = HttpApiMetadata.class.cast(am).getApi();
      } else if (am instanceof org.jclouds.rest.RestApiMetadata) {
         this.api = org.jclouds.rest.RestApiMetadata.class.cast(am).getApi();
      } else {
         throw new UnsupportedOperationException("unsupported base type: " + am);
      }
      // isolate tests from eachother, as default credentialStore is static
      return builder.credentials(identity, credential).modules(
               ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), new CredentialStoreModule(new CopyInputStreamInputSupplierMap(
                     new ConcurrentHashMap<String, InputSupplier<InputStream>>())), module)).overrides(props)
               .buildInjector();
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

   }

   protected Injector createInjector() {
      ProviderMetadata pm = createProviderMetadata();

      ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(ApiMetadata.class
            .cast(checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden")));

      return builder.credentials(identity, credential)
            .modules(ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()))
            .overrides(setupProperties()).buildInjector();
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

   }

   @Override
   protected ContextBuilder newBuilder() {
      ProviderMetadata pm = createProviderMetadata();
      ContextBuilder builder = ContextBuilder.newBuilder(pm);
      return builder;
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

   protected ApiMetadata createApiMetadata() {
      return null;
   }

   protected Injector createInjector(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
      ContextBuilder builder = null;
      if (provider != null)
         try {
            builder = ContextBuilder.newBuilder(provider).credentials(identity, credential);
         } catch (NoSuchElementException e) {
            Logger
                     .getAnonymousLogger()
                     .warning(
                              "provider ["
                                       + provider
                                       + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
         }
      if (builder == null) {
         ProviderMetadata pm = createProviderMetadata();
         ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden");

         builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(am);
      }
      ApiMetadata am = builder.getApiMetadata();
      if (am instanceof HttpApiMetadata) {
         this.api = HttpApiMetadata.class.cast(am).getApi();
      } else if (am instanceof org.jclouds.rest.RestApiMetadata) {
         this.api = org.jclouds.rest.RestApiMetadata.class.cast(am).getApi();
      } else {
         throw new UnsupportedOperationException("unsupported base type: " + am);
      }
      // isolate tests from eachother, as default credentialStore is static
      return builder.credentials(identity, credential)
               .modules(ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), new CredentialStoreModule(new ConcurrentHashMap<String, ByteSource>()), module))
               .overrides(props)
               .buildInjector();
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

   }

   protected Injector createInjector() {
      ProviderMetadata pm = createProviderMetadata();

      ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(ApiMetadata.class
            .cast(checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden")));

      return builder.credentials(identity, credential)
            .modules(ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()))
            .overrides(setupProperties()).buildInjector();
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

                        + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
         }

      ProviderMetadata pm = createProviderMetadata();

      ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder
            .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden")));
      return builder;
   }
View Full Code Here

Examples of org.jclouds.ContextBuilder

      if (computeService == null && canCreateService) {
         try {
            // This may run in or inside OSGi, so we choose explicitly set a credential store which
            // should be compatible with both.
            ContextBuilder builder = ContextBuilder
                     .newBuilder(providerOrApiValue)
                     .credentials(identityValue, credentialValue)
                     .modules(ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule(),
                              new PropertiesCredentialStore()));
            if (!Strings.isNullOrEmpty(endpointValue)) {
               builder = builder.endpoint(endpointValue);
            }
            computeService = builder.build(ComputeServiceContext.class).getComputeService();
         } catch (Exception ex) {
            throw new RuntimeException("Failed to create service:" + ex.getMessage());
         }
      }
      return computeService;
View Full Code Here

Examples of org.jclouds.ContextBuilder

            throw new RuntimeException(sb.toString());
         }
      }
      if (blobStore == null && canCreateService) {
         try {
            ContextBuilder builder = ContextBuilder.newBuilder(providerOrApiValue)
                     .credentials(identityValue, credentialValue)
                     .modules(ImmutableSet.<Module> of(new Log4JLoggingModule()));
            if (!Strings.isNullOrEmpty(endpointValue)) {
               builder = builder.endpoint(endpointValue);
            }
            BlobStoreContext context = builder.build(BlobStoreContext.class);
            blobStore = context.getBlobStore();
         } catch (Exception ex) {
            throw new RuntimeException("Failed to create service: " + ex.getMessage(), ex);
         }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.