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 2009/06/12 17:46:13 UTC
svn commit: r784162 - in /felix/trunk: scr-annotations/pom.xml
scrplugin/pom.xml
scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
Author: cziegeler
Date: Fri Jun 12 15:46:13 2009
New Revision: 784162
URL: http://svn.apache.org/viewvc?rev=784162&view=rev
Log:
FELIX-1229 : Deactivate has more possibilites than activate; update versions as this are new major features.
Modified:
felix/trunk/scr-annotations/pom.xml
felix/trunk/scrplugin/pom.xml
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
Modified: felix/trunk/scr-annotations/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/pom.xml?rev=784162&r1=784161&r2=784162&view=diff
==============================================================================
--- felix/trunk/scr-annotations/pom.xml (original)
+++ felix/trunk/scr-annotations/pom.xml Fri Jun 12 15:46:13 2009
@@ -29,7 +29,7 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
- <version>0.9.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Annotations for Maven SCR Plugin</name>
Modified: felix/trunk/scrplugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/pom.xml?rev=784162&r1=784161&r2=784162&view=diff
==============================================================================
--- felix/trunk/scrplugin/pom.xml (original)
+++ felix/trunk/scrplugin/pom.xml Fri Jun 12 15:46:13 2009
@@ -29,7 +29,7 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven SCR Plugin</name>
@@ -109,7 +109,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
- <version>0.9.0</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=784162&r1=784161&r2=784162&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java Fri Jun 12 15:46:13 2009
@@ -266,8 +266,8 @@
final String deactivateName = this.deactivate == null ? "deactivate" : this.deactivate;
// check activate and deactivate methods
- this.checkLifecycleMethod(specVersion, javaClass, activateName, iLog);
- this.checkLifecycleMethod(specVersion, javaClass, deactivateName, iLog);
+ this.checkLifecycleMethod(specVersion, javaClass, activateName, true, iLog);
+ this.checkLifecycleMethod(specVersion, javaClass, deactivateName, false, iLog);
// ensure public default constructor
boolean constructorFound = true;
@@ -338,6 +338,9 @@
private static final String TYPE_COMPONENT_CONTEXT = "org.osgi.service.component.ComponentContext";
private static final String TYPE_BUNDLE_CONTEXT = "org.osgi.framework.BundleContext";
private static final String TYPE_MAP = "java.util.Map";
+ private static final String TYPE_INT = "int";
+ private static final String TYPE_INTEGER = "java.lang.Integer";
+
/**
* Check for existence of lifecycle methods.
* @param specVersion The spec version
@@ -348,6 +351,7 @@
protected void checkLifecycleMethod(final int specVersion,
final JavaClassDescription javaClass,
final String methodName,
+ final boolean isActivate,
final IssueLog iLog)
throws MojoExecutionException {
// first candidate is (de)activate(ComponentContext)
@@ -361,11 +365,20 @@
method = javaClass.getMethodBySignature(methodName, new String[] {TYPE_MAP});
if ( method == null ) {
+ // if this is a deactivate method, we have two additional possibilities
+ // a method with parameter of type int and one of type Integer
+ if ( !isActivate ) {
+ method = javaClass.getMethodBySignature(methodName, new String[] {TYPE_INT});
+ if ( method == null ) {
+ method = javaClass.getMethodBySignature(methodName, new String[] {TYPE_INTEGER});
+ }
+ }
+
// fourth candidate is (de)activate with two or three arguments (type must be BundleContext, ComponentCtx and Map)
// as we have to iterate now and the fifth candidate is zero arguments
// we already store this option
JavaMethod zeroArgMethod = null;
- JavaMethod found = null;
+ JavaMethod found = method;
final JavaMethod[] methods = javaClass.getMethods();
int i = 0;
while ( i < methods.length && found == null ) {
@@ -373,14 +386,17 @@
if ( methods[i].getParameters().length == 0 ) {
zeroArgMethod = methods[i];
- } else if ( methods[i].getParameters().length == 2 || methods[i].getParameters().length == 3) {
+ } else if ( methods[i].getParameters().length >= 2 ) {
boolean valid = true;
for(int m=0; m<methods[i].getParameters().length; m++) {
final String type = methods[i].getParameters()[m].getType();
if ( !type.equals(TYPE_BUNDLE_CONTEXT)
&& !type.equals(TYPE_COMPONENT_CONTEXT)
&& !type.equals(TYPE_MAP) ) {
- valid = false;
+ // if this is deactivate, int and integer are possible as well
+ if ( isActivate || (!type.equals(TYPE_INT) && !type.equals(TYPE_INTEGER)) ) {
+ valid = false;
+ }
}
}
if ( valid ) {
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java?rev=784162&r1=784161&r2=784162&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java Fri Jun 12 15:46:13 2009
@@ -34,13 +34,13 @@
protected static final JavaTag[] EMPTY_TAGS = new JavaTag[0];
- protected final Class clazz;
+ protected final Class<?> clazz;
protected final JavaClassDescriptorManager manager;
protected final Component component;
- public ClassLoaderJavaClassDescription(Class c, Component comp, JavaClassDescriptorManager m) {
+ public ClassLoaderJavaClassDescription(Class<?> c, Component comp, JavaClassDescriptorManager m) {
this.clazz = c;
this.manager = m;
this.component = comp;
@@ -99,7 +99,7 @@
* @see org.apache.felix.scrplugin.tags.JavaClassDescription#getImplementedInterfaces()
*/
public JavaClassDescription[] getImplementedInterfaces() throws MojoExecutionException {
- Class[] implemented = clazz.getInterfaces();
+ Class<?>[] implemented = clazz.getInterfaces();
if (implemented.length == 0) {
return JavaClassDescription.EMPTY_RESULT;
}
@@ -116,7 +116,7 @@
*/
public JavaMethod getMethodBySignature(String name, String[] parameters)
throws MojoExecutionException {
- Class[] classParameters = null;
+ Class<?>[] classParameters = null;
if ( parameters != null ) {
classParameters = new Class[parameters.length];
for(int i=0; i<parameters.length; i++) {
@@ -235,8 +235,8 @@
return this.testClass(this.clazz, type);
}
- protected boolean testClass(Class c, String type) {
- final Class[] interfaces = c.getInterfaces();
+ protected boolean testClass(Class<?> c, String type) {
+ final Class<?>[] interfaces = c.getInterfaces();
for(int i=0; i<interfaces.length; i++) {
if ( interfaces[i].getName().equals(type) ) {
return true;