@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; }
/** * Creates an instance of {@link ApiMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ApiMetadata> listApiMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ApiMetadata.class); }
/** * Searches for {@link ProviderMetadata} and {@link ApiMetadata} registered under the {@link Bundle} id. If metadata * are found they are removed the {@link ProviderRegistry} and {@link ApiRegistry}. Also the {@link ProviderListener} * and {@link ApiListener} are notified. * * @param bundle */ private synchronized void removeBundle(Bundle bundle) { for (ProviderMetadata providerMetadata : providerMetadataMap.removeAll(bundle.getBundleId())) { ProviderRegistry.unregisterProvider(providerMetadata); for (ProviderListener listener : providerListeners) { listener.removed(providerMetadata); } } for (ApiMetadata apiMetadata : apiMetadataMap.removeAll(bundle.getBundleId())) { ApiRegistry.unRegisterApi(apiMetadata); for (ApiListener listener : apiListeners) { listener.removed(apiMetadata); } } }
@Override public synchronized void bundleChanged(BundleEvent event) { switch (event.getType()) { case STARTED: addBundle(event.getBundle()); break; case STOPPING: case STOPPED: removeBundle(event.getBundle()); break; } }
/** * Creates an instance of {@link ProviderMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
@Override public synchronized void bundleChanged(BundleEvent event) { switch (event.getType()) { case STARTED: addBundle(event.getBundle()); break; case STOPPING: case STOPPED: removeBundle(event.getBundle()); break; } }
/** * Creates an instance of {@link ApiMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ApiMetadata> listApiMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ApiMetadata.class); }
@Override public synchronized void bundleChanged(BundleEvent event) { switch (event.getType()) { case STARTED: addBundle(event.getBundle()); break; case STOPPING: case STOPPED: removeBundle(event.getBundle()); break; } }
/** * Creates an instance of {@link ProviderMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
@Override public synchronized void bundleChanged(BundleEvent event) { switch (event.getType()) { case STARTED: addBundle(event.getBundle()); break; case STOPPING: case STOPPED: removeBundle(event.getBundle()); break; } }
/** * Creates an instance of {@link ApiMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ApiMetadata> listApiMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ApiMetadata.class); }
@Override public synchronized void bundleChanged(BundleEvent event) { switch (event.getType()) { case STARTED: addBundle(event.getBundle()); break; case STOPPING: case STOPPED: removeBundle(event.getBundle()); break; } }
/** * Creates an instance of {@link ApiMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ApiMetadata> listApiMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ApiMetadata.class); }
/** * Creates an instance of {@link ProviderMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
/** * Creates an instance of {@link ApiMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ApiMetadata> listApiMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ApiMetadata.class); }
/** * Creates an instance of {@link ProviderMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
/** * Creates an instance of {@link ProviderMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
/** * Creates an instance of {@link ApiMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ApiMetadata> listApiMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ApiMetadata.class); }
/** * Creates an instance of {@link ProviderMetadata} from the {@link Bundle}. * * @param bundle * @return */ public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
/** * Creates an instance of {@link org.jclouds.management.ViewMBeanFactory} from the {@link org.osgi.framework.Bundle}. * * @param bundle * @return */ public Iterable<ViewMBeanFactory> listManagedViewFactories(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle("/META-INF/services/" + ViewMBeanFactory.class.getName(), bundle); return instantiateAvailableClasses(bundle, classNames, ViewMBeanFactory.class); } }