felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r818375 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags: JavaClassDescriptorManager.java annotation/AnnotationJavaClassDescription.java qdox/QDoxJavaClassDescription.java
Date Thu, 24 Sep 2009 06:16:48 GMT
Author: cziegeler
Date: Thu Sep 24 06:16:48 2009
New Revision: 818375

URL: http://svn.apache.org/viewvc?rev=818375&view=rev
Log:
FELIX-1419 : Add support for nested/inner classes in SCR Plugins (QDox+Annotations). Apply
patch from Stefan Seifert

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java?rev=818375&r1=818374&r2=818375&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
Thu Sep 24 06:16:48 2009
@@ -388,10 +388,10 @@
      * @return All contained java class descriptions.
      */
     public JavaClassDescription[] getSourceDescriptions() throws MojoExecutionException {
-        final JavaClassDescription[] descs = new JavaClassDescription[this.sources.length];
-        for(int i=0; i<this.sources.length; i++) {
-            final String className = this.sources[i].getClasses()[0].getFullyQualifiedName();
-            descs[i] = this.getJavaClassDescription(className);
+        final JavaClass[] javaClasses = getJavaClassesFromSources();
+        final JavaClassDescription[] descs = new JavaClassDescription[javaClasses.length];
+        for(int i=0; i<javaClasses.length; i++) {
+            descs[i] = this.getJavaClassDescription(javaClasses[i].getFullyQualifiedName());
         }
         return descs;
     }
@@ -408,18 +408,19 @@
         if ( result == null ) {
             this.log.debug("Searching description for: " + className);
             int index = 0;
-            while ( result == null && index < this.sources.length) {
-                final JavaClass javaClass = this.sources[index].getClasses()[0];
+            final JavaClass[] javaClasses = getJavaClassesFromSources();
+            while ( result == null && index < javaClasses.length) {
+                final JavaClass javaClass = javaClasses[index];
                 if ( javaClass.getFullyQualifiedName().equals(className) ) {
                     try {
                         // check for java annotation descriptions - fallback to QDox if none
found
                         Class<?> clazz = this.classloader.loadClass(className);
                         if (this.processAnnotations && getAnnotationTagProviderManager().hasScrPluginAnnotation(javaClass))
{
                             this.log.debug("Found java annotation description for: " + className);
-                            result = new AnnotationJavaClassDescription(clazz, this.sources[index],
this);
+                            result = new AnnotationJavaClassDescription(clazz, javaClasses[index],
this);
                         } else if ( this.parseJavadocs ) {
                             this.log.debug("Found qdox description for: " + className);
-                            result = new QDoxJavaClassDescription(clazz, this.sources[index],
this);
+                            result = new QDoxJavaClassDescription(clazz, javaClasses[index],
this);
                         }
                     } catch (ClassNotFoundException e) {
                         throw new MojoExecutionException("Unable to load class " + className);
@@ -440,4 +441,24 @@
         }
         return result;
     }
+    
+    /**
+     * Get a list of all {@link JavaClass} definitions four all source files (including nested/inner
classes)
+     * @return List of {@link JavaClass} definitions
+     */
+    private JavaClass[] getJavaClassesFromSources() {
+        final List<JavaClass> classes = new ArrayList<JavaClass>();
+        for(int i=0; i<this.sources.length; i++) {
+            for(int j=0; j<this.sources[i].getClasses().length; j++) {
+                final JavaClass clazz = this.sources[i].getClasses()[j];
+                classes.add(clazz);
+                for (int k=0; k<clazz.getNestedClasses().length; k++) {
+                    final JavaClass nestedClass = clazz.getNestedClasses()[k];
+                    classes.add(nestedClass);
+                }
+            }
+        }
+        return classes.toArray(new JavaClass[classes.size()]);
+    }
+    
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java?rev=818375&r1=818374&r2=818375&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
Thu Sep 24 06:16:48 2009
@@ -24,7 +24,7 @@
 import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
 import org.apache.maven.plugin.MojoExecutionException;
 
-import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.JavaClass;
 
 /**
  * Reading class description based on java annotations. This extends
@@ -38,8 +38,8 @@
      * @param source QDox source
      * @param manager description manager
      */
-    public AnnotationJavaClassDescription(Class<?> clazz, JavaSource source, JavaClassDescriptorManager
manager) {
-        super(clazz, source, manager);
+    public AnnotationJavaClassDescription(Class<?> clazz, JavaClass javaClass, JavaClassDescriptorManager
manager) {
+        super(clazz, javaClass, manager);
     }
 
     /**

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java?rev=818375&r1=818374&r2=818375&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
Thu Sep 24 06:16:48 2009
@@ -43,15 +43,12 @@
 
     protected final JavaClassDescriptorManager manager;
 
-    protected final JavaSource source;
-
     /** The compiled class. */
     protected final Class<?> clazz;
 
-    public QDoxJavaClassDescription(Class<?> clazz, JavaSource source, JavaClassDescriptorManager
m) {
-        this.javaClass = source.getClasses()[0];
+    public QDoxJavaClassDescription(Class<?> clazz, JavaClass javaClass, JavaClassDescriptorManager
m) {
+        this.javaClass = javaClass;
         this.manager = m;
-        this.source = source;
         this.clazz = clazz;
     }
 



Mime
View raw message