FELIX-3550 : Reimplement the SCR Generator
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1349769 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/annotations/NOTICE b/scrplugin/annotations/NOTICE
index cf782a9..d342d0e 100644
--- a/scrplugin/annotations/NOTICE
+++ b/scrplugin/annotations/NOTICE
@@ -1,5 +1,5 @@
Apache Felix SCR Annotations
-Copyright 2007-2011 The Apache Software Foundation
+Copyright 2007-2012 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
diff --git a/scrplugin/annotations/pom.xml b/scrplugin/annotations/pom.xml
index b9a16e0..c6b4ed8 100644
--- a/scrplugin/annotations/pom.xml
+++ b/scrplugin/annotations/pom.xml
@@ -29,7 +29,7 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
- <version>1.6.1-SNAPSHOT</version>
+ <version>1.7.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Annotations for SCR</name>
@@ -47,7 +47,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.generator</artifactId>
- <version>1.1.2</version>
+ <version>1.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java b/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
index 20035fd..32bc929 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
@@ -18,7 +18,10 @@
*/
package org.apache.felix.scr.annotations;
-import java.lang.annotation.*;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* The <code>Component</code> annotation is the only required annotation. If
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/PropertyOption.java b/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/PropertyOption.java
index ff3397a..eba8dbd 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/PropertyOption.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/PropertyOption.java
@@ -18,12 +18,15 @@
*/
package org.apache.felix.scr.annotations;
-import java.lang.annotation.*;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* Defines a {@link Property} option.
*/
-@Property(options=@PropertyOption(name="you",value="something"))
@Target(ElementType.ANNOTATION_TYPE)
@Retention(RetentionPolicy.CLASS)
@Documented
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java
new file mode 100644
index 0000000..4cf9678
--- /dev/null
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java
@@ -0,0 +1,438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.AutoDetect;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Modified;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.felix.scr.annotations.Services;
+import org.apache.felix.scrplugin.description.ClassDescription;
+import org.apache.felix.scrplugin.description.ComponentConfigurationPolicy;
+import org.apache.felix.scrplugin.description.ComponentDescription;
+import org.apache.felix.scrplugin.description.MethodDescription;
+import org.apache.felix.scrplugin.description.PropertyDescription;
+import org.apache.felix.scrplugin.description.PropertyType;
+import org.apache.felix.scrplugin.description.PropertyUnbounded;
+import org.apache.felix.scrplugin.description.ReferenceCardinality;
+import org.apache.felix.scrplugin.description.ReferenceDescription;
+import org.apache.felix.scrplugin.description.ReferencePolicy;
+import org.apache.felix.scrplugin.description.ReferenceStrategy;
+import org.apache.felix.scrplugin.description.ServiceDescription;
+import org.apache.felix.scrplugin.description.SpecVersion;
+import org.apache.felix.scrplugin.scanner.ClassAnnotation;
+import org.apache.felix.scrplugin.scanner.FieldAnnotation;
+import org.apache.felix.scrplugin.scanner.MethodAnnotation;
+import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
+import org.apache.felix.scrplugin.scanner.ScannedClass;
+
+/**
+ * This is the processor for the Apache Felix SCR annotations.
+ */
+public class SCRAnnotationProcessor implements AnnotationProcessor {
+
+ /**
+ * @throws SCRDescriptorException
+ * @throws SCRDescriptorFailureException
+ * @see org.apache.felix.scrplugin.AnnotationProcessor#process(ScannedClass, ClassDescription)
+ */
+ public void process(final ScannedClass scannedClass, final ClassDescription describedClass)
+ throws SCRDescriptorFailureException, SCRDescriptorException {
+
+ final List<ClassAnnotation> componentTags = scannedClass.getClassAnnotations(Component.class.getName());
+ scannedClass.processed(componentTags);
+
+ for (final ClassAnnotation cad : componentTags) {
+ describedClass.add(createComponent(cad, scannedClass));
+ }
+
+ // search for the component descriptions and use the first one
+ final List<ComponentDescription> componentDescs = describedClass.getDescriptions(ComponentDescription.class);
+ ComponentDescription found = null;
+ if (!componentDescs.isEmpty()) {
+ found = componentDescs.get(0);
+ }
+
+ if (found != null) {
+ final ComponentDescription cd = found;
+
+ // search for methods
+ final List<MethodAnnotation> methodTags = scannedClass.getMethodAnnotations(null);
+ for (final MethodAnnotation m : methodTags) {
+ if (m.getName().equals(Activate.class.getName())) {
+ cd.setActivate(new MethodDescription(m.getAnnotatedMethod()));
+ scannedClass.processed(m);
+ } else if (m.getName().equals(Deactivate.class.getName())) {
+ cd.setDeactivate(new MethodDescription(m.getAnnotatedMethod()));
+ scannedClass.processed(m);
+ } else if (m.getName().equals(Modified.class.getName())) {
+ cd.setModified(new MethodDescription(m.getAnnotatedMethod()));
+ scannedClass.processed(m);
+ }
+ }
+
+ }
+
+ // service tags
+ final List<ClassAnnotation> allServiceTags = new ArrayList<ClassAnnotation>();
+ final List<ClassAnnotation> serviceTags = scannedClass.getClassAnnotations(Service.class.getName());
+ if (serviceTags.size() > 0) {
+ scannedClass.processed(serviceTags);
+ allServiceTags.addAll(serviceTags);
+ }
+ // services tags - class level
+ final List<ClassAnnotation> servicesTags = scannedClass.getClassAnnotations(Services.class.getName());
+ if (servicesTags.size() > 0) {
+ scannedClass.processed(servicesTags);
+ for (final ClassAnnotation cad : servicesTags) {
+ final ClassAnnotation[] values = (ClassAnnotation[]) cad.getValue("value");
+ if (values != null) {
+ allServiceTags.addAll(Arrays.asList(values));
+ }
+ }
+ }
+ if (allServiceTags.size() > 0) {
+ describedClass.add(createService(allServiceTags, scannedClass));
+ }
+
+ // reference - class level
+ final List<ClassAnnotation> refClassTags = scannedClass.getClassAnnotations(Reference.class.getName());
+ scannedClass.processed(refClassTags);
+ createReferences(refClassTags, describedClass);
+
+ // reference - field level
+ final List<FieldAnnotation> refFieldTags = scannedClass.getFieldAnnotations(Reference.class.getName());
+ scannedClass.processed(refFieldTags);
+ createReferences(refFieldTags, describedClass);
+
+ // properties - class level
+ final List<ClassAnnotation> propsClassTags = scannedClass.getClassAnnotations(Properties.class.getName());
+ scannedClass.processed(propsClassTags);
+ for (final ClassAnnotation cad : propsClassTags) {
+ final ClassAnnotation[] values = (ClassAnnotation[]) cad.getValue("value");
+ if (values != null) {
+ createProperties(Arrays.asList(values), describedClass);
+ }
+ }
+
+ // property - class level
+ final List<ClassAnnotation> propClassTags = scannedClass.getClassAnnotations(Property.class.getName());
+ scannedClass.processed(propClassTags);
+ createProperties(propClassTags, describedClass);
+
+ // property - field level
+ final List<FieldAnnotation> propFieldTags = scannedClass.getFieldAnnotations(Property.class.getName());
+ scannedClass.processed(propFieldTags);
+ createProperties(propFieldTags, describedClass);
+ }
+
+ /**
+ * @see org.apache.felix.scrplugin.AnnotationProcessor#getRanking()
+ */
+ public int getRanking() {
+ return 1000;
+ }
+
+ /**
+ * Create a component description.
+ *
+ * @param cad
+ * The component annotation for the class.
+ * @param scannedClass
+ * The scanned class.
+ */
+ private ComponentDescription createComponent(final ClassAnnotation cad, final ScannedClass scannedClass) {
+ final ComponentDescription component = new ComponentDescription(cad);
+
+ final boolean classIsAbstract = Modifier.isAbstract(scannedClass.getClass().getModifiers());
+ component.setAbstract(cad.getBooleanValue("componentAbstract", classIsAbstract));
+
+ component.setCreatePid(cad.getBooleanValue("createPid", true));
+
+ component.setName(cad.getStringValue("name", scannedClass.getScannedClass().getName()));
+
+ component.setLabel(cad.getStringValue("label", null));
+ component.setDescription(cad.getStringValue("description", null));
+
+ component.setCreateDs(cad.getBooleanValue("ds", true));
+
+ component.setCreateMetatype(cad.getBooleanValue("metatype", false));
+
+ if (cad.getValue("enabled") != null) {
+ component.setEnabled(cad.getBooleanValue("enabled", true));
+ }
+ if (cad.getValue("specVersion") != null) {
+ component.setSpecVersion(SpecVersion.fromName(cad.getValue("specVersion").toString()));
+ }
+ component.setFactory(cad.getStringValue("factory", null));
+ // FELIX-593: immediate attribute does not default to true all the
+ // times hence we only set it if declared in the tag
+ if (cad.getValue("immediate") != null) {
+ component.setEnabled(cad.getBooleanValue("immediate", false));
+ }
+ component.setInherit(cad.getBooleanValue("inherit", true));
+ component.setConfigurationPolicy(ComponentConfigurationPolicy.valueOf(cad.getEnumValue("policy",
+ ComponentConfigurationPolicy.OPTIONAL.name())));
+ component.setSetMetatypeFactoryPid(cad.getBooleanValue("configurationFactory", false));
+
+ return component;
+ }
+
+ /**
+ * Create a service description
+ *
+ * @param descs
+ * The service annotations.
+ * @param scannedClass
+ * The scanned class
+ */
+ private ServiceDescription createService(final List<ClassAnnotation> descs, final ScannedClass scannedClass) {
+ final ServiceDescription service = new ServiceDescription(descs.get(0));
+
+ final List<String> listedInterfaces = new ArrayList<String>();
+ for (final ClassAnnotation d : descs) {
+ if (d.getBooleanValue("serviceFactory", false)) {
+ service.setServiceFactory(true);
+ }
+ if (d.getValue("value") != null) {
+ final String[] interfaces = (String[]) d.getValue("value");
+ for (String t : interfaces) {
+ listedInterfaces.add(t);
+ }
+ }
+ }
+
+ if (listedInterfaces.size() > 0 && !listedInterfaces.contains(AutoDetect.class.getName())) {
+ for (final String i : listedInterfaces) {
+ service.addInterface(i);
+ }
+ } else {
+ // auto detection
+ addInterfaces(service, scannedClass.getScannedClass());
+ }
+
+ return service;
+ }
+
+ /**
+ * Recursively add interfaces to the service.
+ */
+ private void addInterfaces(final ServiceDescription service, final Class<?> javaClass) {
+ if (javaClass != null) {
+ final Class<?>[] interfaces = javaClass.getInterfaces();
+ for (final Class<?> i : interfaces) {
+ service.addInterface(i.getName());
+ // recursivly add interfaces implemented by this interface
+ this.addInterfaces(service, i);
+ }
+
+ // try super class
+ this.addInterfaces(service, javaClass.getSuperclass());
+ }
+ }
+
+ /**
+ * Create a method description if a name is provided.
+ *
+ * @param methodName
+ * The name of the method or <code>null</code>
+ * @return A method description if the name is not null.
+ */
+ private MethodDescription getMethodDescription(final String methodName) {
+ if (methodName != null) {
+ return new MethodDescription(methodName);
+ }
+ return null;
+ }
+
+ /**
+ * Create reference descriptions
+ *
+ * @param descs
+ * List of reference annotations.s
+ * @param describedClass
+ * The described class.
+ */
+ private void createReferences(final List<? extends ScannedAnnotation> descs, final ClassDescription describedClass) {
+ for (final ScannedAnnotation ad : descs) {
+ final ReferenceDescription ref = new ReferenceDescription(ad);
+
+ // check for field annotation
+ final FieldAnnotation fieldAnnotation;
+ if (ad instanceof FieldAnnotation) {
+ fieldAnnotation = (FieldAnnotation) ad;
+ ref.setField(fieldAnnotation.getAnnotatedField());
+ } else {
+ fieldAnnotation = null;
+ }
+
+ ref.setName(ad.getStringValue("name",
+ (fieldAnnotation != null ? fieldAnnotation.getAnnotatedField().getName() : null)));
+ ref.setInterfaceName(ad.getStringValue("referenceInterface", (fieldAnnotation != null ? fieldAnnotation
+ .getAnnotatedField().getType().getName() : null)));
+ ref.setTarget(ad.getStringValue("target", null));
+ ref.setCardinality(ReferenceCardinality.valueOf(ad.getEnumValue("cardinality",
+ ReferenceCardinality.MANDATORY_UNARY.name())));
+ ref.setPolicy(ReferencePolicy.valueOf(ad.getEnumValue("policy", ReferencePolicy.STATIC.name())));
+ ref.setStrategy(ReferenceStrategy.valueOf(ad.getEnumValue("strategy", ReferenceStrategy.EVENT.name())));
+
+ ref.setBind(getMethodDescription(ad.getStringValue("bind", null)));
+ ref.setUnbind(getMethodDescription(ad.getStringValue("unbind", null)));
+ ref.setUpdated(getMethodDescription(ad.getStringValue("updated", null)));
+
+ describedClass.add(ref);
+ }
+ }
+
+ private static final String[] PROPERTY_VALUE_PROCESSING = new String[] { "String", "value", "String", "classValue", "Long",
+ "longValue", "Double", "doubleValue", "Float", "floatValue", "Integer", "intValue", "Byte", "byteValue", "Char",
+ "charValue", "Boolean", "boolValue", "Short", "shortValue" };
+
+ /**
+ * Create properties descriptions
+ *
+ * @throws SCRDescriptorException
+ * @throws SCRDescriptorFailureException
+ */
+ private void createProperties(final List<? extends ScannedAnnotation> descs, final ClassDescription describedClass)
+ throws SCRDescriptorFailureException, SCRDescriptorException {
+ for (final ScannedAnnotation ad : descs) {
+ final PropertyDescription prop = new PropertyDescription(ad);
+
+ // check for field annotation
+ final FieldAnnotation fieldAnnotation;
+ if (ad instanceof FieldAnnotation) {
+ fieldAnnotation = (FieldAnnotation) ad;
+ } else {
+ fieldAnnotation = null;
+ }
+
+ // Detect values from annotation
+ String type = null;
+ String[] values = null;
+ int index = 0;
+ while (type == null && index < PROPERTY_VALUE_PROCESSING.length) {
+ final String propType = PROPERTY_VALUE_PROCESSING[index];
+ final String propName = PROPERTY_VALUE_PROCESSING[index + 1];
+ final Object propValue = ad.getValue(propName);
+ if (propValue != null && propValue.getClass().isArray()) {
+ type = propType;
+ values = new String[Array.getLength(propValue)];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = Array.get(propValue, i).toString();
+ }
+ }
+ index += 2;
+ }
+
+ if (values != null) {
+ prop.setType(PropertyType.valueOf(type));
+ if (values.length == 1) {
+ prop.setValue(values[0]);
+ } else {
+ prop.setMultiValue(values);
+ }
+ } else if (fieldAnnotation != null) {
+
+ // Detect values from field
+ final Object value = fieldAnnotation.getAnnotatedFieldValue();
+ if (value != null) {
+ if (value.getClass().isArray()) {
+ values = new String[Array.getLength(value)];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = Array.get(value, i).toString();
+ }
+ prop.setMultiValue(values);
+ prop.setType(PropertyType.from(Array.get(value, 0).getClass()));
+ } else {
+ prop.setType(PropertyType.from(value.getClass()));
+ prop.setValue(value.toString());
+ }
+ }
+ }
+
+ final String defaultName;
+ if (fieldAnnotation != null) {
+ if (values == null) {
+ defaultName = fieldAnnotation.getAnnotatedField().getName();
+ } else {
+ final Object value = fieldAnnotation.getAnnotatedFieldValue();
+ if (value != null) {
+ defaultName = value.toString();
+ } else {
+ defaultName = null;
+ }
+ }
+ } else {
+ defaultName = null;
+ }
+ prop.setName(ad.getStringValue("name", defaultName));
+ prop.setLabel(ad.getStringValue("label", null));
+ prop.setDescription(ad.getStringValue("description", null));
+
+ // check type
+ if ( prop.getType() == null ) {
+ prop.setType(PropertyType.String);
+ }
+
+ // private
+ if ( ad.getValue("propertyPrivate") != null ) {
+ prop.setPrivate(ad.getBooleanValue("propertyPrivate", false));
+ }
+
+ // cardinality handling
+ final PropertyUnbounded pu = PropertyUnbounded
+ .valueOf(ad.getEnumValue("unbounded", PropertyUnbounded.DEFAULT.name()));
+ prop.setUnbounded(pu);
+
+ if (pu == PropertyUnbounded.DEFAULT) {
+ prop.setCardinality(ad.getIntegerValue("cardinality", 0));
+ if (prop.getMultiValue() != null && prop.getCardinality() == 0) {
+ prop.setUnbounded(PropertyUnbounded.ARRAY);
+ }
+ } else {
+ prop.setCardinality(0);
+ }
+
+ // options
+ final ClassAnnotation[] options = (ClassAnnotation[])ad.getValue("options");
+ if (options != null) {
+ final List<String> propertyOptions = new ArrayList<String>();
+ for(final ClassAnnotation po : options) {
+ propertyOptions.add(po.getStringValue("name", ""));
+ propertyOptions.add(po.getStringValue("value", ""));
+ }
+ prop.setOptions(propertyOptions.toArray(new String[propertyOptions.size()]));
+ }
+
+ describedClass.add(prop);
+ }
+ }
+}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java
new file mode 100644
index 0000000..19c08af
--- /dev/null
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin;
+
+import java.util.List;
+
+import org.apache.felix.scr.annotations.sling.SlingFilter;
+import org.apache.felix.scr.annotations.sling.SlingFilterScope;
+import org.apache.felix.scr.annotations.sling.SlingServlet;
+import org.apache.felix.scrplugin.description.ClassDescription;
+import org.apache.felix.scrplugin.description.ComponentConfigurationPolicy;
+import org.apache.felix.scrplugin.description.ComponentDescription;
+import org.apache.felix.scrplugin.description.PropertyDescription;
+import org.apache.felix.scrplugin.description.PropertyType;
+import org.apache.felix.scrplugin.description.ServiceDescription;
+import org.apache.felix.scrplugin.scanner.ClassAnnotation;
+import org.apache.felix.scrplugin.scanner.ScannedClass;
+
+/**
+ * This is the processor for the Apache Felix Sling annotations.
+ */
+public class SlingAnnotationProcessor implements AnnotationProcessor {
+
+ /**
+ * @see org.apache.felix.scrplugin.AnnotationProcessor#process(ScannedClass, ClassDescription)
+ */
+ public void process(final ScannedClass scannedClass,
+ final ClassDescription describedClass)
+ throws SCRDescriptorFailureException, SCRDescriptorException {
+
+ final List<ClassAnnotation> servlets = scannedClass.getClassAnnotations(SlingServlet.class.getName());
+ scannedClass.processed(servlets);
+
+ for(final ClassAnnotation cad : servlets) {
+ processSlingServlet(cad, describedClass);
+ }
+
+ final List<ClassAnnotation> filters = scannedClass.getClassAnnotations(SlingFilter.class.getName());
+ scannedClass.processed(filters);
+
+ for(final ClassAnnotation cad : filters) {
+ processSlingFilter(cad, describedClass);
+ }
+
+ }
+
+ /**
+ * @see org.apache.felix.scrplugin.AnnotationProcessor#getRanking()
+ */
+ public int getRanking() {
+ return 500;
+ }
+
+ /**
+ * Process SlingServlet
+ */
+ private void processSlingServlet(final ClassAnnotation cad, final ClassDescription classDescription) {
+ // generate ComponentDescription if required
+ final boolean generateComponent = cad.getBooleanValue("generateComponent", true);
+ if (generateComponent) {
+ final ComponentDescription cd = new ComponentDescription(cad);
+ cd.setName(cad.getStringValue("name", classDescription.getDescribedClass().getName()));
+ cd.setConfigurationPolicy(ComponentConfigurationPolicy.OPTIONAL);
+
+ cd.setLabel(cad.getStringValue("label", null));
+ cd.setDescription(cad.getStringValue("description", null));
+
+ cd.setCreateMetatype(cad.getBooleanValue("metatype", false));
+
+ classDescription.add(cd);
+ }
+
+ // generate ServiceDescription if required
+ final boolean generateService = cad.getBooleanValue("generateService", true);
+ if (generateService) {
+ final ServiceDescription sd = new ServiceDescription(cad);
+ sd.addInterface("javax.servlet.Servlet");
+ classDescription.add(sd);
+ }
+
+ // generate PropertyDescriptions
+ // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_PATHS}
+ final String[] paths = (String[])cad.getValue("paths");
+ if ( paths != null ) {
+ final PropertyDescription pd = new PropertyDescription(cad);
+ pd.setName("sling.servlet.paths");
+ pd.setMultiValue(paths);
+ pd.setType(PropertyType.String);
+ pd.setPrivate(true);
+ classDescription.add(pd);
+ }
+
+ // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES}
+ final String[] resourceTypes = (String[])cad.getValue("resourceTypes");
+ if ( resourceTypes != null ) {
+ final PropertyDescription pd = new PropertyDescription(cad);
+ pd.setName("sling.servlet.resourceTypes");
+ pd.setMultiValue(resourceTypes);
+ pd.setType(PropertyType.String);
+ pd.setPrivate(true);
+ classDescription.add(pd);
+ }
+
+ // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_SELECTORS}
+ final String[] selectors = (String[])cad.getValue("selectors");
+ if (selectors != null ) {
+ final PropertyDescription pd = new PropertyDescription(cad);
+ pd.setName("sling.servlet.selectors");
+ pd.setMultiValue(selectors);
+ pd.setType(PropertyType.String);
+ pd.setPrivate(true);
+ classDescription.add(pd);
+ }
+
+ // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_EXTENSIONS}
+ final String[] extensions = (String[])cad.getValue("extensions");
+ if (extensions != null ) {
+ final PropertyDescription pd = new PropertyDescription(cad);
+ pd.setName("sling.servlet.extensions");
+ pd.setMultiValue(extensions);
+ pd.setType(PropertyType.String);
+ pd.setPrivate(true);
+ classDescription.add(pd);
+ }
+
+ // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_METHODS}
+ final String[] methods = (String[])cad.getValue("methods");
+ if (methods != null ) {
+ final PropertyDescription pd = new PropertyDescription(cad);
+ pd.setName("sling.servlet.methods");
+ pd.setMultiValue(methods);
+ pd.setType(PropertyType.String);
+ pd.setPrivate(true);
+ classDescription.add(pd);
+ }
+ }
+
+ /**
+ * Process SlingFilter
+ */
+ private void processSlingFilter(final ClassAnnotation cad, final ClassDescription classDescription) {
+ // generate ComponentDescription if required
+ final boolean generateComponent = cad.getBooleanValue("generateComponent", true);
+ if (generateComponent) {
+ final ComponentDescription cd = new ComponentDescription(cad);
+ cd.setName(cad.getStringValue("name", classDescription.getDescribedClass().getName()));
+ cd.setConfigurationPolicy(ComponentConfigurationPolicy.OPTIONAL);
+
+ cd.setLabel(cad.getStringValue("label", null));
+ cd.setDescription(cad.getStringValue("description", null));
+
+ cd.setCreateMetatype(cad.getBooleanValue("metatype", false));
+
+ classDescription.add(cd);
+ }
+
+ // generate ServiceDescription if required
+ final boolean generateService = cad.getBooleanValue("generateService", true);
+ if (generateService) {
+ final ServiceDescription sd = new ServiceDescription(cad);
+ sd.addInterface("javax.servlet.Filter");
+ classDescription.add(sd);
+ }
+
+ // generate PropertyDescriptions
+ // property order = service.ranking
+ final int order = cad.getIntegerValue("order", 0);
+ final PropertyDescription pd = new PropertyDescription(cad);
+ pd.setName("service.ranking");
+ pd.setValue(String.valueOf(order));
+ pd.setType(PropertyType.Integer);
+ pd.setPrivate(true);
+ classDescription.add(pd);
+
+ // property scope
+ final String scope = cad.getEnumValue("scope", SlingFilterScope.REQUEST.getScope());
+ final PropertyDescription pd2 = new PropertyDescription(cad);
+ pd2.setName("sling.filter.scope");
+ pd2.setValue(scope);
+ pd2.setType(PropertyType.String);
+ pd.setPrivate(true);
+ classDescription.add(pd2);
+ }
+}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
deleted file mode 100644
index 669e45a..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.scr.annotations.*;
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AbstractTag;
-import org.apache.felix.scrplugin.tags.annotation.Util;
-
-import com.thoughtworks.qdox.model.Annotation;
-import com.thoughtworks.qdox.model.JavaMethod;
-
-/**
- * Description of a java tag for components.
- */
-public class ComponentTag extends AbstractTag {
-
- protected final Component annotation;
-
- /**
- * @param annotation Annotation
- * @param desc Description
- */
- public ComponentTag(final Annotation annotation, final JavaClassDescription desc) {
- super(annotation, desc, null);
- this.annotation = new Component() {
-
- public boolean componentAbstract() {
- final String[] sValues = Util.getAnnotationValues(annotation, "componentAbstract", desc);
- if ( sValues != null )
- {
- return Boolean.valueOf(sValues[0]);
- }
- return desc.isAbstract();
- }
-
- public boolean createPid() {
- return Util.getBooleanValue(annotation, desc, "createPid", Component.class);
- }
-
- public String description() {
- return Util.getStringValue(annotation, desc, "description", Component.class);
- }
-
- public boolean ds() {
- return Util.getBooleanValue(annotation, desc, "ds", Component.class);
- }
-
- public String specVersion() {
- return Util.getStringValue( annotation, desc, "specVersion", Component.class );
- }
-
- public boolean enabled() {
- return Util.getBooleanValue(annotation, desc, "enabled", Component.class);
- }
-
- public String factory() {
- return Util.getStringValue(annotation, desc, "factory", Component.class);
- }
-
- public boolean immediate() {
- return Util.getBooleanValue(annotation, desc, "immediate", Component.class);
- }
-
- public boolean inherit() {
- return Util.getBooleanValue(annotation, desc, "inherit", Component.class);
- }
-
- public String label() {
- return Util.getStringValue(annotation, desc, "label", Component.class);
- }
-
- public boolean metatype() {
- return Util.getBooleanValue(annotation, desc, "metatype", Component.class);
- }
-
- public String name() {
- return Util.getStringValue(annotation, desc, "name", Component.class);
- }
-
- public ConfigurationPolicy policy() {
- return Util.getEnumValue(annotation, "policy", ConfigurationPolicy.class, Component.class, false);
- }
-
- public boolean getConfigurationFactory() {
- return Util.getBooleanValue(annotation, desc, "getConfigurationFactory", Component.class);
- }
-
- public boolean configurationFactory() {
- final Object obj = annotation.getNamedParameter("configurationFactory");
- if ( obj != null ) {
- return Boolean.valueOf(obj.toString());
- }
- return getConfigurationFactory();
- }
-
- public Class<? extends java.lang.annotation.Annotation> annotationType() {
- return null;
- }
- };
- }
-
- @Override
- public String getName() {
- return Constants.COMPONENT;
- }
-
- @Override
- public String getSourceName() {
- return "Component";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final Map<String, String> map = new HashMap<String, String>();
-
- map.put(Constants.COMPONENT_NAME, emptyToNull(this.annotation.name()));
- map.put(Constants.COMPONENT_LABEL, emptyToNull(this.annotation.label()));
- map.put(Constants.COMPONENT_DESCRIPTION, emptyToNull(this.annotation.description()));
- map.put(Constants.COMPONENT_ENABLED, String.valueOf(this.annotation.enabled()));
- map.put(Constants.COMPONENT_FACTORY, emptyToNull(this.annotation.factory()));
- map.put(Constants.COMPONENT_SET_METATYPE_FACTORY_PID, String.valueOf(this.annotation.configurationFactory()));
-
- // FELIX-593: immediate attribute does not default to true all the
- // times hence we only set it if declared in the tag
- if ( this.sourceAnnotation.getNamedParameter("immediate") != null) {
- map.put(Constants.COMPONENT_IMMEDIATE, this.sourceAnnotation.getNamedParameter("immediate").toString());
- }
- map.put(Constants.COMPONENT_INHERIT, String.valueOf(this.annotation.inherit()));
- map.put(Constants.COMPONENT_METATYPE, String.valueOf(this.annotation.metatype()));
- map.put(Constants.COMPONENT_ABSTRACT, String.valueOf(this.annotation.componentAbstract()));
- map.put(Constants.COMPONENT_DS, String.valueOf(this.annotation.ds()));
- map.put(Constants.COMPONENT_DS_SPEC_VERSION, String.valueOf(this.annotation.specVersion()));
- map.put(Constants.COMPONENT_CREATE_PID, String.valueOf(this.annotation.createPid()));
-
- // version 1.1
- if ( this.annotation.policy() != null ) {
- map.put(Constants.COMPONENT_CONFIG_POLICY, this.annotation.policy().getPolicyString());
- }
- final JavaMethod[] jms = this.sourceAnnotation.getContext().getParent().getParentSource().getClasses()[0].getMethods();
- for(final JavaMethod jm : jms) {
- final Annotation[] annotations = jm.getAnnotations();
- for(final Annotation a : annotations) {
- if ( a.getType().getJavaClass().getFullyQualifiedName().equals(Activate.class.getName()) ) {
- map.put(Constants.COMPONENT_ACTIVATE, jm.getName());
- }
- if ( a.getType().getJavaClass().getFullyQualifiedName().equals(Deactivate.class.getName()) ) {
- map.put(Constants.COMPONENT_DEACTIVATE, jm.getName());
- }
- if ( a.getType().getJavaClass().getFullyQualifiedName().equals(Modified.class.getName()) ) {
- map.put(Constants.COMPONENT_MODIFIED, jm.getName());
- }
- }
- }
-
- return map;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
deleted file mode 100644
index 0bd7ad1..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.scr.annotations.*;
-import org.apache.felix.scrplugin.tags.JavaField;
-import org.apache.felix.scrplugin.tags.JavaTag;
-import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Provides mapping of default SCR annotations to tag implementations.
- */
-public class DefaultAnnotationTagProvider implements AnnotationTagProvider {
-
- /**
- * @see org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider#getTags(Annotation, org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription, org.apache.felix.scrplugin.tags.JavaField)
- */
- public List<JavaTag> getTags(Annotation annotation,
- AnnotationJavaClassDescription description, JavaField field) {
- List<JavaTag> tags = new ArrayList<JavaTag>();
-
- // check for single annotations
- if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Component.class.getName())) {
- tags.add(new ComponentTag(annotation, description));
- } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Property.class.getName())) {
- tags.add(new PropertyTag(annotation, description, field));
- } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Service.class.getName())) {
- tags.addAll(ServiceTag.createServiceTags(annotation, description));
- } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Reference.class.getName())) {
- tags.add(new ReferenceTag(annotation, description, field));
- }
-
- // check for multi-annotations
- else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Properties.class.getName())) {
- @SuppressWarnings("unchecked")
- final List<Annotation> properties = (List<Annotation>)annotation.getNamedParameter("value");
- for (Annotation property : properties) {
- tags.add(new PropertyTag(property, description, field));
- }
- } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Services.class.getName())) {
- @SuppressWarnings("unchecked")
- final List<Annotation> services = (List<Annotation>)annotation.getNamedParameter("value");
- for (Annotation service : services) {
- tags.addAll(ServiceTag.createServiceTags(service, description));
- }
- } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(References.class.getName())) {
- @SuppressWarnings("unchecked")
- final List<Annotation> references = (List<Annotation>)annotation.getNamedParameter("value");
- for (Annotation reference : references) {
- tags.add(new ReferenceTag(reference, description, field));
- }
- }
-
- return tags;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
deleted file mode 100644
index 5b71f01..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-
-import java.util.*;
-
-import org.apache.felix.scr.annotations.*;
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.JavaField;
-import org.apache.felix.scrplugin.tags.annotation.*;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class PropertyTag extends AbstractTag {
-
- protected final Property annotation;
-
- /**
- * @param annotation Annotation
- * @param desc Description
- */
- public PropertyTag(final Annotation annotation, final AnnotationJavaClassDescription desc, JavaField field) {
- super(annotation, desc, field);
- this.annotation = new Property() {
-
- public int cardinality() {
- return Util.getIntValue(annotation, desc, "cardinality", Property.class);
- }
-
- public String description() {
- return Util.getStringValue(annotation, desc, "description", Property.class);
- }
-
- public String label() {
- return Util.getStringValue(annotation, desc, "label", Property.class);
- }
-
- public String name() {
- return Util.getStringValue(annotation, desc, "name", Property.class);
- }
-
- public PropertyOption[] options() {
- final Object obj = annotation.getNamedParameter("options");
- if ( obj != null ) {
- if ( obj instanceof Annotation ) {
- final Annotation annotation = (Annotation)obj;
- return new PropertyOption[] {new PropertyOptionImpl(annotation, desc)};
- }
- @SuppressWarnings("unchecked")
- final List<Annotation> annotations = (List<Annotation>) obj;
- PropertyOption[] options = new PropertyOption[annotations.size()];
- for (int index = 0; index < options.length; index++) {
- final Annotation propAnnotation = annotations.get(index);
- options[index] = new PropertyOptionImpl(propAnnotation, desc);
- }
- return options;
- }
- try {
- return (PropertyOption[]) Property.class.getMethod("options").getDefaultValue();
- } catch( NoSuchMethodException mnfe) {
- // we ignore this
- return null;
- }
- }
-
- public boolean propertyPrivate() {
- return Util.getBooleanValue(annotation, desc, "propertyPrivate", Property.class);
- }
-
- public String[] value() {
- // value property can be used as String[] or String property
- return Util.getStringValues(annotation, desc, "value");
- }
-
- public Class<?>[] classValue() {
- return Util.getClassArrayValue(annotation, "classValue", Property.class, desc.getClassLoader());
- }
-
- public boolean[] boolValue() {
- return Util.getBooleanValues(annotation, desc, "boolValue");
- }
-
- public byte[] byteValue() {
- return Util.getByteValues(annotation, desc, "byteValue");
- }
-
- public char[] charValue() {
- return Util.getCharValues(annotation, desc, "charValue");
- }
-
- public double[] doubleValue() {
- return Util.getDoubleValues(annotation, desc, "doubleValue");
- }
-
- public float[] floatValue() {
- return Util.getFloatValues(annotation, desc, "floatValue");
- }
-
- public int[] intValue() {
- return Util.getIntValues(annotation, desc, "intValue");
- }
-
- public long[] longValue() {
- return Util.getLongValues(annotation, desc, "longValue");
- }
-
- public short[] shortValue() {
- return Util.getShortValues(annotation, desc, "shortValue");
- }
-
- public PropertyUnbounded unbounded() {
- return Util.getEnumValue(annotation, "unbounded", PropertyUnbounded.class, Property.class);
- }
-
- public Class<? extends java.lang.annotation.Annotation> annotationType() {
- return null;
- }
- };
- }
-
- @Override
- public String getName() {
- return Constants.PROPERTY;
- }
-
- @Override
- public String getSourceName() {
- return "Property";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final Map<String, String> map = new LinkedHashMap<String, String>();
-
- map.put(Constants.PROPERTY_NAME, emptyToNull(this.annotation.name()));
- map.put(Constants.PROPERTY_LABEL, emptyToNull(this.annotation.label()));
- map.put(Constants.PROPERTY_DESCRIPTION, emptyToNull(this.annotation.description()));
-
-
- String type = null;
- Object[] values = this.annotation.value();
- // we now check all options
- if (values == null || values.length == 0 ) {
- final Class<?>[] classValues = this.annotation.classValue();
- if ( classValues == null || classValues.length == 0 ) {
- long[] lValues = this.annotation.longValue();
- if ( lValues == null || lValues.length == 0 ) {
- double[] dValues = this.annotation.doubleValue();
- if ( dValues == null || dValues.length == 0 ) {
- float[] fValues = this.annotation.floatValue();
- if ( fValues == null || fValues.length == 0 ) {
- int[] iValues = this.annotation.intValue();
- if ( iValues == null || iValues.length == 0 ) {
- byte[] byteValues = this.annotation.byteValue();
- if ( byteValues == null || byteValues.length == 0 ) {
- char[] cValues = this.annotation.charValue();
- if ( cValues == null || cValues.length == 0 ) {
- boolean[] boolValues = this.annotation.boolValue();
- if ( boolValues == null || boolValues.length == 0 ) {
- short[] sValues = this.annotation.shortValue();
- if ( sValues != null && sValues.length != 0 ) {
- values = new Object[sValues.length];
- for(int i=0;i<sValues.length;i++) {
- values[i] = sValues[i];
- }
- type = "Short";
- }
- } else {
- values = new Object[boolValues.length];
- for(int i=0;i<boolValues.length;i++) {
- values[i] = boolValues[i];
- }
- type = "Boolean";
- }
- } else {
- values = new Object[cValues.length];
- for(int i=0;i<cValues.length;i++) {
- values[i] = cValues[i];
- }
- type = "Char";
- }
- } else {
- values = new Object[byteValues.length];
- for(int i=0;i<byteValues.length;i++) {
- values[i] = byteValues[i];
- }
- type = "Byte";
- }
- } else {
- values = new Object[iValues.length];
- for(int i=0;i<iValues.length;i++) {
- values[i] = iValues[i];
- }
- type = "Integer";
- }
- } else {
- values = new Object[fValues.length];
- for(int i=0;i<fValues.length;i++) {
- values[i] = fValues[i];
- }
- type = "Float";
- }
- } else {
- values = new Object[dValues.length];
- for(int i=0;i<dValues.length;i++) {
- values[i] = dValues[i];
- }
- type = "Double";
- }
- } else {
- values = new Object[lValues.length];
- for(int i=0;i<lValues.length;i++) {
- values[i] = lValues[i];
- }
- type = "Long";
- }
- } else {
- values = new Object[classValues.length];
- for(int i=0;i<classValues.length;i++) {
- values[i] = classValues[i].getName();
- }
- type = "String";
- }
- } else {
- type = "String";
- }
-
- if ( values != null && values.length > 0 ) {
- map.put(Constants.PROPERTY_TYPE, type);
- if (values.length == 1) {
- map.put(Constants.PROPERTY_VALUE, values[0].toString());
- } else {
- for (int i = 0; i < values.length; i++) {
- map.put(Constants.PROPERTY_MULTIVALUE_PREFIX + '.' + i, values[i].toString());
- }
- }
- }
-
- // cardinality handling
- final PropertyUnbounded pu = this.annotation.unbounded();
- if ( pu != PropertyUnbounded.DEFAULT ) {
- if ( pu == PropertyUnbounded.ARRAY ) {
- map.put(Constants.PROPERTY_CARDINALITY, "+");
- } else {
- map.put(Constants.PROPERTY_CARDINALITY, "-");
- }
- } else if (this.annotation.cardinality() != 0) {
- if ( this.annotation.cardinality() == Integer.MAX_VALUE ) {
- map.put(Constants.PROPERTY_CARDINALITY, "+");
- } else if ( this.annotation.cardinality() == Integer.MIN_VALUE ) {
- map.put(Constants.PROPERTY_CARDINALITY, "-");
- } else {
- map.put(Constants.PROPERTY_CARDINALITY, String.valueOf(this.annotation.cardinality()));
- }
- }
-
- map.put(Constants.PROPERTY_PRIVATE, String.valueOf(this.annotation.propertyPrivate()));
-
- return map;
- }
-
- @Override
- public String[] getParameters() {
- List<String> parameters = new ArrayList<String>();
-
- String[] defaultParameters = super.getParameters();
- if (defaultParameters != null) {
- parameters.addAll(Arrays.asList(defaultParameters));
- }
-
- // if defined: add options as parameters to the end of parameter list
- // (strange parsing due to qdox tag restrictions...)
- if (this.annotation.options().length > 0) {
- parameters.add(Constants.PROPERTY_OPTIONS);
- for (PropertyOption option : this.annotation.options()) {
- parameters.add(option.name());
- parameters.add("=");
- parameters.add(option.value());
- }
- }
-
- return parameters.toArray(new String[parameters.size()]);
- }
-
- protected static class PropertyOptionImpl implements PropertyOption {
-
- private final Annotation annotation;
- private final JavaClassDescription description;
-
- public PropertyOptionImpl(final Annotation annotation,
- final JavaClassDescription desc) {
- this.annotation = annotation;
- this.description = desc;
- }
-
- public String name() {
- final String[] names = Util.getAnnotationValues(annotation, "name", description);
- if ( names != null && names.length > 0 ) {
- return names[0];
- }
- return null;
- }
-
- public String value() {
- final String[] values = Util.getAnnotationValues(annotation, "value", description);
- if ( values != null && values.length > 0 ) {
- return values[0];
- }
- return null;
- }
-
- public Class<? extends java.lang.annotation.Annotation> annotationType() {
- return PropertyOption.class;
- }
- }
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
deleted file mode 100644
index 8319692..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.scr.annotations.*;
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaField;
-import org.apache.felix.scrplugin.tags.annotation.*;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class ReferenceTag extends AbstractTag {
-
- protected final Reference annotation;
-
- /**
- * @param annotation Annotation
- * @param desc Description
- */
- public ReferenceTag(final Annotation annotation, final AnnotationJavaClassDescription desc, JavaField field) {
- super(annotation, desc, field);
-
- this.annotation = new Reference() {
-
- public String bind() {
- return Util.getStringValue(annotation, desc, "bind", Reference.class);
- }
-
- public ReferenceCardinality cardinality() {
- return Util.getEnumValue(annotation, "cardinality", ReferenceCardinality.class, Reference.class);
- }
-
- public String name() {
- return Util.getStringValue(annotation, desc, "name", Reference.class);
- }
-
- public ReferencePolicy policy() {
- return Util.getEnumValue(annotation, "policy", ReferencePolicy.class, Reference.class);
- }
-
- public Class<?> referenceInterface() {
- return Util.getClassValue(annotation, "referenceInterface", Reference.class, desc.getClassLoader());
- }
-
- public ReferenceStrategy strategy() {
- return Util.getEnumValue(annotation, "strategy", ReferenceStrategy.class, Reference.class);
- }
-
- public String target() {
- return Util.getStringValue(annotation, desc, "target", Reference.class);
- }
-
- public String unbind() {
- return Util.getStringValue(annotation, desc, "unbind", Reference.class);
- }
-
- public String updated() {
- return Util.getStringValue(annotation, desc, "updated", Reference.class);
- }
-
- public Class<? extends java.lang.annotation.Annotation> annotationType() {
- return null;
- }
- };
- }
-
- @Override
- public String getName() {
- return Constants.REFERENCE;
- }
-
- @Override
- public String getSourceName() {
- return "Reference";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final Map<String, String> map = new HashMap<String, String>();
-
- map.put(Constants.REFERENCE_NAME, emptyToNull(this.annotation.name()));
-
- if (this.annotation.referenceInterface() != AutoDetect.class) {
- String referenceInterface = this.annotation.referenceInterface().getName();
- map.put(Constants.REFERENCE_INTERFACE, referenceInterface);
- }
-
- map.put(Constants.REFERENCE_CARDINALITY, this.annotation.cardinality().getCardinalityString());
- map.put(Constants.REFERENCE_POLICY, this.annotation.policy().getPolicyString());
- map.put(Constants.REFERENCE_TARGET, emptyToNull(this.annotation.target()));
- map.put(Constants.REFERENCE_BIND, emptyToNull(this.annotation.bind()));
- map.put(Constants.REFERENCE_UNDBIND, emptyToNull(this.annotation.unbind()));
- map.put(Constants.REFERENCE_UPDATED, emptyToNull(this.annotation.updated()));
- map.put(Constants.REFERENCE_STRATEGY, this.annotation.strategy().getStrategyString());
-
- return map;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
deleted file mode 100644
index 5f84215..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-
-import java.util.*;
-
-import org.apache.felix.scr.annotations.AutoDetect;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.annotation.*;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class ServiceTag extends AbstractTag {
-
- protected final Service annotation;
-
- protected final String serviceInterface;
-
- /**
- * @param annotation Annotation
- * @param desc Description
- */
- public ServiceTag(final Annotation annotation,
- final AnnotationJavaClassDescription desc,
- final Service tag,
- final String serviceInterface) {
- super(annotation, desc, null);
- this.annotation = tag;
- this.serviceInterface = serviceInterface;
- }
-
- @Override
- public String getName() {
- return Constants.SERVICE;
- }
-
- @Override
- public String getSourceName() {
- return "Service";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final Map<String, String> map = new HashMap<String, String>();
-
- map.put(Constants.SERVICE_INTERFACE, this.serviceInterface);
- map.put(Constants.SERVICE_FACTORY, String.valueOf(this.annotation.serviceFactory()));
-
- return map;
- }
-
- public static List<ServiceTag> createServiceTags(final Annotation annotation, final AnnotationJavaClassDescription desc) {
- final Service tag = new Service() {
-
- public boolean serviceFactory() {
- return Util.getBooleanValue(annotation, desc, "serviceFactory", Service.class);
- }
-
- public Class<?>[] value() {
- return Util.getClassArrayValue(annotation, "value", Service.class, desc.getClassLoader());
- }
-
- public Class<? extends java.lang.annotation.Annotation> annotationType() {
- return null;
- }
- };
- final Class<?>[] classes = tag.value();
- if ( classes != null && classes.length > 0
- && (classes.length != 1 || !classes[0].getName().equals(AutoDetect.class.getName()))) {
- final List<ServiceTag> tags = new ArrayList<ServiceTag>();
- for(final Class<?> c : classes ) {
- tags.add(new ServiceTag(annotation, desc, tag, c.getName()));
- }
- return tags;
- }
- return Collections.singletonList(new ServiceTag(annotation, desc, tag, null));
- }
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
deleted file mode 100644
index 67c4673..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * SCR plugin annotation tag provider default implementation for annotations provided in package
- * <code>org.apache.felix.scrplugin.annotations</code>.
- */
-package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
deleted file mode 100644
index 13d616c..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.sling;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.scr.annotations.sling.SlingFilter;
-import org.apache.felix.scr.annotations.sling.SlingServlet;
-import org.apache.felix.scrplugin.tags.JavaField;
-import org.apache.felix.scrplugin.tags.JavaTag;
-import org.apache.felix.scrplugin.tags.annotation.*;
-
-/**
- * Annotation tag provider for sling-specific SCR annotations.
- */
-public class SlingAnnotationTagProvider implements AnnotationTagProvider {
-
- /**
- * @see org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider#getTags(com.thoughtworks.qdox.model.Annotation, org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription, org.apache.felix.scrplugin.tags.JavaField)
- */
- public List<JavaTag> getTags(final com.thoughtworks.qdox.model.Annotation annotation,
- final AnnotationJavaClassDescription description,
- final JavaField field)
- {
- final String annotationName = annotation.getType().getJavaClass().getFullyQualifiedName();
- final List<JavaTag> tags = new ArrayList<JavaTag>();
-
- // SlingServlet annotation
- if (annotationName.equals(SlingServlet.class.getName()))
- {
-
- // generate @Component tag if required
- boolean generateComponent = Util.getBooleanValue(annotation, description, "generateComponent", SlingServlet.class);
- if (generateComponent)
- {
- String name = Util.getStringValue(annotation, description, "name", SlingServlet.class);
- if ( name != null && name.trim().length() == 0 ) {
- name = null;
- }
- String label = Util.getStringValue(annotation, description, "label", SlingServlet.class);
- if ( label != null && label.trim().length() == 0 ) {
- label = null;
- }
- String desc = Util.getStringValue(annotation, description, "description", SlingServlet.class);
- if ( desc != null && desc.trim().length() == 0 ) {
- desc = null;
- }
- final boolean createMetatype = Util.getBooleanValue(annotation, description, "metatype", SlingServlet.class);
- tags.add(new SlingServletComponentTag(annotation, description, createMetatype, name, label, desc));
- }
-
- // generate @Service tag if required
- boolean generateService = Util.getBooleanValue(annotation, description, "generateService", SlingServlet.class);
- if (generateService)
- {
- tags.add(new SlingServletServiceTag(annotation, description));
- }
-
- // generate @Property tags
- // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_PATHS}
- String[] paths = Util.getStringValues(annotation, description, "paths");
- if (paths != null && paths.length != 0)
- {
- tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.paths", paths, description));
- }
-
- // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES}
- String[] resourceTypes = Util.getStringValues(annotation, description, "resourceTypes");
- if (resourceTypes != null && resourceTypes.length != 0)
- {
- tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.resourceTypes", resourceTypes, description));
- }
-
- // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_SELECTORS}
- String[] selectors = Util.getStringValues(annotation, description, "selectors");
- if (selectors != null && selectors.length != 0)
- {
- tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.selectors", selectors, description));
- }
-
- // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_EXTENSIONS}
- String[] extensions = Util.getStringValues(annotation, description, "extensions");
- if (extensions != null && extensions.length != 0)
- {
- tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.extensions", extensions, description));
- }
-
- // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_METHODS}
- String[] methods = Util.getStringValues(annotation, description, "methods");
- if (methods != null && methods.length != 0)
- {
- tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.methods", methods, description));
- }
-
- }
- // Filter annotation
- else if ( annotationName.equals(SlingFilter.class.getName()) )
- {
- // generate @Component tag if required
- boolean generateComponent = Util.getBooleanValue(annotation, description, "generateComponent", SlingFilter.class);
- if (generateComponent)
- {
- String name = Util.getStringValue(annotation, description, "name", SlingFilter.class);
- if ( name != null && name.trim().length() == 0 ) {
- name = null;
- }
- String label = Util.getStringValue(annotation, description, "label", SlingFilter.class);
- if ( label != null && label.trim().length() == 0 ) {
- label = null;
- }
- String desc = Util.getStringValue(annotation, description, "description", SlingFilter.class);
- if ( desc != null && desc.trim().length() == 0 ) {
- desc = null;
- }
- final boolean createMetatype = Util.getBooleanValue(annotation, description, "metatype", SlingFilter.class);
- tags.add(new SlingFilterComponentTag(annotation, description, createMetatype, name, label, desc));
- }
-
- // generate @Service tag if required
- boolean generateService = Util.getBooleanValue(annotation, description, "generateService", SlingFilter.class);
- if (generateService)
- {
- tags.add(new SlingFilterServiceTag(annotation, description));
- }
-
- // property order = service.ranking
- final int order = Util.getIntValue(annotation, description, "order", SlingFilter.class);
- tags.add(new SlingServletPropertyTag(annotation, "service.ranking", String.valueOf(order), description, "Integer", true));
-
- // property scope
- final String[] scopes = Util.getAnnotationValues(annotation, "scope", description);
- tags.add(new SlingServletPropertyTag(annotation, "sling.filter.scope", scopes, description, true));
- }
-
- return tags;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
deleted file mode 100644
index f9b0638..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.sling;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AbstractTag;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class SlingFilterComponentTag extends AbstractTag {
-
- private final boolean createMetatype;
- private final String name;
- private final String label;
- private final String description;
-
- /**
- * @param desc Description
- */
- public SlingFilterComponentTag(final Annotation annotation,
- final JavaClassDescription desc,
- final boolean createMetatype,
- final String name,
- final String label,
- final String description) {
- super(annotation, desc, null);
- this.createMetatype = createMetatype;
- this.name = name;
- this.label = label;
- this.description = description;
- }
-
- @Override
- public String getName() {
- return Constants.COMPONENT;
- }
-
- @Override
- public String getSourceName() {
- return "SlingFilter";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final Map<String, String> params = new HashMap<String, String>();
- if ( this.name != null ) {
- params.put(Constants.COMPONENT_NAME, this.name);
- }
- if ( this.label != null ) {
- params.put(Constants.COMPONENT_LABEL, this.label);
- }
- if ( this.description != null ) {
- params.put(Constants.COMPONENT_DESCRIPTION, this.description);
- }
- params.put(Constants.COMPONENT_METATYPE, String.valueOf(this.createMetatype));
- return params;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
deleted file mode 100644
index 8991482..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.sling;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AbstractTag;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class SlingFilterServiceTag extends AbstractTag {
-
- private static final Map<String, String> INTERFACE_MAP =
- Collections.singletonMap(Constants.SERVICE_INTERFACE, "javax.servlet.Filter");
-
- /**
- * @param desc Description
- */
- public SlingFilterServiceTag(Annotation annotation, JavaClassDescription desc) {
- super(annotation, desc, null);
- }
-
- @Override
- public String getName() {
- return Constants.SERVICE;
- }
-
- @Override
- public String getSourceName() {
- return "SlingFilter";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- return INTERFACE_MAP;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
deleted file mode 100644
index 5fa4ae1..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.sling;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AbstractTag;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class SlingServletComponentTag extends AbstractTag {
-
- private final boolean createMetatype;
- private final String name;
- private final String label;
- private final String description;
-
- /**
- * @param desc Description
- */
- public SlingServletComponentTag(final Annotation annotation,
- final JavaClassDescription desc,
- final boolean createMetatype,
- final String name,
- final String label,
- final String description) {
- super(annotation, desc, null);
- this.createMetatype = createMetatype;
- this.name = name;
- this.label = label;
- this.description = description;
- }
-
- @Override
- public String getName() {
- return Constants.COMPONENT;
- }
-
- @Override
- public String getSourceName() {
- return "SlingServlet";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final Map<String, String> params = new HashMap<String, String>();
- if ( this.name != null ) {
- params.put(Constants.COMPONENT_NAME, this.name);
- }
- if ( this.label != null ) {
- params.put(Constants.COMPONENT_LABEL, this.label);
- }
- if ( this.description != null ) {
- params.put(Constants.COMPONENT_DESCRIPTION, this.description);
- }
- params.put(Constants.COMPONENT_METATYPE, String.valueOf(this.createMetatype));
- return params;
- }
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
deleted file mode 100644
index 4064911..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.sling;
-
-import java.util.*;
-
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.helper.StringUtils;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AbstractTag;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * A property tag.
- */
-public class SlingServletPropertyTag extends AbstractTag {
-
- protected final String name;
- protected final String[] values;
- protected final String type;
- protected final Boolean isPrivate;
-
- /**
- * @param name Property name
- * @param values Property values
- * @param desc Description
- */
- public SlingServletPropertyTag(Annotation annotation, String name, String[] values, JavaClassDescription desc) {
- super(annotation, desc, null);
- this.name = name;
- this.values = values;
- this.type = null;
- this.isPrivate = null;
- }
-
- /**
- * @param name Property name
- * @param values Property values
- * @param desc Description
- */
- public SlingServletPropertyTag(Annotation annotation, String name, String[] values, JavaClassDescription desc, final boolean isPrivate) {
- super(annotation, desc, null);
- this.name = name;
- this.values = values;
- this.type = null;
- this.isPrivate = isPrivate;
- }
-
- /**
- * @param name Property name
- * @param value Property value
- * @param desc Description
- */
- public SlingServletPropertyTag(final Annotation annotation,
- final String name,
- final String value,
- final JavaClassDescription desc,
- final String type,
- final boolean isPrivate) {
- super(annotation, desc, null);
- this.name = name;
- this.values = new String[] {value};
- this.type = type;
- this.isPrivate = isPrivate;
- }
-
- @Override
- public String getName() {
- return Constants.PROPERTY;
- }
-
- @Override
- public String getSourceName() {
- return "SlingServlet";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- final SortedMap<String, String> map = new TreeMap<String, String>();
-
- map.put(Constants.PROPERTY_NAME, this.name);
-
- if (this.values == null || this.values.length == 0) {
- map.put(Constants.PROPERTY_VALUE, "");
- } else if (this.values.length == 1) {
- map.put(Constants.PROPERTY_VALUE, this.values[0]);
- } else {
- for (int i = 0; i < this.values.length; i++) {
- // generate index number with trailing zeros to ensure correct sort order in map
- String index = StringUtils.leftPad(Integer.toString(i), 10, "0");
- map.put(Constants.PROPERTY_MULTIVALUE_PREFIX + '.' + index, this.values[i]);
- }
- }
-
- if ( this.type != null ) {
- map.put(Constants.PROPERTY_TYPE, type);
- }
- if ( this.isPrivate != null ) {
- map.put(Constants.PROPERTY_PRIVATE, String.valueOf(this.isPrivate));
- }
-
- return map;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java
deleted file mode 100644
index da9944b..0000000
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.scrplugin.tags.annotation.sling;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.annotation.AbstractTag;
-
-import com.thoughtworks.qdox.model.Annotation;
-
-/**
- * Description of a java tag for components.
- */
-public class SlingServletServiceTag extends AbstractTag {
-
- private static final Map<String, String> INTERFACE_MAP =
- Collections.singletonMap(Constants.SERVICE_INTERFACE, "javax.servlet.Servlet");
-
- /**
- * @param desc Description
- */
- public SlingServletServiceTag(Annotation annotation, JavaClassDescription desc) {
- super(annotation, desc, null);
- }
-
- @Override
- public String getName() {
- return Constants.SERVICE;
- }
-
- @Override
- public String getSourceName() {
- return "SlingServlet";
- }
-
- @Override
- public Map<String, String> createNamedParameterMap() {
- return INTERFACE_MAP;
- }
-
-}
diff --git a/scrplugin/annotations/src/main/resources/META-INF/services/org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider b/scrplugin/annotations/src/main/resources/META-INF/services/org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider
index a9f2add..ab7e308 100644
--- a/scrplugin/annotations/src/main/resources/META-INF/services/org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider
+++ b/scrplugin/annotations/src/main/resources/META-INF/services/org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider
@@ -1,2 +1,2 @@
-org.apache.felix.scrplugin.tags.annotation.defaulttag.DefaultAnnotationTagProvider
-org.apache.felix.scrplugin.tags.annotation.sling.SlingAnnotationTagProvider
+org.apache.felix.scrplugin.SCRAnnotationProcessor
+org.apache.felix.scrplugin.SlingAnnotationProcessor