You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2012/05/14 15:21:05 UTC
svn commit: r1338189 [1/4] - in /felix/sandbox/cziegeler:
eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/
scrplugin/annotations/
scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/
scrplugin/annotations/src/main/java...
Author: cziegeler
Date: Mon May 14 13:21:02 2012
New Revision: 1338189
URL: http://svn.apache.org/viewvc?rev=1338189&view=rev
Log:
New SCR Plugin (WiP)
Added:
felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java (with props)
felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/AbstractDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentConfigurationPolicy.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/MethodDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/PropertyDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/PropertyType.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/PropertyUnbounded.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceCardinality.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferencePolicy.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceStrategy.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ServiceDescription.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/SpecVersion.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/AnnotationProcessorManager.java (contents, props changed)
- copied, changed from r1332203, felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Context.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/ClassAnnotation.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/FieldAnnotation.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/MethodAnnotation.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/ScannedAnnotation.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/ScannedClass.java (with props)
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/scanner/Source.java (with props)
felix/sandbox/cziegeler/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenProjectScanner.java (with props)
Removed:
felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Services.java
felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/
felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/ClassUtil.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/JavaField.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/JavaMethod.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/JavaParameter.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/ModifiableJavaClassDescription.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/qdox/
felix/sandbox/cziegeler/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java
Modified:
felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
felix/sandbox/cziegeler/scrplugin/annotations/NOTICE
felix/sandbox/cziegeler/scrplugin/annotations/pom.xml
felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
felix/sandbox/cziegeler/scrplugin/generator/DEPENDENCIES
felix/sandbox/cziegeler/scrplugin/generator/NOTICE
felix/sandbox/cziegeler/scrplugin/generator/pom.xml
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Constants.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Log.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/AbstractObject.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Components.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Implementation.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Interface.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Property.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Reference.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Service.java
felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
felix/sandbox/cziegeler/scrplugin/maven-scr-plugin/NOTICE
felix/sandbox/cziegeler/scrplugin/maven-scr-plugin/pom.xml
felix/sandbox/cziegeler/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java
felix/sandbox/cziegeler/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
Modified: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java (original)
+++ felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java Mon May 14 13:21:02 2012
@@ -233,7 +233,7 @@ public abstract class AbstractTest imple
@Configuration
public static Option[] configuration() {
- final String eventAdminVersion = System.getProperty( EVENT_ADMIN_VERSION_PROP );
+ final String eventAdminVersion = System.getProperty( EVENT_ADMIN_VERSION_PROP, "1.2.15-SNAPSHOT" );
return options(
provision(
mavenBundle( "org.ops4j.pax.tinybundles", "tinybundles", "1.0.0" ),
Modified: felix/sandbox/cziegeler/scrplugin/annotations/NOTICE
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/annotations/NOTICE?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/annotations/NOTICE (original)
+++ felix/sandbox/cziegeler/scrplugin/annotations/NOTICE Mon May 14 13:21:02 2012
@@ -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/).
Modified: felix/sandbox/cziegeler/scrplugin/annotations/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/annotations/pom.xml?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/annotations/pom.xml (original)
+++ felix/sandbox/cziegeler/scrplugin/annotations/pom.xml Mon May 14 13:21:02 2012
@@ -47,7 +47,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.generator</artifactId>
- <version>1.1.2</version>
+ <version>1.1.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Modified: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java (original)
+++ felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java Mon May 14 13:21:02 2012
@@ -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
@@ -114,7 +117,7 @@ public @interface Component {
*
* @since 1.0.1
*/
- String specVersion() default "1.0";
+ String specVersion() default "";
/**
* Generated <code>service.pid</code> property by default, if none declared
@@ -124,13 +127,6 @@ public @interface Component {
/**
* Set the metatype factory pid property (only for non factory components).
- * @since 1.0
- * @deprecated Use {@link #configurationFactory()}
- */
- boolean getConfigurationFactory() default false;
-
- /**
- * Set the metatype factory pid property (only for non factory components).
* @since 1.3
*/
boolean configurationFactory() default false;
Added: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java?rev=1338189&view=auto
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java (added)
+++ felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java Mon May 14 13:21:02 2012
@@ -0,0 +1,398 @@
+/*
+ * 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.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> serviceTags = scannedClass.getClassAnnotations(Service.class.getName());
+ if ( serviceTags.size() > 0 ) {
+ scannedClass.processed(serviceTags);
+ describedClass.add(createService(serviceTags, 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", "%" + component.getName() + ".name"));
+ component.setDescription(cad.getStringValue("description", "%" + component.getName() + ".description"));
+
+ 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) {
+ // 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.setBind(getMethodDescription(ad.getStringValue("bind", "bind")));
+ ref.setUnbind(getMethodDescription(ad.getStringValue("unbind", "unbind")));
+ ref.setUpdated(getMethodDescription(ad.getStringValue("updated", null)));
+ ref.setTarget(ad.getStringValue("target", null));
+ ref.setInterfaceName(ad.getStringValue("referenceInterface", (fieldAnnotation != null ? fieldAnnotation.getAnnotatedField().getType().getName() : null)));
+
+ ref.setCardinality(ReferenceCardinality.valueOf(ad.getEnumValue("cardinality", ReferenceCardinality.MANDATORY_UNARY.name())));
+ ref.setStrategy(ReferenceStrategy.valueOf(ad.getEnumValue("strategy", ReferenceStrategy.EVENT.name())));
+ ref.setPolicy(ReferencePolicy.valueOf(ad.getEnumValue("policy", ReferencePolicy.STATIC.name())));
+
+ 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;
+ prop.setField(fieldAnnotation.getAnnotatedField());
+ } 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", prop.getName() != null ? "%" + prop.getName() + ".name" : null));
+ prop.setDescription(ad.getStringValue("description", prop.getName() != null ? "%" + prop.getName() + ".description" : 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);
+ }
+
+ // TODO PropertyOptions
+
+ describedClass.add(prop);
+ }
+ }
+}
Propchange: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SCRAnnotationProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java?rev=1338189&view=auto
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java (added)
+++ felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java Mon May 14 13:21:02 2012
@@ -0,0 +1,197 @@
+/*
+ * 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.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.setLabel(cad.getStringValue("label", "%" + cd.getName() + ".name"));
+ cd.setDescription(cad.getStringValue("description", "%" + cd.getName() + ".description"));
+
+ 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.setLabel(cad.getStringValue("label", "%" + cd.getName() + ".name"));
+ cd.setDescription(cad.getStringValue("description", "%" + cd.getName() + ".description"));
+
+ 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);
+ }
+}
Propchange: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/sandbox/cziegeler/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/SlingAnnotationProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: felix/sandbox/cziegeler/scrplugin/generator/DEPENDENCIES
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/DEPENDENCIES?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/DEPENDENCIES (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/DEPENDENCIES Mon May 14 13:21:02 2012
@@ -19,10 +19,6 @@ This product uses software developed at
Copyright (c) 2000-2005 INRIA, France Telecom
Licensed under the BSD License.
-This product uses software developed at
-The Codehaus (http://www.codehaus.org)
-Licensed under the Apache License 2.0.
-
III. License Summary
- Apache License 2.0
Modified: felix/sandbox/cziegeler/scrplugin/generator/NOTICE
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/NOTICE?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/NOTICE (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/NOTICE Mon May 14 13:21:02 2012
@@ -1,5 +1,5 @@
Apache Felix Descriptor Generator Implementation
-Copyright 2010-2011 The Apache Software Foundation
+Copyright 2010-2012 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Modified: felix/sandbox/cziegeler/scrplugin/generator/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/pom.xml?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/pom.xml (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/pom.xml Mon May 14 13:21:02 2012
@@ -45,14 +45,6 @@
</scm>
<dependencies>
- <!-- JavaDoc Tags -->
- <dependency>
- <groupId>com.thoughtworks.qdox</groupId>
- <artifactId>qdox</artifactId>
- <version>1.12</version>
- <scope>compile</scope>
- </dependency>
-
<!-- bind/unbind method generation -->
<dependency>
<groupId>asm</groupId>
@@ -60,20 +52,6 @@
<version>3.1</version>
<scope>compile</scope>
</dependency>
-
- <!-- OSGi APIs (some constant references used only) -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- <scope>provided</scope>
- </dependency>
</dependencies>
<build>
Added: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java?rev=1338189&view=auto
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java (added)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java Mon May 14 13:21:02 2012
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.felix.scrplugin.description.ClassDescription;
+import org.apache.felix.scrplugin.scanner.ScannedClass;
+
+/**
+ * This service provides a plugin for annotation processing. Custom tags
+ * can be processed.
+ * On a scanned class all available annotation processors are called in
+ * order of their {@link #getRanking()} value (lowest value first).
+ */
+public interface AnnotationProcessor {
+
+ /**
+ * Processes annotations from the provided list and adds objects
+ * to the object model based on the read annotations.
+ * If this service processes an annotation, it should remove this
+ * annotation from the provided list to avoid duplicate processing
+ * by other processors.
+ * @param scannedClass The scanned class.
+ * @param describedClass The descriptions.
+ */
+ void process(final ScannedClass scannedClass,
+ final ClassDescription describedClass)
+ throws SCRDescriptorException, SCRDescriptorFailureException;
+
+ /**
+ * The ranking of this processor.
+ */
+ int getRanking();
+}
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/AnnotationProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Constants.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Constants.java?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Constants.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Constants.java Mon May 14 13:21:02 2012
@@ -21,21 +21,12 @@ package org.apache.felix.scrplugin;
import java.io.File;
/**
- * The <code>Constants</code> interface provides use full constants for various
+ * The <code>Constants</code> interface provides useful constants for various
* values used for processing SCR annotations and JavaDoc tags into SCR
* descriptors.
*/
public interface Constants {
- /** Version 1.0 (R4.1) */
- public static final int VERSION_1_0 = 0;
-
- /** Version 1.1 (R4.2) */
- public static final int VERSION_1_1 = 1;
-
- /** Version 1.1-felix (R4.2 + FELIX-1893) */
- public static final int VERSION_1_1_FELIX = 2;
-
/**
* The name of the Bundle manifest header providing the list of service
* component descriptor files.
@@ -67,15 +58,6 @@ public interface Constants {
// Force the descriptor version (since 1.4.1)
public static final String COMPONENT_DS_SPEC_VERSION = "specVersion";
- // Specification version identifier for SCR 1.0 (R 4.1)
- public static final String COMPONENT_DS_SPEC_VERSION_10 = "1.0";
-
- // Specification version identifier for SCR 1.1 (R 4.2)
- public static final String COMPONENT_DS_SPEC_VERSION_11 = "1.1";
-
- // Specification version identifier for SCR 1.1-felix (R 4.2+FELIX-1893)
- public static final String COMPONENT_DS_SPEC_VERSION_11_FELIX = "1.1-felix";
-
public static final String COMPONENT_CREATE_PID = "create-pid";
public static final String COMPONENT_SET_METATYPE_FACTORY_PID = "configurationFactory";
Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Log.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Log.java?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Log.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Log.java Mon May 14 13:21:02 2012
@@ -24,8 +24,8 @@ package org.apache.felix.scrplugin;
* SCR descriptor generation process using whatever means is implemented. There
* should be no big surprises here.
*/
-public interface Log
-{
+public interface Log {
+
/**
* @return true if the <b>debug</b> error level is enabled
*/
Added: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java?rev=1338189&view=auto
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java (added)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java Mon May 14 13:21:02 2012
@@ -0,0 +1,115 @@
+/*
+ * 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.Collections;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.description.SpecVersion;
+
+
+public class Options {
+
+ private boolean generateAccessors = true;
+
+ private boolean strictMode = false;
+
+ private Map<String, String> properties = Collections.emptyMap();
+
+ private SpecVersion specVersion;
+
+ private String[] annotationProcessors;
+
+ public String[] getAnnotationProcessors() {
+ return annotationProcessors;
+ }
+
+ public void setAnnotationProcessors(String[] annotationProcessors) {
+ this.annotationProcessors = annotationProcessors;
+ }
+
+ public boolean isGenerateAccessors() {
+ return generateAccessors;
+ }
+
+ /**
+ * Defines whether bind and unbind methods are automatically created by
+ * the SCR descriptor generator.
+ * <p>
+ * The generator uses the ASM library to create the method byte codes
+ * directly inside the class files. If bind and unbind methods are not
+ * to be created, the generator fails if such methods are missing.
+ * <p>
+ * The default value of this property is <code>true</code>.
+ */
+ public void setGenerateAccessors(boolean generateAccessors) {
+ this.generateAccessors = generateAccessors;
+ }
+
+ public boolean isStrictMode() {
+ return strictMode;
+ }
+
+ /**
+ * Defines whether warnings should be considered as errors and thus cause
+ * the generation process to fail.
+ * <p>
+ * The default value of this property is <code>false</code>.
+ */
+ public void setStrictMode(boolean strictMode) {
+ this.strictMode = strictMode;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets global properties to be set for each descriptor. If a descriptor
+ * provides properties of the same name, the descriptor properties are preferred
+ * over the properties provided here.
+ * <p>
+ * The are no default global properties.
+ */
+ public void setProperties(Map<String, String> properties) {
+ this.properties = properties;
+ }
+
+ public SpecVersion getSpecVersion() {
+ return specVersion;
+ }
+
+ /**
+ * Sets the Declarative Services specification version number to be forced
+ * on the declarations.
+ * <p>
+ * Supported values for this property are <code>null</code> to autodetect
+ * the specification version, or one of the enum values from
+ * {@link SpecVersion}.
+ * <p>
+ * The default is to generate the descriptor version according to the
+ * capabilities used by the descriptors. If no 1.1 capabilities, such as
+ * <code>configuration-policy</code>, are used, version 1.0 is used,
+ * otherwise a 1.1 descriptor is generated.
+ */
+ public void setSpecVersion(SpecVersion specVersion) {
+ this.specVersion = specVersion;
+ }
+
+}
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java?rev=1338189&view=auto
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java (added)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java Mon May 14 13:21:02 2012
@@ -0,0 +1,58 @@
+/*
+ * 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.io.File;
+import java.util.Collection;
+
+import org.apache.felix.scrplugin.scanner.Source;
+
+public class Project {
+
+ private Collection<Source> sources;
+
+ private Collection<File> dependencies;
+
+ private ClassLoader classLoader;
+
+ public Collection<Source> getSources() {
+ return sources;
+ }
+
+ public void setSources(Collection<Source> sources) {
+ this.sources = sources;
+ }
+
+ public Collection<File> getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(Collection<File> dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+}
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java?rev=1338189&r1=1338188&r2=1338189&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java Mon May 14 13:21:02 2012
@@ -19,11 +19,7 @@
package org.apache.felix.scrplugin;
-import org.apache.felix.scrplugin.tags.JavaTag;
-
-
-public class SCRDescriptorException extends Exception
-{
+public class SCRDescriptorException extends Exception {
private static final long serialVersionUID = 1L;
@@ -32,12 +28,6 @@ public class SCRDescriptorException exte
private final int m_lineNumber;
- public SCRDescriptorException( final String message, final JavaTag tag )
- {
- this( message, tag.getSourceLocation(), tag.getLineNumber() );
- }
-
-
public SCRDescriptorException( final String message, final String sourceLocation, final int lineNumber )
{
super( message );
@@ -46,9 +36,9 @@ public class SCRDescriptorException exte
}
- public SCRDescriptorException( final String message, final JavaTag tag, final Throwable cause )
+ public SCRDescriptorException( final String message, final Throwable cause )
{
- this( message, tag.getSourceLocation(), tag.getLineNumber(), cause );
+ this( message, null, -1, cause );
}