add java annotation support for sling scr components/servlets
-------------------------------------------------------------

                 Key: SLING-902
                 URL: https://issues.apache.org/jira/browse/SLING-902
             Project: Sling
          Issue Type: New Feature
          Components: Servlets Resolver
            Reporter: Stefan Seifert
         Attachments: 090329_sling_scr_annotations.zip

please note: this proposal depends on a felix-scr-plugin proposal described in
https://issues.apache.org/jira/browse/FELIX-1010

with the described scr plugin enhancement it is possible to define SCR 
component definitions via annotations. furthermore it is possible for felix/SCR 
based projects to define their own and less verbose annotations for specific 
need, together with a provider class mapping them to the SCR tags needed by the 
plugin internally.

the attached zip file provides such a implemented for one new annotation 
"SlingServlet", see example below.

i was not sure into which project and classpath this classes should be placed, 
so i attached a ZIP file for discussion and try-out. the best solution would be 
to split them up into two projects - one project containing only the 
annotation, and the other containing the provider and tag mapping. the first 
project has no dependencies and can be referenced by any other project needing 
the annotation. the second has to import the felix-scr-plugin as dependency, 
this results in a lot of transitive dependency not to be wished in a normal 
project.


Example
-------

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.

Reply via email to