camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r672723 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean: BeanInfo.java MethodInfo.java
Date Mon, 30 Jun 2008 08:03:42 GMT
Author: davsclaus
Date: Mon Jun 30 01:03:42 2008
New Revision: 672723

URL: http://svn.apache.org/viewvc?rev=672723&view=rev
Log:
CAMEL-651: Improved method matching, considering MEP pattern that out capable should invoke
a non-void method

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java?rev=672723&r1=672722&r2=672723&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
Mon Jun 30 01:03:42 2008
@@ -212,8 +212,7 @@
     }
 
     protected MethodInfo chooseMethodWithMatchingBody(Exchange exchange, Collection<MethodInfo>
operationList) throws AmbiguousMethodCallException {
-        // lets see if we can find a method who's body param type matches
-        // the message body
+        // lets see if we can find a method who's body param type matches the message body
         Message in = exchange.getIn();
         Object body = in.getBody();
         if (body != null) {
@@ -221,6 +220,18 @@
 
             List<MethodInfo> possibles = new ArrayList<MethodInfo>();
             for (MethodInfo methodInfo : operationList) {
+                // TODO: AOP proxies have additioan methods - consider having a static
+                // method exclude list to skip all known AOP proxy methods
+                // TODO: This class could use some TRACE logging
+
+                // test for MEP pattern matching
+                boolean out = exchange.getPattern().isOutCapable();
+                if (out && methodInfo.isReturnTypeVoid()) {
+                    // skip this method as the MEP is Out so the method must return someting
+                    continue;
+                }
+                
+                // try to match the arguments
                 if (methodInfo.bodyParameterMatches(bodyType)) {
                     possibles.add(methodInfo);
                 }
@@ -255,6 +266,7 @@
                 return chooseMethodWithCustomAnnotations(exchange, possibles);
             }
         }
+        // no match so return null
         return null;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java?rev=672723&r1=672722&r2=672723&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
Mon Jun 30 01:03:42 2008
@@ -99,7 +99,6 @@
         return parameterInfo.getType();
     }
 
-
     public boolean bodyParameterMatches(Class bodyType) {
         Class actualType = getBodyParameterType();
         return actualType != null && ObjectHelper.isAssignableFrom(bodyType, actualType);
@@ -117,6 +116,10 @@
         return hasCustomAnnotation;
     }
 
+    public boolean isReturnTypeVoid() {
+        return method.getReturnType().getName().equals("void");
+    }
+
     protected Object invoke(Method mth, Object pojo, Object[] arguments, Exchange exchange)
throws IllegalAccessException, InvocationTargetException {
         return mth.invoke(pojo, arguments);
     }



Mime
View raw message