You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2014/06/19 03:01:43 UTC

git commit: Fixed JavadocApiMethodGeneratorMojo to avoid throwing exceptions for declared non-public methods

Repository: camel
Updated Branches:
  refs/heads/master 2d2716464 -> b6a242da5


Fixed JavadocApiMethodGeneratorMojo to avoid throwing exceptions for declared non-public methods


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b6a242da
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b6a242da
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b6a242da

Branch: refs/heads/master
Commit: b6a242da5996877f82b2474ea15572becdd14b10
Parents: 2d27164
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 18 18:00:32 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Wed Jun 18 18:00:32 2014 -0700

----------------------------------------------------------------------
 .../maven/AbstractApiMethodGeneratorMojo.java   |  2 +-
 .../maven/JavadocApiMethodGeneratorMojo.java    | 23 ++++++++++----------
 2 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b6a242da/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
index 8dff89d..7a38ce0 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -91,7 +91,7 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractSourceGener
     }
 
     protected ApiMethodParser createAdapterParser(Class proxyType) {
-        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions()){};
+        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
     }
 
     public abstract List<String> getSignatureList() throws MojoExecutionException;

http://git-wip-us.apache.org/repos/asf/camel/blob/b6a242da/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
index a62b35e..634d29c 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -34,7 +34,6 @@ import javax.swing.text.html.parser.Parser;
 import javax.swing.text.html.parser.TagElement;
 
 import org.apache.camel.util.component.ApiMethodParser;
-import org.apache.camel.util.component.ArgumentSubstitutionParser;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -66,11 +65,6 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
     protected String excludeMethods;
 
     @Override
-    protected ApiMethodParser createAdapterParser(Class proxyType) {
-        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
-    }
-
-    @Override
     public List<String> getSignatureList() throws MojoExecutionException {
         // signatures as map from signature with no arg names to arg names from JavadocParser
         Map<String, String> result = new HashMap<String, String>();
@@ -159,18 +153,25 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
                 throw new MojoExecutionException(e.getCause().getMessage(), e.getCause());
             }
         }
+        // return null for non-public and non-static methods
+        String result = null;
         try {
             final Method method = aClass.getMethod(name, argTypes);
             // only include non-static public methods
             int modifiers = method.getModifiers();
-            if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
-                return method.getReturnType().getCanonicalName();
-            } else {
-                return null;
+            if (!Modifier.isStatic(modifiers)) {
+                result = method.getReturnType().getCanonicalName();
             }
         } catch (NoSuchMethodException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
+            // could be a non-public method
+            try {
+                aClass.getDeclaredMethod(name, argTypes);
+            } catch (NoSuchMethodException e1) {
+                throw new MojoExecutionException(e1.getMessage(), e1);
+            }
         }
+
+        return result;
     }
 
     private class JavadocParser extends Parser {