You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Nirmal Fernando <ni...@wso2.com> on 2013/12/29 19:06:49 UTC

Loading providers and APIs via ServiceLoader

Hi All,

I've a question on $subject. Currently in Apis.java class I could see
following method;

/**
    * Returns the apis located on the classpath via {@link
java.util.ServiceLoader}.
    *
    * @return all available apis loaded from classpath via ServiceLoader
    */
   private static Iterable<ApiMetadata> fromServiceLoader() {
      return ServiceLoader.load(ApiMetadata.class);
   }

But, in any of the jclouds API jars I couldn't find the relevant config
file that required by Java Service Loader [1].

I'm trying to load some APIs via Eclipse and unable to do so, am guessing
due to this issue. I think the issue is same for any non-OSGi environment.

Can someone please explain this behaviour?

[1] http://www.oracle.com/technetwork/articles/javase/extensible-137159.html

-- 

Thanks & regards,
Nirmal

Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/

Re: Loading providers and APIs via ServiceLoader

Posted by Nirmal Fernando <ni...@wso2.com>.
Thanks Ignasi! Ya, it seems git and eclipse messed up my local setup :(


On Mon, Dec 30, 2013 at 1:37 AM, Ignasi Barrera <na...@apache.org> wrote:

> Hi Nirmal,
>
> In the jars for the Apis you'll find the corresponding ApiMetadata file
> inside the META-INF/services folder. (see the EC2 api metadata file [1] for
> an example). Providers have the equivalent ProviderMetadata file (see [2]).
>
> I bet your issue will be a Eclipse specific classpath configuration thing.
> Do you have any jclouds api/provider project open? If so, try closing it
> and try again.
>
> HTH!
>
> Ignasi
>
> [1]
>
> https://github.com/jclouds/jclouds/blob/master/apis/ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
> [2]
>
> https://github.com/jclouds/jclouds/blob/master/providers/aws-ec2/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
> El 29/12/2013 19:07, "Nirmal Fernando" <ni...@wso2.com> escribió:
>
> > Hi All,
> >
> > I've a question on $subject. Currently in Apis.java class I could see
> > following method;
> >
> > /**
> >     * Returns the apis located on the classpath via {@link
> > java.util.ServiceLoader}.
> >     *
> >     * @return all available apis loaded from classpath via ServiceLoader
> >     */
> >    private static Iterable<ApiMetadata> fromServiceLoader() {
> >       return ServiceLoader.load(ApiMetadata.class);
> >    }
> >
> > But, in any of the jclouds API jars I couldn't find the relevant config
> > file that required by Java Service Loader [1].
> >
> > I'm trying to load some APIs via Eclipse and unable to do so, am guessing
> > due to this issue. I think the issue is same for any non-OSGi
> environment.
> >
> > Can someone please explain this behaviour?
> >
> > [1]
> > http://www.oracle.com/technetwork/articles/javase/extensible-137159.html
> >
> > --
> >
> > Thanks & regards,
> > Nirmal
> >
> > Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
> > Mobile: +94715779733
> > Blog: http://nirmalfdo.blogspot.com/
> >
>



-- 

Thanks & regards,
Nirmal

Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/

Re: Loading providers and APIs via ServiceLoader

Posted by Ignasi Barrera <na...@apache.org>.
Hi Nirmal,

In the jars for the Apis you'll find the corresponding ApiMetadata file
inside the META-INF/services folder. (see the EC2 api metadata file [1] for
an example). Providers have the equivalent ProviderMetadata file (see [2]).

I bet your issue will be a Eclipse specific classpath configuration thing.
Do you have any jclouds api/provider project open? If so, try closing it
and try again.

HTH!

Ignasi

[1]
https://github.com/jclouds/jclouds/blob/master/apis/ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
[2]
https://github.com/jclouds/jclouds/blob/master/providers/aws-ec2/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
El 29/12/2013 19:07, "Nirmal Fernando" <ni...@wso2.com> escribió:

> Hi All,
>
> I've a question on $subject. Currently in Apis.java class I could see
> following method;
>
> /**
>     * Returns the apis located on the classpath via {@link
> java.util.ServiceLoader}.
>     *
>     * @return all available apis loaded from classpath via ServiceLoader
>     */
>    private static Iterable<ApiMetadata> fromServiceLoader() {
>       return ServiceLoader.load(ApiMetadata.class);
>    }
>
> But, in any of the jclouds API jars I couldn't find the relevant config
> file that required by Java Service Loader [1].
>
> I'm trying to load some APIs via Eclipse and unable to do so, am guessing
> due to this issue. I think the issue is same for any non-OSGi environment.
>
> Can someone please explain this behaviour?
>
> [1]
> http://www.oracle.com/technetwork/articles/javase/extensible-137159.html
>
> --
>
> Thanks & regards,
> Nirmal
>
> Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
> Mobile: +94715779733
> Blog: http://nirmalfdo.blogspot.com/
>