You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Robert Munteanu <rm...@adobe.com> on 2012/04/13 14:33:29 UTC

Proposal to make org.apache.felix.scr.annotations available at Runtime

Hi,

I've noticed that the annotations from org.apache.felix.scr.annotations are declared with @Retention(RetentionPolicy.SOURCE) . I think the following use cases would benefit from the annotations being available at runtime .

1. Configuring component instances outside a OSGi container

I often develop components which I want to test in plain JUnit tests rather than in a container. These components have references which I need to satisfy in order for the unit test to run. Since the annotations are available only in the source file, I am unable to  inspect the declared references and inject them in a generic manner.

The alternative is to manually configure each reference, but that gets tedious pretty fast.

2. Processing SCR annotations in a JSR-269 annotation processor

Having the annotations available to the processor ( strictly speaking only RetentionPolicy.CLASS is required ) would allow much simpler integration of SCR processing since the processor would only need to be available as a JAR on the compile classpath, rather than a separate maven plugin invocation or explicit ant task call.

Above the other two use cases, having annotations at runtime can generally ease integration with other systems which can inspect the component configuration at runtime.

The single downside that I see is that the annotations will increase the file size of the deployed bundles ( although I don't think it will be a huge increase ).

I'm willing to prepare a patch, but would like your opinion first.

Thanks,

Robert

Re: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Felix Meschberger <fm...@adobe.com>.
Hi

Am 16.04.2012 um 06:29 schrieb Mark Derricutt:

> +1 for RetentionPolicy.RUNTIME if that change was on the cards ( also 
> upstream OSGi spec change ).

Retention will be CLASS not RUNTIME. And the OSGi spec is not doing RUNTIME, either. Because the OSGi spec is targeted at tooling and not runtime support.

The reason for not using the annotations at runtime is performance: With annotations on class files we have to scan all class files for annotations .. not the best thing to do in terms of performance.

> 
> The other day I was trying to integrate Guice IOC with some of our 
> classes which use @Reference's, if the annotation was runtime I would 
> have been sweet and could have attached them simply into Guice, but alas 
> no :(

Well, the goal and use case of our annotations is support DS descriptor tooling. If you want to use it for GUICE integration you may fail in the future because you depend on something which does not have (and will probably never have) your use case in mind.

Regards
Felix

> 
> 
> 
> 
> On 14/04/12 1:03 AM, Robert Munteanu wrote:
>> Hi Caspar,
>> 
>> Thanks for your reply. I've glanced over http://www.osgi.org/download/osgi-early-draft-2011-09.pdf and noticed that the annotations are defined with @Retention(value=RetentionPolicy.CLASS) .  I've also found that the same will happen with the SCR annotations from Felix in the next release ( https://issues.apache.org/jira/browse/FELIX-3247 ) .
>> 
>> That means that the annotations will not be available at runtime, so I will not be able to configure components by myself in unit tests. I assume that Felix annotations will follow the official ones, so it makes little sense to argue for making them available at runtime.
>> 
>> Robert
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Mark Derricutt <ma...@talios.com>.
+1 for RetentionPolicy.RUNTIME if that change was on the cards ( also 
upstream OSGi spec change ).

The other day I was trying to integrate Guice IOC with some of our 
classes which use @Reference's, if the annotation was runtime I would 
have been sweet and could have attached them simply into Guice, but alas 
no :(




On 14/04/12 1:03 AM, Robert Munteanu wrote:
> Hi Caspar,
>
> Thanks for your reply. I've glanced over http://www.osgi.org/download/osgi-early-draft-2011-09.pdf and noticed that the annotations are defined with @Retention(value=RetentionPolicy.CLASS) .  I've also found that the same will happen with the SCR annotations from Felix in the next release ( https://issues.apache.org/jira/browse/FELIX-3247 ) .
>
> That means that the annotations will not be available at runtime, so I will not be able to configure components by myself in unit tests. I assume that Felix annotations will follow the official ones, so it makes little sense to argue for making them available at runtime.
>
> Robert
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

I hope to work on this stuff (including support for RFC 0172) pretty soon.

Regards
Carsten

2012/4/13 Robert Munteanu <rm...@adobe.com>:
> Hi Caspar,
>
> Thanks for the idea, I did not consider ASM. Since it reads bytecode it will be able to access those annotations and that is confirmed by the docs.
>
> Thanks.
>
> Robert
>
>> -----Original Message-----
>> From: Caspar MacRae [mailto:earcam@gmail.com]
>> Sent: Friday, April 13, 2012 5:32 PM
>> To: users@felix.apache.org
>> Subject: Re: Proposal to make org.apache.felix.scr.annotations
>> available at Runtime
>>
>> Hi Robert,
>>
>> Apologies, I didn't read the spec in detail.  As it's for unit tests
>> you
>> could access the runtime annotations with ASM?
>>
>> cheers,
>> Caspar
>>
>>
>> On 13 April 2012 14:03, Robert Munteanu <rm...@adobe.com> wrote:
>>
>> > Hi Caspar,
>> >
>> > Thanks for your reply. I've glanced over
>> > http://www.osgi.org/download/osgi-early-draft-2011-09.pdf and noticed
>> > that the annotations are defined with
>> > @Retention(value=RetentionPolicy.CLASS) .  I've also found that the
>> same
>> > will happen with the SCR annotations from Felix in the next release (
>> > https://issues.apache.org/jira/browse/FELIX-3247 ) .
>> >
>> > That means that the annotations will not be available at runtime, so
>> I
>> > will not be able to configure components by myself in unit tests. I
>> assume
>> > that Felix annotations will follow the official ones, so it makes
>> little
>> > sense to argue for making them available at runtime.
>> >
>> > Robert
>> >
>> > > -----Original Message-----
>> > > From: Caspar MacRae [mailto:earcam@gmail.com]
>> > > Sent: Friday, April 13, 2012 3:48 PM
>> > > To: users@felix.apache.org
>> > > Subject: Re: Proposal to make org.apache.felix.scr.annotations
>> > > available at Runtime
>> > >
>> > > Hi Robert,
>> > >
>> > > In a broader scope this will happen for RFC 0172 Declarative
>> Services
>> > > Annotations (runtime processing of SCR components), however this
>> brings
>> > > with it standardised annotations.
>> > >
>> > > cheers,
>> > > Caspar
>> > >
>> > >
>> > > On 13 April 2012 13:33, Robert Munteanu <rm...@adobe.com> wrote:
>> > >
>> > > > Hi,
>> > > >
>> > > > I've noticed that the annotations from
>> > > org.apache.felix.scr.annotations
>> > > > are declared with @Retention(RetentionPolicy.SOURCE) . I think
>> the
>> > > > following use cases would benefit from the annotations being
>> > > available at
>> > > > runtime .
>> > > >
>> > > > 1. Configuring component instances outside a OSGi container
>> > > >
>> > > > I often develop components which I want to test in plain JUnit
>> tests
>> > > > rather than in a container. These components have references
>> which I
>> > > need
>> > > > to satisfy in order for the unit test to run. Since the
>> annotations
>> > > are
>> > > > available only in the source file, I am unable to  inspect the
>> > > declared
>> > > > references and inject them in a generic manner.
>> > > >
>> > > > The alternative is to manually configure each reference, but that
>> > > gets
>> > > > tedious pretty fast.
>> > > >
>> > > > 2. Processing SCR annotations in a JSR-269 annotation processor
>> > > >
>> > > > Having the annotations available to the processor ( strictly
>> speaking
>> > > only
>> > > > RetentionPolicy.CLASS is required ) would allow much simpler
>> > > integration of
>> > > > SCR processing since the processor would only need to be
>> available as
>> > > a JAR
>> > > > on the compile classpath, rather than a separate maven plugin
>> > > invocation or
>> > > > explicit ant task call.
>> > > >
>> > > > Above the other two use cases, having annotations at runtime can
>> > > generally
>> > > > ease integration with other systems which can inspect the
>> component
>> > > > configuration at runtime.
>> > > >
>> > > > The single downside that I see is that the annotations will
>> increase
>> > > the
>> > > > file size of the deployed bundles ( although I don't think it
>> will be
>> > > a
>> > > > huge increase ).
>> > > >
>> > > > I'm willing to prepare a patch, but would like your opinion
>> first.
>> > > >
>> > > > Thanks,
>> > > >
>> > > > Robert
>> > > >
>> >



-- 
Carsten Ziegeler
cziegeler@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Robert Munteanu <rm...@adobe.com>.
Hi Caspar,

Thanks for the idea, I did not consider ASM. Since it reads bytecode it will be able to access those annotations and that is confirmed by the docs.

Thanks.

Robert

> -----Original Message-----
> From: Caspar MacRae [mailto:earcam@gmail.com]
> Sent: Friday, April 13, 2012 5:32 PM
> To: users@felix.apache.org
> Subject: Re: Proposal to make org.apache.felix.scr.annotations
> available at Runtime
> 
> Hi Robert,
> 
> Apologies, I didn't read the spec in detail.  As it's for unit tests
> you
> could access the runtime annotations with ASM?
> 
> cheers,
> Caspar
> 
> 
> On 13 April 2012 14:03, Robert Munteanu <rm...@adobe.com> wrote:
> 
> > Hi Caspar,
> >
> > Thanks for your reply. I've glanced over
> > http://www.osgi.org/download/osgi-early-draft-2011-09.pdf and noticed
> > that the annotations are defined with
> > @Retention(value=RetentionPolicy.CLASS) .  I've also found that the
> same
> > will happen with the SCR annotations from Felix in the next release (
> > https://issues.apache.org/jira/browse/FELIX-3247 ) .
> >
> > That means that the annotations will not be available at runtime, so
> I
> > will not be able to configure components by myself in unit tests. I
> assume
> > that Felix annotations will follow the official ones, so it makes
> little
> > sense to argue for making them available at runtime.
> >
> > Robert
> >
> > > -----Original Message-----
> > > From: Caspar MacRae [mailto:earcam@gmail.com]
> > > Sent: Friday, April 13, 2012 3:48 PM
> > > To: users@felix.apache.org
> > > Subject: Re: Proposal to make org.apache.felix.scr.annotations
> > > available at Runtime
> > >
> > > Hi Robert,
> > >
> > > In a broader scope this will happen for RFC 0172 Declarative
> Services
> > > Annotations (runtime processing of SCR components), however this
> brings
> > > with it standardised annotations.
> > >
> > > cheers,
> > > Caspar
> > >
> > >
> > > On 13 April 2012 13:33, Robert Munteanu <rm...@adobe.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > I've noticed that the annotations from
> > > org.apache.felix.scr.annotations
> > > > are declared with @Retention(RetentionPolicy.SOURCE) . I think
> the
> > > > following use cases would benefit from the annotations being
> > > available at
> > > > runtime .
> > > >
> > > > 1. Configuring component instances outside a OSGi container
> > > >
> > > > I often develop components which I want to test in plain JUnit
> tests
> > > > rather than in a container. These components have references
> which I
> > > need
> > > > to satisfy in order for the unit test to run. Since the
> annotations
> > > are
> > > > available only in the source file, I am unable to  inspect the
> > > declared
> > > > references and inject them in a generic manner.
> > > >
> > > > The alternative is to manually configure each reference, but that
> > > gets
> > > > tedious pretty fast.
> > > >
> > > > 2. Processing SCR annotations in a JSR-269 annotation processor
> > > >
> > > > Having the annotations available to the processor ( strictly
> speaking
> > > only
> > > > RetentionPolicy.CLASS is required ) would allow much simpler
> > > integration of
> > > > SCR processing since the processor would only need to be
> available as
> > > a JAR
> > > > on the compile classpath, rather than a separate maven plugin
> > > invocation or
> > > > explicit ant task call.
> > > >
> > > > Above the other two use cases, having annotations at runtime can
> > > generally
> > > > ease integration with other systems which can inspect the
> component
> > > > configuration at runtime.
> > > >
> > > > The single downside that I see is that the annotations will
> increase
> > > the
> > > > file size of the deployed bundles ( although I don't think it
> will be
> > > a
> > > > huge increase ).
> > > >
> > > > I'm willing to prepare a patch, but would like your opinion
> first.
> > > >
> > > > Thanks,
> > > >
> > > > Robert
> > > >
> >

Re: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Caspar MacRae <ea...@gmail.com>.
Hi Robert,

Apologies, I didn't read the spec in detail.  As it's for unit tests you
could access the runtime annotations with ASM?

cheers,
Caspar


On 13 April 2012 14:03, Robert Munteanu <rm...@adobe.com> wrote:

> Hi Caspar,
>
> Thanks for your reply. I've glanced over
> http://www.osgi.org/download/osgi-early-draft-2011-09.pdf and noticed
> that the annotations are defined with
> @Retention(value=RetentionPolicy.CLASS) .  I've also found that the same
> will happen with the SCR annotations from Felix in the next release (
> https://issues.apache.org/jira/browse/FELIX-3247 ) .
>
> That means that the annotations will not be available at runtime, so I
> will not be able to configure components by myself in unit tests. I assume
> that Felix annotations will follow the official ones, so it makes little
> sense to argue for making them available at runtime.
>
> Robert
>
> > -----Original Message-----
> > From: Caspar MacRae [mailto:earcam@gmail.com]
> > Sent: Friday, April 13, 2012 3:48 PM
> > To: users@felix.apache.org
> > Subject: Re: Proposal to make org.apache.felix.scr.annotations
> > available at Runtime
> >
> > Hi Robert,
> >
> > In a broader scope this will happen for RFC 0172 Declarative Services
> > Annotations (runtime processing of SCR components), however this brings
> > with it standardised annotations.
> >
> > cheers,
> > Caspar
> >
> >
> > On 13 April 2012 13:33, Robert Munteanu <rm...@adobe.com> wrote:
> >
> > > Hi,
> > >
> > > I've noticed that the annotations from
> > org.apache.felix.scr.annotations
> > > are declared with @Retention(RetentionPolicy.SOURCE) . I think the
> > > following use cases would benefit from the annotations being
> > available at
> > > runtime .
> > >
> > > 1. Configuring component instances outside a OSGi container
> > >
> > > I often develop components which I want to test in plain JUnit tests
> > > rather than in a container. These components have references which I
> > need
> > > to satisfy in order for the unit test to run. Since the annotations
> > are
> > > available only in the source file, I am unable to  inspect the
> > declared
> > > references and inject them in a generic manner.
> > >
> > > The alternative is to manually configure each reference, but that
> > gets
> > > tedious pretty fast.
> > >
> > > 2. Processing SCR annotations in a JSR-269 annotation processor
> > >
> > > Having the annotations available to the processor ( strictly speaking
> > only
> > > RetentionPolicy.CLASS is required ) would allow much simpler
> > integration of
> > > SCR processing since the processor would only need to be available as
> > a JAR
> > > on the compile classpath, rather than a separate maven plugin
> > invocation or
> > > explicit ant task call.
> > >
> > > Above the other two use cases, having annotations at runtime can
> > generally
> > > ease integration with other systems which can inspect the component
> > > configuration at runtime.
> > >
> > > The single downside that I see is that the annotations will increase
> > the
> > > file size of the deployed bundles ( although I don't think it will be
> > a
> > > huge increase ).
> > >
> > > I'm willing to prepare a patch, but would like your opinion first.
> > >
> > > Thanks,
> > >
> > > Robert
> > >
>

RE: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Robert Munteanu <rm...@adobe.com>.
Hi Caspar,

Thanks for your reply. I've glanced over http://www.osgi.org/download/osgi-early-draft-2011-09.pdf and noticed that the annotations are defined with @Retention(value=RetentionPolicy.CLASS) .  I've also found that the same will happen with the SCR annotations from Felix in the next release ( https://issues.apache.org/jira/browse/FELIX-3247 ) . 

That means that the annotations will not be available at runtime, so I will not be able to configure components by myself in unit tests. I assume that Felix annotations will follow the official ones, so it makes little sense to argue for making them available at runtime.

Robert

> -----Original Message-----
> From: Caspar MacRae [mailto:earcam@gmail.com]
> Sent: Friday, April 13, 2012 3:48 PM
> To: users@felix.apache.org
> Subject: Re: Proposal to make org.apache.felix.scr.annotations
> available at Runtime
> 
> Hi Robert,
> 
> In a broader scope this will happen for RFC 0172 Declarative Services
> Annotations (runtime processing of SCR components), however this brings
> with it standardised annotations.
> 
> cheers,
> Caspar
> 
> 
> On 13 April 2012 13:33, Robert Munteanu <rm...@adobe.com> wrote:
> 
> > Hi,
> >
> > I've noticed that the annotations from
> org.apache.felix.scr.annotations
> > are declared with @Retention(RetentionPolicy.SOURCE) . I think the
> > following use cases would benefit from the annotations being
> available at
> > runtime .
> >
> > 1. Configuring component instances outside a OSGi container
> >
> > I often develop components which I want to test in plain JUnit tests
> > rather than in a container. These components have references which I
> need
> > to satisfy in order for the unit test to run. Since the annotations
> are
> > available only in the source file, I am unable to  inspect the
> declared
> > references and inject them in a generic manner.
> >
> > The alternative is to manually configure each reference, but that
> gets
> > tedious pretty fast.
> >
> > 2. Processing SCR annotations in a JSR-269 annotation processor
> >
> > Having the annotations available to the processor ( strictly speaking
> only
> > RetentionPolicy.CLASS is required ) would allow much simpler
> integration of
> > SCR processing since the processor would only need to be available as
> a JAR
> > on the compile classpath, rather than a separate maven plugin
> invocation or
> > explicit ant task call.
> >
> > Above the other two use cases, having annotations at runtime can
> generally
> > ease integration with other systems which can inspect the component
> > configuration at runtime.
> >
> > The single downside that I see is that the annotations will increase
> the
> > file size of the deployed bundles ( although I don't think it will be
> a
> > huge increase ).
> >
> > I'm willing to prepare a patch, but would like your opinion first.
> >
> > Thanks,
> >
> > Robert
> >

Re: Proposal to make org.apache.felix.scr.annotations available at Runtime

Posted by Caspar MacRae <ea...@gmail.com>.
Hi Robert,

In a broader scope this will happen for RFC 0172 Declarative Services
Annotations (runtime processing of SCR components), however this brings
with it standardised annotations.

cheers,
Caspar


On 13 April 2012 13:33, Robert Munteanu <rm...@adobe.com> wrote:

> Hi,
>
> I've noticed that the annotations from org.apache.felix.scr.annotations
> are declared with @Retention(RetentionPolicy.SOURCE) . I think the
> following use cases would benefit from the annotations being available at
> runtime .
>
> 1. Configuring component instances outside a OSGi container
>
> I often develop components which I want to test in plain JUnit tests
> rather than in a container. These components have references which I need
> to satisfy in order for the unit test to run. Since the annotations are
> available only in the source file, I am unable to  inspect the declared
> references and inject them in a generic manner.
>
> The alternative is to manually configure each reference, but that gets
> tedious pretty fast.
>
> 2. Processing SCR annotations in a JSR-269 annotation processor
>
> Having the annotations available to the processor ( strictly speaking only
> RetentionPolicy.CLASS is required ) would allow much simpler integration of
> SCR processing since the processor would only need to be available as a JAR
> on the compile classpath, rather than a separate maven plugin invocation or
> explicit ant task call.
>
> Above the other two use cases, having annotations at runtime can generally
> ease integration with other systems which can inspect the component
> configuration at runtime.
>
> The single downside that I see is that the annotations will increase the
> file size of the deployed bundles ( although I don't think it will be a
> huge increase ).
>
> I'm willing to prepare a patch, but would like your opinion first.
>
> Thanks,
>
> Robert
>