Optimise bean to not create unnessary objects.

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

Branch: refs/heads/master
Commit: 099eac4f30d23e8d03473ff72337e39331a78272
Parents: 39ef98e
Author: Claus Ibsen <davscl...@apache.org>
Authored: Thu Jun 1 22:40:53 2017 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Jun 2 09:05:14 2017 +0200

----------------------------------------------------------------------
 .../camel/component/bean/AbstractBeanProcessor.java |  6 ++----
 .../org/apache/camel/component/bean/BeanInfo.java   | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/099eac4f/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
 
b/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
index beeb692..858253e 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
@@ -266,10 +266,8 @@ public abstract class AbstractBeanProcessor implements 
AsyncProcessor {
         // don't allow if any of the methods has a @Handler annotation
         // as the @Handler annotation takes precedence and is supposed to 
trigger invocation
         // of the given method
-        for (MethodInfo method : info.getMethods()) {
-            if (method.hasHandlerAnnotation()) {
-                return false;
-            }
+        if (info.hasAnyMethodHandlerAnnotation()) {
+            return false;
         }
 
         // fallback and allow using the processor

http://git-wip-us.apache.org/repos/asf/camel/blob/099eac4f/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java 
b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 2e99efa..43cd788 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -1230,6 +1230,7 @@ public class BeanInfo {
      *
      * @return the methods.
      */
+    @Deprecated
     public List<MethodInfo> getMethods() {
         if (operations.isEmpty()) {
             return Collections.emptyList();
@@ -1247,6 +1248,7 @@ public class BeanInfo {
      *
      * @return the methods.
      */
+    @Deprecated
     public List<MethodInfo> getSortedMethods() {
         List<MethodInfo> methods = getMethods();
         if (methods.size() > 1) {
@@ -1257,6 +1259,20 @@ public class BeanInfo {
     }
 
     /**
+     * Does any of the methods have a Canel @Handler annotation.
+     */
+    public boolean hasAnyMethodHandlerAnnotation() {
+        for (List<MethodInfo> list : operations.values()) {
+            for (MethodInfo mi : list) {
+                if (mi.hasHandlerAnnotation()) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
      * Get the operation(s) with the given name. We can have multiple when 
methods is overloaded.
      * <p/>
      * Shorthand method names for getters is supported, so you can pass in eg 
'name' and Camel

Reply via email to