FELIX-3550 : Reimplement the SCR Generator

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1354516 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
index a4968af..339a3db 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
@@ -408,8 +408,10 @@
                 try {
                     current = this.scanner.getDescription(current.getDescribedClass().getSuperclass());
                 } catch ( final SCRDescriptorFailureException sde) {
+                    this.logger.debug(sde.getMessage(), sde);
                     iLog.addError(sde.getMessage(), current.getSource());
                 } catch ( final SCRDescriptorException sde) {
+                    this.logger.debug(sde.getSourceLocation() + " : " + sde.getMessage(), sde);
                     iLog.addError(sde.getMessage(), sde.getSourceLocation());
                 }
             }
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 ff9c5cd..9995b34 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
@@ -200,40 +200,26 @@
             final List<MethodNode> methods = classNode.methods;
             if (methods != null) {
                 for (final MethodNode method : methods) {
+
                     @SuppressWarnings("unchecked")
                     final List<AnnotationNode> annos = method.invisibleAnnotations;
                     if (annos != null) {
                         final String name = method.name;
-                        String signature = method.signature;
-                        if (signature != null) {
-                            // remove generics
-                            int pos;
-                            while ((pos = signature.indexOf('<')) > 0) {
-                                final int lastPos = signature.indexOf('>');
-                                signature = signature.substring(0, pos) + signature.substring(lastPos + 1);
-                            }
-                            // remove everthing after the brackets and replace slash with dot
-                            pos = signature.lastIndexOf(')');
-                            signature = signature.substring(0, pos + 1);
-                            signature = signature.replace('/', '.');
-                        }
+                        final Type[] signature = Type.getArgumentTypes(method.desc);
+
                         final Method[] allMethods = annotatedClass.getDeclaredMethods();
                         Method found = null;
                         for (final Method m : allMethods) {
                             if (m.getName().equals(name)) {
-                                if (m.getParameterTypes().length == 0 && signature == null) {
+                                if (m.getParameterTypes().length == 0 && (signature == null || signature.length == 0) ) {
                                     found = m;
                                 }
-                                if (m.getParameterTypes().length > 0 && signature != null) {
-                                    final StringBuilder sb = new StringBuilder("(");
-                                    for (final Class<?> c : m.getParameterTypes()) {
-                                        sb.append("L");
-                                        sb.append(c.getName());
-                                        sb.append(";");
-                                    }
-                                    sb.append(")");
-                                    if (sb.toString().equals(signature)) {
-                                        found = m;
+                                if (m.getParameterTypes().length > 0 && signature != null && m.getParameterTypes().length == signature.length) {
+                                    found = m;
+                                    for(int index = 0; index < m.getParameterTypes().length; index++ ) {
+                                        if ( !m.getParameterTypes()[index].getName().equals(signature[index].getClassName()) ) {
+                                            found = null;
+                                        }
                                     }
                                 }
                             }
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
index d32db43..882dfe8 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
@@ -129,7 +129,7 @@
             IOUtils.parse(file, xmlHandler);
             return xmlHandler.components;
         } catch (final TransformerException e) {
-            throw new SCRDescriptorException("Unable to read xml", "[stream]", e);
+            throw new SCRDescriptorException("Unable to read xml", location, e);
         }
     }
 
@@ -486,6 +486,8 @@
                             desc.setModified(attributes.getValue(COMPONENT_ATTR_MODIFIED));
                         }
                     }
+
+                    this.currentComponent = desc;
                 } else if (localName.equals(IMPLEMENTATION)) {
                     // now we can create the class description and attach the component description
                     // Set the implementation class name (mandatory)
diff --git a/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java b/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
index 92f6c6e..8a2dce4 100644
--- a/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
+++ b/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
@@ -202,7 +202,7 @@
             this.updateProjectResources();
 
         } catch (final SCRDescriptorException sde) {
-            throw new MojoExecutionException(sde.getMessage(), sde.getCause());
+            throw new MojoExecutionException(sde.getSourceLocation() + " : " + sde.getMessage(), sde.getCause());
         } catch (SCRDescriptorFailureException sdfe) {
             throw (MojoFailureException) new MojoFailureException(
                     sdfe.getMessage()).initCause(sdfe);