[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12709556#action_12709556 ] Carsten Ziegeler commented on FELIX-1010: - I'Ve added various attributes to the property tag now in 774907 - this isn't tested yet add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** * Sample servlet with sling mappings. */ @SlingServlet(methods = GET, resourceTypes = /apps/test/components/samplecomponent, extensions = { html, json }) public
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12703796#action_12703796 ] Stefan Seifert commented on FELIX-1010: --- i personally would prefer keeping a single @Property tag with multiple value, intValue etc. arrays. one reasing is the @Properties tag - this has one implicit value array of @Property tag. if defining different @Property, @IntProperty etc. tags this is getting really ugly like this: @Properties( values={ @Property(name = prop1, value = value1) }, intValues={ @IntProperty(name = prop2, value = 5) }) instead of @Properties({ @Property(name = prop1, value = value1), @Property(name = prop2, intValue = 5) }) add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET *
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12703304#action_12703304 ] Carsten Ziegeler commented on FELIX-1010: - I would opt for using different annotations: @Property for string values @IntProperty for int values and so on add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** * Sample servlet with sling mappings. */ @SlingServlet(methods = GET, resourceTypes = /apps/test/components/samplecomponent, extensions = {
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12702681#action_12702681 ] Stefan Seifert commented on FELIX-1010: --- the perfact way would be to define the value annotation attribut as Object[]. but this is not allowed, only primitive types and String is allowed for an annotation property. when using plain annotations a workaround like @Property(value=MY_DEFAULT_VALUE+) would work, although ugly and still the property type has to be specified separately. an expression like @Property(value=Integer.toString(MY_DEFAULT_VALUE)) does not work because the compiler rates this as not a constant expression. but event the workaround with MY_DEFAULT_VALUE+ does not work right now, because the property values of the annotation are not read via the java annotation support, which evalutes the expression automatically and returns the computed valued, but with qdox which returns only the plain string including the formula. perhaps a way for interpreting it dynamically can be found, but this still prevents correct type detection from the property's value itself. yes, this is a limitation compared to the qdox style attributes. i've no other ideas yet than to add different primitive typed properties. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = {
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12702682#action_12702682 ] Stefan Seifert commented on FELIX-1010: --- in my tests even using simple String constants did not work, but results in a error in qdox parsing engine. example: @Component @Properties( { @Property(name = ServiceValueRefAnnotations.STRINGPROP_NAME, value = ServiceValueRefAnnotations.STRINGPROP_VALUE), @Property(name = ServiceValueRefAnnotations.MULTIPROP_NAME, value = { ServiceValueRefAnnotations.MULTIPROP_VALUE1, ServiceValueRefAnnotations.MULTIPROP_VALUE2 }) }) public class ServiceValueRefAnnotations { public static final String STRINGPROP_NAME = stringProp; public static final String STRINGPROP_VALUE = theValue; private static final String MULTIPROP_NAME = multiProp; private static final String MULTIPROP_VALUE1 = multiValue1; private static final String MULTIPROP_VALUE2 = multiValue2; } results in: com.thoughtworks.qdox.parser.ParseException: syntax error @[31,5] in scrplugin-testproject/src/main/java/org/testproject/valuerefs/ServiceValueRefAnnotations.java at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:987) at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:1293) at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:968) at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:317) at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:349) at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:345) at com.thoughtworks.qdox.JavaDocBuilder$2.visitFile(JavaDocBuilder.java:435) at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:43) at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:34) at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:34) at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:34) at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:34) at com.thoughtworks.qdox.directorywalker.DirectoryScanner.scan(DirectoryScanner.java:52) at com.thoughtworks.qdox.JavaDocBuilder.addSourceTree(JavaDocBuilder.java:432) at com.thoughtworks.qdox.JavaDocBuilder.addSourceTree(JavaDocBuilder.java:421) at org.apache.felix.scrplugin.tags.JavaClassDescriptorManager.init(JavaClassDescriptorManager.java:155) at org.apache.felix.scrplugin.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:139) it seems that the qdox annotation support is limited or broken here? add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12702686#action_12702686 ] Stefan Seifert commented on FELIX-1010: --- update for last comment: there are strange differences in this area between eclipse compiler and sun jdk javac compiler. if all static fields in the sample above are declared as public, it works. the eclipse compiler accepts private static fields in annotation references as well, but not the sun compiler. beware of any comment marking inside the annotation tags like this: @Properties( { /* this is a property */ @Property(name = ServiceValueRefAnnotations.STRINGPROP_NAME, value = ServiceValueRefAnnotations.STRINGPROP_VALUE) }) this breaks the qdox annotation parser and results in a qdox exception as listed in the comment before. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12702256#action_12702256 ] Carsten Ziegeler commented on FELIX-1010: - I've enhanced the annotation support so that any string attribute can point to a constant defined somewhere (e.g. @Property(name=Constants.MY_PROPERTY) This also works for values but I think we are hitting a limit of annotations here now compared to the javadoc tags. With the javadoc tags one could do: int MY_DEFAULT_VALUE = 5; /** @scr.property valueRef=MY_DEFAULT_VALUE */ with annotations this should look like: @Property(value=MY_DEFAULT_VALUE) but it doesn't work as annotation attributes need to have a specific type, a String in our case. The javadoc tags implementation not just uses the value of the constant but also the type to define the property, so you end up with an integer property. I have no clue how to do this with annotations. The only thing comming to my mind is to use different attributes, like value for string intValue for int etc. But this seems very ugly to me. Any ideas? add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, 090423_property_sorted_map.patch, FELIX-1010.patch, scrplugin_annot_090422.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy =
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12699606#action_12699606 ] Carsten Ziegeler commented on FELIX-1010: - Thanks for your patch Felix; I've applied a slightly modifed version (mainly the default for the metatype) I'll rename the annotations module later today. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, FELIX-1010.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** * Sample servlet with sling mappings. */ @SlingServlet(methods = GET, resourceTypes = /apps/test/components/samplecomponent, extensions = { html, json }) public
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12699188#action_12699188 ] Carsten Ziegeler commented on FELIX-1010: - Ok, I've followed the qdox source parsing route and now we have the basic stuff working; I've just tested @Component, @Service and some uses of @Reference. They seem to work; it would be nice if people could do further testing so we find the remaining problems quicker. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** * Sample servlet with sling mappings. */ @SlingServlet(methods =
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12699242#action_12699242 ] Carsten Ziegeler commented on FELIX-1010: - Re artifactId: yes, I was thinking about this as well but didn't had a good idea :) I guess org.apache.felix.scr.annotations is good enough; Not sure if people would search for the annotations in scr itself; these annotations are not tied to our scr implementation, therefore I guess they should be a standalone module. Re default for metatype at @Component; the orignal patch from Stefan had it in line with the @scr.component tag which means it defaults to true. I changed this to false, as I think false should be the default value and we did it wrong for the javadoc tags. I think we can live with this inconsistency. (I'm not completly against changing it to true either) But I completly agree to the other changes :) Thanks for the patch! add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, FELIX-1010.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12699339#action_12699339 ] Felix Meschberger commented on FELIX-1010: -- Re integrate with scr: agreed, it is probably not the best thing to do (at least we discussed it), so lets keep it separate Re artifactId: org.apache.felix.scr.annotations, 3-2-1-sold ;-) Re metatype default: I agree, that in retrospect, the default of metatype=true is probably wrong. I have some problems with inconsistencies ... but given good documentation on that matter, we probably can live with it add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch, FELIX-1010.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12698706#action_12698706 ] Carsten Ziegeler commented on FELIX-1010: - Thanks David (J.) for the new reference :) Yes, xbeans finder looks much better, I'll give it a try. We've been wondering what will happen to the UrlSet code that lists all the class files in a jar in an osgi environment. I'm not an expert in this one, but I think David (B.) is right that wrapping the Bundle.findEntries or maybe getResources is the way to go. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet {
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12697069#action_12697069 ] David Jencks commented on FELIX-1010: - the xbean-reflect library might make reading the annotations very easy. (it uses asm under the covers) It's used in (at least) openejb and geronimo for this. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** * Sample servlet with sling mappings. */ @SlingServlet(methods = GET, resourceTypes = /apps/test/components/samplecomponent, extensions = { html, json }) public class
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12696419#action_12696419 ] Carsten Ziegeler commented on FELIX-1010: - to make the annotations really useful in IDE's like eclipse you need this project as a maven dependency in any way to be included when generating the eclipse project files, and to get inline documentation of the annotations. the dependency type could be set to provided, so its not included in the dependency chain. so, even if we find a way of providing the dependency only in the plugin's classpath, the IDE support will suffer. Yepp, you're right of course - and I don't think that adding the dependency to the project is really a problem; it's just a difference compared to the javadoc stuff. yes, i ran into this already. using reflection for reading annotations form generated classfiles requires to set the policy to RUNTIME. there is no other way with the code implemented in the way currently. policy SOURCE is really only useful for IDEs an other tools, who are parsing the source files by themselves. after submitting the patch i thought if the qdox library can be used for exactly this job - parsing the source files and read the java annotations (not the doclet tags). but it seems the qdox library does not support this, and i've not checked if there are other libraries helping reading SOURCE level annotations from source files. I think RUNTIME as the retention policy is nearly a killer for this; I briefly looked at the QDox javadocs and they mention annotations. I'll have a look at it later. - The valueRef and nameRef attributes for properties are currently not supported. This is a very nice feature which allows to reference an existing I dropped the support for them by design, because as far as i unterstood the syntax, they helped only referencing an existing java constant instead of a hard-coded value. but with java annotations, you can use this already with the value and name properties, and you do not need them any more as separate properties. or did i miss something that cannot be expressed with the new annotations in the current implementation? Ah ok, so how do I reference a constant? (I'm new to annotations...) i recommend maintaining the information concerning the qdox annotations and the java annotations on the same page, because my intention was to name all properties the same way (where possible), to keep the docs+usage in synch easily. i've not figured out yet where the documentation of the felix subprojects are maintained or patches can be applied to (is it a wiki?) Yes, it's a wiki (http://cwiki.apache.org/confluence/display/FELIX) but only Felix committers have write access :) If you send a patch with plain text I can easily add it to the page. Thanks! add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12696595#action_12696595 ] Carsten Ziegeler commented on FELIX-1010: - Thanks for the info and your second patch which I applied. In revision 762830 I've started using qdox to get the annotations. Well, it is possible, but the qdox annotations have to be converted manually into real annotations. Which requires to recode all default values. I think we can live with such an approach as annotations usually don't change. I've only converted the component tag so far. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch, 090406_component_patch.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12696210#action_12696210 ] Carsten Ziegeler commented on FELIX-1010: - Metatype information should not be generated by default - this has actually been an error in the javadocs where metatype is true per default. We can't change it for the javadocs parsing, but we can define new defaults for the annotations stuff. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** * Sample servlet with sling mappings. */ @SlingServlet(methods = GET, resourceTypes =
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12696229#action_12696229 ] Carsten Ziegeler commented on FELIX-1010: - I've played a little bit with the annotation stuff and came across the following problems: - The maven project using the annotations requires the scrplugin-annotation module (containing the annotations) as a compile dependency; maybe we can find a way of adding this dependency by the scr plugin to the classpath - The retention policy for the annotations needs to be RUNTIME, otherwise the scr plugin does not get the annotations as the vm loads the classes but does not retain the annotations. RUNTIME requires to have the annotations available at runtime as well, so although they are not used anymore we would need to make a bundle out of the annotations - The valueRef and nameRef attributes for properties are currently not supported. This is a very nice feature which allows to reference an existing Constant for a value or name. Apart from these problems, the ide support is nice :) add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12696240#action_12696240 ] Stefan Seifert commented on FELIX-1010: --- thanks for applying reviewing so far! - The maven project using the annotations requires the scrplugin-annotation module (containing the annotations) as a compile dependency; maybe we can find a way of adding this dependency by the scr plugin to the classpath to make the annotations really useful in IDE's like eclipse you need this project as a maven dependency in any way to be included when generating the eclipse project files, and to get inline documentation of the annotations. the dependency type could be set to provided, so its not included in the dependency chain. so, even if we find a way of providing the dependency only in the plugin's classpath, the IDE support will suffer. - The retention policy for the annotations needs to be RUNTIME, otherwise the scr plugin does not get the annotations as the vm loads the classes but does not retain the annotations. RUNTIME requires to have the annotations available at runtime as well, so although they are not used anymore we would need to make a bundle out of the annotations yes, i ran into this already. using reflection for reading annotations form generated classfiles requires to set the policy to RUNTIME. there is no other way with the code implemented in the way currently. policy SOURCE is really only useful for IDEs an other tools, who are parsing the source files by themselves. after submitting the patch i thought if the qdox library can be used for exactly this job - parsing the source files and read the java annotations (not the doclet tags). but it seems the qdox library does not support this, and i've not checked if there are other libraries helping reading SOURCE level annotations from source files. - The valueRef and nameRef attributes for properties are currently not supported. This is a very nice feature which allows to reference an existing Constant for a value or name. Apart from these problems, the ide support is nice :) if dropped the support for them by design, because as far as i unterstood the syntax, they helped only referencing an existing java constant instead of a hard-coded value. but with java annotations, you can use this already with the value and name properties, and you do not need them any more as separate properties. or did i miss something that cannot be expressed with the new annotations in the current implementation? - adding missing documentation (hint :) ) i recommend maintaining the information concerning the qdox annotations and the java annotations on the same page, because my intention was to name all properties the same way (where possible), to keep the docs+usage in synch easily. i've not figured out yet where the documentation of the felix subprojects are maintained or patches can be applied to (is it a wiki?) add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Fix For: maven-scr-plugin-1.0.11 Attachments: 090329_felix_scrplugin_annotationsupport.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12694188#action_12694188 ] Carsten Ziegeler commented on FELIX-1010: - Hi Stefan, thanks for this great patch - I've looked at it and it looks great to me; I've just applied it - slightly modified (changed the version to 0.9.0 as the annotations are independent from the maven plugin) and changed the retention policy to source as we don't want to have the annotations in the compiled classes. I've also moved most of the source code of the scr plugin to java 1.5; I think maven 2.1+ requires Java 1.5 to run maven anyway, so I don't think that this is a problem. If uses have a problem with this, we can create a branch anyway. I'll leave this bug open for: - adding missing documentation (hint :) ) - get a feeling for the new annotations add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Attachments: 090329_felix_scrplugin_annotationsupport.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property
[jira] Commented: (FELIX-1010) add java annotation support to felix-scr-plugin
[ https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12693673#action_12693673 ] Stefan Seifert commented on FELIX-1010: --- i forgot to mention one issue: the annotation support requires the plugin itself to run with JDK 1.5 or above (only the plugin, not necessarily the projects code it works upon, if annotations are not used). up to now, the plugin was JDK 1.3 compatible. not sure how to solve this. perhaps by keeping a branch of the old version, and raising the JDK requirement to JDK 1.5 from the next released SCR plugin version. add java annotation support to felix-scr-plugin --- Key: FELIX-1010 URL: https://issues.apache.org/jira/browse/FELIX-1010 Project: Felix Issue Type: New Feature Components: Maven SCR Plugin Affects Versions: maven-scr-plugin-1.0.10 Reporter: Stefan Seifert Assignee: Carsten Ziegeler Attachments: 090329_felix_scrplugin_annotationsupport.patch goals of this proposal: - allow definition of SCR components with java annotations instead of QDox tags - advantages: strong typing, auto-completion and jump to source documentation in modern IDEs - support built-in annotations with 1:1 matching the old scr.* tags, and allow definition of custom annotations for other felix/scr-based projects to minimalize syntax overhead - the QDox tags are still supported, but cannot be mixed with annotations whithing the same source file attached to this ticket is a full implemented and tested patch, that supports all feates supported by the scr.* QDox tags today. some of the more exotic features are not tested in detail, only the generated descriptors where compared. i created a new project scrplugin-annotations, that contains only the annotations for easy referencing without unwanted transitive dependencies. i'm not sure if the package and artifact name are well chosen. Example 1 - QDox version: /** * Service class with QDox annotations. * * @scr.component * @scr.property name=testProperty value=testValue * @scr.service */ public class MinimalServiceQDox implements { ... Annotation version: /** * Service class with java annotations. */ @Component @Property(name = testProperty, value = testValue) @Service public class MinimalServiceAnnotations { ... Example 2 - QDox version: /** * Service class with QDox annotations. * * @scr.component name=QDoxName label=theLabel description=theDescription *immediate=false enabled=false factory=xx.yy.zz * @scr.service interface=org.osgi.service.component.ComponentInstance * servicefactory=true * @scr.service interface=java.lang.Readable * @scr.property name=stringProp value=theValue label=thePropLabel * description=thePropDesc options 0=option0 1=option1 * 2=option2 * @scr.property name=intProp value=5 type=Integer * @scr.property name=multiProp values.0=multiValue1 values.1=multiValue2 */ public class ServiceQDox implements ComponentInstance, Readable { /** * @scr.reference cardinality=0..1, dynamic=true */ MinimalServiceQDox reference; ... Annotation version: /** * Service class with java annotations. */ @Component(name = AnnotName, label = theLabel, description = theDescription, immediate = false, enabled = false, factory = xx.yy.zz) @Services( { @Service(value = ComponentInstance.class, serviceFactory = true), @Service(Readable.class) }) @Properties( { @Property(name = stringProp, value = theValue, label = thePropLabel, description = thePropDesc, options = { @PropertyOption(name = 0, value = option0), @PropertyOption(name = 1, value = option1), @PropertyOption(name = 2, value = option2) }), @Property(name = intProp, value = 5, type = Integer.class), @Property(name = multiProp, value = { multiValue1, multiValue2 }) }) public class ServiceAnnotations implements ComponentInstance, Readable { @Reference(cardinality = ReferenceCardinality.ZERO_TO_ONE, policy = ReferencePolicy.DYNAMIC) MinimalServiceAnnotations reference; ... Example 3 - using Custom Annotation from other project -- QDox version: /** * Sample servlet with sling mappings. * * @scr.component immediate=true * @scr.service interface=javax.servlet.Servlet * @scr.property name=sling.servlet.methods value=GET * @scr.property name=sling.servlet.resourceTypes * value=/apps/test/components/samplecomponent * @scr.property name=sling.servlet.extensions values.0=html values.1=json */ public class SlingServletQDox implements Servlet { Annotation version: /** *