You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/01/21 06:48:16 UTC

svn commit: r736227 - /camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java

Author: ningjiang
Date: Tue Jan 20 21:48:16 2009
New Revision: 736227

URL: http://svn.apache.org/viewvc?rev=736227&view=rev
Log:
CAMEL-1279 take the setter which's parameterType is Object to be last candidate

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=736227&r1=736226&r2=736227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java Tue Jan 20 21:48:16 2009
@@ -254,16 +254,24 @@
         // Build the method name.
         name = "set" + ObjectHelper.capitalize(name);
         while (clazz != Object.class) {
+            // Since Object.class.isInstance all the objects,
+            // Here we just make sure it will be add to the bottom of the set.
+            Method objectSetMethod = null;
             Method[] methods = clazz.getMethods();
             for (Method method : methods) {
                 Class params[] = method.getParameterTypes();
                 if (method.getName().equals(name) && params.length == 1) {
                     Class paramType = params[0];
-                    if (typeConverter != null || isSettableType(paramType) || paramType.isInstance(value)) {
+                    if (paramType.equals(Object.class)) {                        
+                        objectSetMethod = method;
+                    } else if (typeConverter != null || isSettableType(paramType) || paramType.isInstance(value)) {
                         candidates.add(method);
                     }
                 }
             }
+            if (objectSetMethod != null) {
+                candidates.add(objectSetMethod);
+            }
             clazz = clazz.getSuperclass();
         }
 
@@ -277,8 +285,8 @@
             if (LOG.isTraceEnabled()) {
                 LOG.trace("Found " + candidates.size() + " suitable setter methods for setting " + name);
             }
-            // perfer to use the one with the same instance if any exists
-            for (Method method : candidates) {
+            // prefer to use the one with the same instance if any exists
+            for (Method method : candidates) {                               
                 if (method.getParameterTypes()[0].isInstance(value)) {
                     if (LOG.isTraceEnabled()) {
                         LOG.trace("Method " + method + " is the best candidate as it has parameter with same instance type");