You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by fivos <fi...@gmail.com> on 2013/07/01 11:40:58 UTC

Re: where is the code for initializing "providers" empty hashset?

Thanks for the reply, It was very helpful. I wasn't aware of  OSGi and how
it works. I looked it up and your answer is clear to me now.


On Sat, Jun 29, 2013 at 9:20 PM, Ioannis Canellos <io...@gmail.com> wrote:

> 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 <fi...@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.
>
>

Re: where is the code for initializing "providers" empty hashset?

Posted by Ignasi <ig...@gmail.com>.
It will scan the META-INF/services folder in the classpath. That
includes all loaded jars and classes, so as long as your provider jar
contains that file, it should be properly loaded.

On 1 July 2013 14:08, fivos <fi...@gmail.com> wrote:
> I've checked the META-INF/services folder and it only contains this file :
> org.jclouds.logging.config.LoggingModule
>
> However the bundle activator is scanning for
> "/META-INF/services/org.jclouds.providers.ProviderMetadata" .
> My main question should be if I create a new Provider, how will I make sure
> it gets registered in OSGi?
>
>
> On Mon, Jul 1, 2013 at 12:40 PM, fivos <fi...@gmail.com> wrote:
>
>> Thanks for the reply, It was very helpful. I wasn't aware of  OSGi and how
>> it works. I looked it up and your answer is clear to me now.
>>
>>
>> On Sat, Jun 29, 2013 at 9:20 PM, Ioannis Canellos <io...@gmail.com>wrote:
>>
>>> 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 <fi...@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.
>>>
>>>
>>

Re: where is the code for initializing "providers" empty hashset?

Posted by fivos <fi...@gmail.com>.
I've checked the META-INF/services folder and it only contains this file :
org.jclouds.logging.config.LoggingModule

However the bundle activator is scanning for
"/META-INF/services/org.jclouds.providers.ProviderMetadata" .
My main question should be if I create a new Provider, how will I make sure
it gets registered in OSGi?


On Mon, Jul 1, 2013 at 12:40 PM, fivos <fi...@gmail.com> wrote:

> Thanks for the reply, It was very helpful. I wasn't aware of  OSGi and how
> it works. I looked it up and your answer is clear to me now.
>
>
> On Sat, Jun 29, 2013 at 9:20 PM, Ioannis Canellos <io...@gmail.com>wrote:
>
>> 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 <fi...@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.
>>
>>
>