FELIX-3636 : Using @Service without @Component should log a warning
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1438480 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
index 96be5ee..195f45c 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
@@ -56,6 +56,9 @@
import org.apache.felix.scrplugin.annotations.ScannedClass;
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.ReferenceDescription;
+import org.apache.felix.scrplugin.description.ServiceDescription;
import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;
@@ -146,6 +149,16 @@
if ( desc.getDescriptions(ComponentDescription.class).size() > 0) {
result.add(desc);
log.debug("Found component description " + desc + " in " + annotatedClass.getName());
+ } else {
+ // check whether one of the other annotations is used and log a warning (FELIX-3636)
+ if ( desc.getDescription(PropertyDescription.class) != null
+ || desc.getDescription(ReferenceDescription.class) != null
+ || desc.getDescription(ServiceDescription.class) != null ) {
+ iLog.addWarning("Class '" + src.getClassName() + "' contains SCR annotations, but not a" +
+ "@Component (or equivalent) annotation. Therefore no component descriptor is created for this" +
+ "class. Please add a @Component annotation and consider making it abstract.",
+ src.getFile().toString());
+ }
}
} else {
this.allDescriptions.put(annotatedClass.getName(), new ClassDescription(annotatedClass, GENERATED));