[
https://issues.apache.org/jira/browse/FELIX-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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" 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 SlingServletAnnotation implements Servlet {
> Custom annotation mappings can be integrated by defining a class implementing
> "org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider" for the
> new plugin property "annotationTagProviders" in the pom.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.