A pastie or gist would be fine but in this case a pull request would be even better. Just a work-in-progress PR for us to look at. It's not like we would necessarily merge it either. It's just to share code and comment on it.
Everett On Jan 21, 2014, at 3:48 PM, Ignasi Barrera wrote: > Can you paste in a gist or pastie the GlanceApiMetadata classes? > Have you assigned a different ID to each, like "glance-v1" and "glance-v2"? > > On 21 January 2014 22:27, Ignacio Mulas Viela <[email protected]> wrote: >> I tried having in the ServiceLoader file the two APiMetadata, run the tests >> and it only takes the first class that it is in the serviceLoader file. If >> I put first the v2 ApiMetadata then the v1 tests fails due to a cast >> conversion problem. And viceversa if the first class is the v1. The error >> is the following (in case v2 is first): >> >> Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy52 cannot be >> cast to org.jclouds.openstack.glance.v1_0.GlanceApi >> >> The configuration file contains: >> org.jclouds.openstack.glance.v2_0.GlanceApiMetadata >> org.jclouds.openstack.glance.v1_0.GlanceApiMetadata >> >> Any clue about what I am missing here? >> >> >> 2014/1/21 Ignasi Barrera <[email protected]> >> >>> By default you don't have to do nothing apart from having the two >>> ApiMetadata classes and have them declared in the ServiceLoader file. >>> It will work :) >>> >>> Feel free to join the #jclouds IRC channel @Freenode if you want to >>> discuss it live! >>> >>> On 21 January 2014 21:58, Ignacio Mulas Viela <[email protected]> >>> wrote: >>>> Thanks everyone for the discussion and the hints! I think I will try to >>>> maintain everything inside one glance module and see where it goes, If I >>>> can achieve the correct loading of the two services I think it will be >>>> better than having the code divided in different projects as Glance only >>>> contains one API (imageAPI). >>>> >>>> @Ignasi thanks for the implementation hints, I will try to investigate >>> how >>>> I can implement the two contexts depending on the versions. >>>> >>>> >>>> >>>> >>>> 2014/1/21 Ignasi Barrera <[email protected]> >>>> >>>>> With the described approach you'll need two contexts, one to use each >>>>> version (as the ServiceLoader will create one instance of the service >>> for >>>>> each). >>>>> >>>>> Depending on the complexity of the differences, perhaps it can be >>>>> configured with a single ApiMetadata and let Guice *provide* the right >>>>> classes depending on the *apiVersion* (it can be configured when >>> creating >>>>> the context). jclouds-chef already does this to handle the >>> deserialization >>>>> of objects in different versions of the api [1] (see the peoviders at >>> the >>>>> end of the file). >>>>> >>>>> [1] >>>>> >>>>> >>> https://github.com/jclouds/jclouds-chef/blob/master/core/src/main/java/org/jclouds/chef/config/ChefParserModule.java >>>>> El 21/01/2014 19:13, "Andrew Phillips" <[email protected]> >>> escribió: >>>>> >>>>>> If we start going down the path of breaking it out into glance-v1, >>>>>>> glance-v2, and glance-common, we're going to see an explosion of >>>>>>> OpenStack modules in jclouds as new versions of APIs are released in >>>>>>> OpenStack land. >>>>>>> >>>>>> >>>>>> I wasn't very clear in my original answer: I was under the impression >>>>> that >>>>>> the two versions cannot coexist simultaneously in the same context. If >>>>>> there's no problem to have both of these loaded at the same time, then >>>>>> let's definitely try to do that in one dependency! >>>>>> >>>>>> ap >>>>>> >>>>> >>>
