felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@adobe.com>
Subject Re: BndTools and DS 1.2 Annotations
Date Sun, 17 Mar 2013 12:00:32 GMT
Hi,

Am 17.03.2013 um 12:55 schrieb Carsten Ziegeler:

> Hi Pierre,
> 
> thanks for the info - I have to look into the details but I think
> supporting this should be really easy. The scr plugin uses an
> interface for a class collector already, so in the plugin we can
> simply create an instance of this one based on the bnd collector and
> pass this into the generator.
> With the latest version of the scr plugin, we switched to separate
> descriptor files for each class to make incremental processing of
> projects easier and we have an integration into Eclipse via the m2e
> plugin. So if you change a java file in Eclipse and your project is
> using m2e, the descriptor gets automatically updated.

Great, we might want to use a similar mechanism for bndtools integration -- looks like a number
of bndtools users generally don't use m2e because they don't use maven at all ...

Regards
Felix


> 
> Regards
> Carsten
> 
> 2013/3/16 Pierre De Rop <pierre.derop@gmail.com>:
>> Hi Felix,
>> 
>> If this can help, you can take a look at [1]: It's a Bnd plugin I wrote in
>> the past for
>> Marcel's DependencyManager.
>> 
>> Basically, when writing a bnd plugin, you have to implement the
>> "aQute.bnd.service.AnalyzerPlugin" interface, which is the entry point for
>> all bnd plugins. This interface contains an "analyzeJar" method, which
>> takes as parameter an "Analyser" class. Along with this Analyzer, a
>> "ClassDataCollector" can then be used to scan classes (.class) at build
>> time, in order to scan annotations and generate corresponding descriptors.
>> 
>> I don't fully master the code from scrplugin, but as far as I remember,
>> Carsten abstracted the scrplugin engine in the
>> org.apache.felix.scrplugin.SCRDescriptorGenerator.
>> 
>> So I imagine that it could be possible to write a bnd plugin which could
>> reuse this ScrDescriptorGenerator ? Another way could consist in writing a
>> new plugin, based on bndlib "ClassDataCollector" (in this case, it might be
>> better to take the existing ds bndplugin and adapt it to the felix ds
>> annotations).
>> 
>> So, if the ScrDescriptorGenerator could be reused, I then imagine something
>> like:
>> 
>> public class FelixDSAnnotationPlugin implements AnalyzerPlugin {
>>  public boolean analyzeJar(Analyzer analyzer) {
>>         // Reuse the scr generator engine:
>>         SCRDescriptorGenerator generator = new SCRDescriptorGenerator(...)
>>         ...
>> 
>>         // Get result
>>         Result result = generator.execute()
>> 
>>         // And include the generated descriptors in the artifact using
>>         // analyzer.getJar().putResource(...)
>> }
>> 
>> 
>> Hope this helps.
>> /Pierre
>> 
>> [1]
>> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationPlugin.java
>> 
>> 
>> 
>> On Sat, Mar 16, 2013 at 4:39 PM, Felix Meschberger <fmeschbe@adobe.com>wrote:
>> 
>>> Hi
>>> 
>>> How complex would it be to create a bndtools plugin for our annotations ?
>>> 
>>> Regards
>>> Felix
>>> 
>>> -------- Original Message --------
>>> Subject: Re: BndTools and DS 1.2 Annotations
>>> From: Neil Bartlett <njbartlett@gmail.com>
>>> To: bndtools-users@googlegroups.com
>>> CC:
>>> 
>>> 
>>> 
>>> 
>>> Bndtools doesn't support the Felix SCR annotations, and I have no plans to
>>> support them. Frankly I'd like to see at least one of these sets of
>>> annotations die out, as it's confusing having three.
>>> 
>>> To build with the Felix annotations you can use the maven-scr-plugin, or
>>> the ANT task here: http://felix.apache.org/downloads.cgi#ant. Neither are
>>> integrated with the Bndtools incremental builder, so you would need to run
>>> a full build in order to get your XML generated.
>>> 
>>> Regards,
>>> Neil
>>> 
>>> On Sat, Mar 16, 2013 at 7:53 AM, Hsufeng Ko <hsufeng@gmail.com<mailto:
>>> hsufeng@gmail.com>> wrote:
>>> Oh, so there are Bnd annotation, standard annotation, felix annotations,
>>> and they are all different. Thanks for pointing that out to me, Neil.
>>> 
>>> However, I really like to be able to use/apply Felix scr annotations. Is
>>> there a way that I can generate XML Descriptor using Bndtools within
>>> Eclipse? If not, how do people usually go about generating XML Descriptor
>>> from Felix annotations?
>>> 
>>> On Friday, March 15, 2013 9:34:01 PM UTC-7, Neil Bartlett wrote:
>>> You have not use the standard annotations! The clue is in the package
>>> name: "org.apache.felix.scr.annotations" ;-)
>>> 
>>> The *standard* annotations use the package name
>>> "org.osgi.service.component.annotations".
>>> 
>>> Regards,
>>> Neil
>>> 
>>> On Sat, Mar 16, 2013 at 2:28 AM, Hsufeng Ko <hsu...@gmail.com> wrote:
>>> How do I switch to use DS 1.2 Annotations for my Eclipse project using
>>> Bndtools plugin?
>>> 
>>> Using Bndtools in Eclipse, I went to my project's bnd.bnd file and toggle
>>> between 'Bnd Annotations' and 'DS 1.2 Annotations'
>>> 
>>> When I choose to use 'Bnd Annotations', I had my java code annotated as
>>> below,
>>> 
>>> import aQute.bnd.annotation.component.*;
>>> import org.example.api.*;
>>> 
>>> @Component
>>> public class ExampleComponent implements Greeting {
>>> public String sayHello(String name) {
>>> return "Hello " + name;
>>> }
>>> }
>>> 
>>> As a result of the build, the generated bundle jar was built successfully
>>> with OSGI-INF/org.example.ExampleComponent.XML generated and included.
>>> 
>>> However, when I chose to use 'DS 1.2 Annotations' toward my java code
>>> annotated as below (with label=..., description=...),
>>> 
>>> 
>>> package org.example;
>>> 
>>> import org.apache.felix.scr.annotations.Component;
>>> import org.apache.felix.scr.annotations.Properties;
>>> import org.apache.felix.scr.annotations.Property;
>>> import org.apache.felix.scr.annotations.PropertyUnbounded;
>>> import org.apache.felix.scr.annotations.Reference;
>>> import org.apache.felix.scr.annotations.Service;
>>> import org.example.api.*;
>>> 
>>> @Component(label = "label", description="description", metatype=true,
>>> immediate=true)
>>> 
>>> public class ExampleComponent implements Greeting {
>>> public String sayHello(String name) {
>>> return "Hello " + name;
>>> }
>>> }
>>> 
>>> 
>>> I could compile and build but it did not generate
>>> OSGI-INF/org.example.ExampleComponent.XML at all as if the annotation
>>> didn't exist. :(
>>> 
>>> 
>>> I'm new to this and trying to use Bndtools for OSGi development but I
>>> couldn't get the above simple standard DS annotation to work. What step did
>>> I miss? Or Bndtools simply is not for standard DS so it failed silently?
>>> 
>>> On Wednesday, January 23, 2013 12:07:04 AM UTC-8, Neil Bartlett wrote:
>>> I disagree with BJ. The standard DS annotations are more limited than the
>>> bnd ones, for example they have no support for metatype XML generation. For
>>> this reason, Peter and I (and several others) are continuing to use the bnd
>>> annotations, and we do intend to keep them up to date with future changes
>>> in the DS specification.
>>> 
>>> Some people dislike using the bnd annotations for aesthetic reasons,
>>> because they are in the "biz.aQute" namespace, so the "org.osgi" namespace
>>> of the standard annotations is seen as preferable. Personally I don't find
>>> this particularly important, especially as both sets of annotations are
>>> build-time only and do not create runtime dependencies.
>>> 
>>> Neil
>>> 
>>> 
>>> 
>>> 
>>> On Wed, Jan 23, 2013 at 4:43 AM, BJ Hargrave <b...@bjhargrave.com> wrote:
>>> 
>>> 
>>> On Jan 22, 2013, at 22:24 , St Clair Clarke <st.clai...@gmail.com> wrote:
>>> 
>>>> 
>>>> Considering that there should be minimal evolution in bnd annotation,
>>> would you suggest/recommend it to be the more stable form of the two to use?
>>> 
>>> The DS annotations are the best choice as OSGi will update them when the
>>> DS spec is updated. This will of course need a corresponding update in bnd
>>> which processes the annotations.
>>> 
>>> --
>>> 
>>> BJ
>>> 
>>> 
>>> 
>>> 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "bndtools-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to bndtools-user...@googlegroups.com.
>>> 
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>> 
>>> 
>>> 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "bndtools-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to bndtools-users+unsubscribe@googlegroups.com<mailto:
>>> bndtools-users%2Bunsubscribe@googlegroups.com>.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>> 
>>> 
>>> 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "bndtools-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to bndtools-users+unsubscribe@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>> 
>>> 
>>> 
> 
> 
> 
> -- 
> Carsten Ziegeler
> cziegeler@apache.org


--
Felix Meschberger | Principal Scientist | Adobe








Mime
View raw message