camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [07/12] camel git commit: CAMEL-5958: Bindy ignores bean class type: load models recursively
Date Fri, 07 Aug 2015 09:14:33 GMT
CAMEL-5958: Bindy ignores bean class type: load models recursively


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

Branch: refs/heads/master
Commit: 222f5fdaea783002161333502aadf1b7a38ea8f4
Parents: a052c1c
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Fri Nov 29 22:46:27 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Aug 7 11:05:47 2015 +0200

----------------------------------------------------------------------
 .../dataformat/bindy/BindyAbstractFactory.java  | 25 ++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/222f5fda/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
index 43bca89..a23383a 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
@@ -64,23 +64,34 @@ public abstract class BindyAbstractFactory implements BindyFactory {
      */
     public void initModel() throws Exception {
         models = new HashSet<Class<?>>();
-        models.add(type);
+        modelClassNames = new HashSet<String>();
         
-        for (Field field : type.getDeclaredFields()) {
+        loadModels(type);
+    }
+    
+    /**
+     * Recursively load model.
+     *  
+     * @param root
+     */
+    private void loadModels(Class<?> root) {
+        models.add(root);
+        modelClassNames.add(root.getName());
+        
+        for (Field field : root.getDeclaredFields()) {
             Link linkField = field.getAnnotation(Link.class);
 
             if (linkField != null) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Class linked: {}, Field: {}", field.getType(), field);
                 }
+                
                 models.add(field.getType());
+                modelClassNames.add(field.getType().getName());
+                
+                loadModels(field.getType());
             }
         }
-        
-        modelClassNames = new HashSet<String>();
-        for (Class<?> clazz : models) {
-            modelClassNames.add(clazz.getName());
-        }
     }
 
     /**


Mime
View raw message