FELIX-2963 : scr annotations @Activate @Deactivate @Modified are not detected with class inheritance
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1156580 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/generator/changelog.txt b/scrplugin/generator/changelog.txt
index 0ded2d5..e72adcc 100644
--- a/scrplugin/generator/changelog.txt
+++ b/scrplugin/generator/changelog.txt
@@ -1,3 +1,10 @@
+Changes from 1.1.2 to 1.1.4
+---------------------------
+
+** Bug
+ * [FELIX-2963] - scr annotations @Activate @Deactivate @Modified are not detected with class inheritance
+
+
Changes from 1.1.0 to 1.1.2
---------------------------
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
index 16eac5d..0c3e719 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
@@ -18,21 +18,12 @@
*/
package org.apache.felix.scrplugin.tags.cl;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.lang.reflect.*;
+import java.util.*;
-import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.JavaClassDescriptorManager;
-import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.*;
import org.apache.felix.scrplugin.om.Component;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.JavaField;
-import org.apache.felix.scrplugin.tags.JavaMethod;
-import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.*;
/**
* <code>ClassLoaderJavaClassDescription.java</code>...
@@ -185,8 +176,10 @@
* @see org.apache.felix.scrplugin.tags.JavaClassDescription#getTagByName(java.lang.String)
*/
public JavaTag getTagByName(String name) {
- // this is only used to retrieve the component tag, so we can ignore it
- // for classes from other bundles and simply return null
+ // this is only used to retrieve the component tag, so we just support this
+ if ( this.component != null && name.equals(Constants.COMPONENT) ) {
+ return new ClassLoaderJavaTag(this, this.component);
+ }
return null;
}
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
index 4e7118d..c9e8e88 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
@@ -32,31 +32,43 @@
public class ClassLoaderJavaTag implements JavaTag {
protected final JavaClassDescription description;
+ protected final Component component;
protected final Reference reference;
protected final Property property;
protected final Interface interf;
protected boolean isServiceFactory;
- public ClassLoaderJavaTag(JavaClassDescription desc, Reference reference) {
+ public ClassLoaderJavaTag(final JavaClassDescription desc, final Component component) {
+ this.description = desc;
+ this.reference = null;
+ this.interf = null;
+ this.property = null;
+ this.component = component;
+ }
+
+ public ClassLoaderJavaTag(final JavaClassDescription desc, final Reference reference) {
this.description = desc;
this.reference = reference;
this.interf = null;
this.property = null;
+ this.component = null;
}
- public ClassLoaderJavaTag(JavaClassDescription desc, Property property) {
+ public ClassLoaderJavaTag(final JavaClassDescription desc, final Property property) {
this.description = desc;
this.property = property;
this.reference = null;
this.interf = null;
+ this.component = null;
}
- public ClassLoaderJavaTag(JavaClassDescription desc, Interface i, boolean isSF) {
+ public ClassLoaderJavaTag(final JavaClassDescription desc, final Interface i, final boolean isSF) {
this.interf = i;
this.description = desc;
this.property = null;
this.reference = null;
this.isServiceFactory = isSF;
+ this.component = null;
}
/**
@@ -84,6 +96,8 @@
return Constants.PROPERTY;
} else if ( this.interf != null ) {
return Constants.SERVICE;
+ } else if ( this.component != null ) {
+ return Constants.COMPONENT;
}
return null;
}
@@ -153,6 +167,18 @@
map.put(Constants.SERVICE_FACTORY, "true");
}
return map;
+ } else if ( this.component != null ) {
+ final Map<String, String> map = new HashMap<String, String>();
+ if ( this.component.getActivate() != null ) {
+ map.put(Constants.COMPONENT_ACTIVATE, this.component.getActivate());
+ }
+ if ( this.component.getDeactivate() != null ) {
+ map.put(Constants.COMPONENT_DEACTIVATE, this.component.getDeactivate());
+ }
+ if ( this.component.getModified() != null ) {
+ map.put(Constants.COMPONENT_MODIFIED, this.component.getModified());
+ }
+ return map;
}
return null;
}
diff --git a/scrplugin/maven-scr-plugin/changelog.txt b/scrplugin/maven-scr-plugin/changelog.txt
index fef6d5c..7774e7c 100644
--- a/scrplugin/maven-scr-plugin/changelog.txt
+++ b/scrplugin/maven-scr-plugin/changelog.txt
@@ -1,6 +1,9 @@
Changes from 1.7.2 to 1.7.4
---------------------------
+** Bug
+ * [FELIX-2963] - scr annotations @Activate @Deactivate @Modified are not detected with class inheritance
+
** Improvement
* [FELIX-3066] - Add support for source directory include filter via plugin configuration
diff --git a/scrplugin/maven-scr-plugin/pom.xml b/scrplugin/maven-scr-plugin/pom.xml
index ff04933..e9702d1 100644
--- a/scrplugin/maven-scr-plugin/pom.xml
+++ b/scrplugin/maven-scr-plugin/pom.xml
@@ -57,7 +57,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.generator</artifactId>
- <version>1.1.2</version>
+ <version>1.1.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/scrplugin/scrtask/changelog.txt b/scrplugin/scrtask/changelog.txt
index 284b44d..a6fa5e3 100644
--- a/scrplugin/scrtask/changelog.txt
+++ b/scrplugin/scrtask/changelog.txt
@@ -1,8 +1,14 @@
-Changes from 1.1.0 to 1.1.2
+Changes from 1.1.2 to 1.1.4
---------------------------
** Bug
* [FELIX-2963] - scr annotations @Activate @Deactivate @Modified are not detected with class inheritance
+
+
+Changes from 1.1.0 to 1.1.2
+---------------------------
+
+** Bug
* [FELIX-2978] - Lookup reference policy does not work for inherited components
* [FELIX-2945] - SCR plugin: Parsing of "options" for property tag broken for java annotations
* [FELIX-2906] - @Property(cardinality=Integer.MAX_Int, ...) causes java.lang.NumberFormatException