jclouds-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ioannis Canellos <ioca...@gmail.com>
Subject Re: where is the code for initializing "providers" empty hashset?
Date Sat, 29 Jun 2013 18:20:57 GMT
The fromRegistry() method has meaning only inside the OSGi context.
The java service loader doesn't work well unless you are using a flat class loader. In OSGi
this is not the case, so we are also looking up the OSGi Service Registry for registered providers
& apis.

So how do those providers and apis get registered in OSGi? The Bundle Activator of the jclouds-core
module is listening for installed bundles and its scanning for META-INF/services/.… which
then registers to the OSGi service registry. It acts like a bridge between java.util.ServiceLoader
and the OSGi Service Registry (if that makes it easier to understand).

On Jun 28, 2013, at 7:30 PM, fivos <fivos.oeo@gmail.com> wrote:

> Hi,
> I was going through some code in org.jclouds.providers.
> providers.java
>    /**
>     * Returns all available providers.
>     * 
>     * @return all available providers
>     */
>    public static Iterable<ProviderMetadata> all() {
>      return ImmutableSet.<ProviderMetadata>builder()
>                         .addAll(fromServiceLoader())
>                         .addAll(ProviderRegistry.fromRegistry()).build();
>    }
> Apparently fromRegistry() returns  all the providers which are supposed to be stored
in a variable called providers in ProviderRegistry class. Now could someone point to me when/where
this providers variable gets initialized with all the provider metadata supported by jclouds?

> Thanks in advance, I am attaching the code I am using to create a server
> Fivos K.
> p.s: i m sorry if i accidentally sent this twice.

View raw message