You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2014/01/16 12:10:19 UTC
[jira] [Commented] (FELIX-4392) make @Property use
RetentionPolicy.RUNTIME so that code can use runtime field/setter injecting
property values
[ https://issues.apache.org/jira/browse/FELIX-4392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13873272#comment-13873272 ]
Carsten Ziegeler commented on FELIX-4392:
-----------------------------------------
This was done on purpose - number one reason being spec compliant, secondly not requiring any bundle providing the annotations at runtime.
With RFC 190, the spec will get a much nicer way of configuring the component, as this spec will be released this year, it makes more sense to focus on implementing/supporting the spec than inventing a proprietary way.
> make @Property use RetentionPolicy.RUNTIME so that code can use runtime field/setter injecting property values
> --------------------------------------------------------------------------------------------------------------
>
> Key: FELIX-4392
> URL: https://issues.apache.org/jira/browse/FELIX-4392
> Project: Felix
> Issue Type: Improvement
> Components: SCR Annotations
> Reporter: james strachan
>
> It'd be nice to be able to write a base class for a @Component with an @Activate method taking the Map<String,Object> of configurations and performing field or setter injection of configurations via @Property - but the annotation is not retained at runtime right now due to CLASS not RUNTIME RetentionPolicy on @Property.
> Any idea why not? Was this on purpose or just an oversight?
> e.g. it'd be nice to be able to code components like this (and get the SCR and MetaType metadata auto-generated)
> {code}
> public abstract class MyAbstractComponent {
> @Activate
> public void activate(Map<String, ?> configuration) throws Exception {
> // use introspection to find the fields and setters with @Property annotated...
> }
> }
> ...
> @Component(name = "foo")
> public FooComponent extends MyAbstractComponent {
> @Property
> private int foo;
> @Property
> private String bar;
> ....
> {code}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)