[ 
https://issues.apache.org/jira/browse/CAMEL-5958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14659999#comment-14659999
 ] 

ASF GitHub Bot commented on CAMEL-5958:
---------------------------------------

GitHub user lburgazzoli opened a pull request:

    https://github.com/apache/camel/pull/586

    CAMEL-5958: Bindy ignores bean class type

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/lburgazzoli/camel CAMEL-5958

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/586.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #586
    
----
commit 1c293a9c7083ed593a706f42ae6da7247741d9a9
Author: lburgazzoli <[email protected]>
Date:   2013-10-27T15:04:33Z

    CAMEL-5958: Bindy ignores bean class type (initial work)

commit 402f911aaaf3ddaebdad2b143557bd0179813721
Author: lburgazzoli <[email protected]>
Date:   2013-11-06T14:07:11Z

    Merge remote-tracking branch 'upstream/master'

commit ab71ee66d0f69369fa76d09d4a75159b24215c5f
Author: lburgazzoli <[email protected]>
Date:   2013-11-06T21:07:18Z

    Merge remote-tracking branch 'upstream/master'

commit 54440df7c2afefe7324bd5e235c693ccc12e8cff
Author: lburgazzoli <[email protected]>
Date:   2013-11-06T21:17:23Z

    CAMEL-5958: Bindy ignores bean class type (initial work)

commit 8d8e9cb8624cd54354dab12b843b82a94cc14baa
Author: lburgazzoli <[email protected]>
Date:   2013-11-07T15:55:11Z

    Merge remote-tracking branch 'upstream/master'

commit 08c97b5030687abf551a61ee7905465632927081
Author: lburgazzoli <[email protected]>
Date:   2013-11-10T19:02:43Z

    Merge remote-tracking branch 'upstream/master'

commit 095202dc8ee0d551381f275383f4d8afc9d5ac14
Author: lburgazzoli <[email protected]>
Date:   2013-11-22T10:14:58Z

    Merge remote-tracking branch 'upstream/master'

commit ce4e7928904abaa321a1e13e48e7d4f83ec428c2
Author: lburgazzoli <[email protected]>
Date:   2013-11-24T17:19:34Z

    Merge remote-tracking branch 'upstream/master'

commit c1005b5731b3eecbe1d56aa3692707b3ed3bf56f
Author: lburgazzoli <[email protected]>
Date:   2013-11-26T09:58:21Z

    Merge remote-tracking branch 'upstream/master'

commit 1b5c9be1affcfd80484071ec5da310733ed53f78
Author: lburgazzoli <[email protected]>
Date:   2013-11-26T17:01:28Z

    CAMEL-5958: Bindy ignores bean class type (some more work)

commit ab2719e2b6253a0114ec284b4fdfce15851ebb7c
Author: lburgazzoli <[email protected]>
Date:   2013-11-29T21:46:27Z

    CAMEL-5958: Bindy ignores bean class type: load models recursively

commit 2657ac1ba1099867132854780d7901c84fcb439d
Author: lburgazzoli <[email protected]>
Date:   2013-12-17T13:16:37Z

    Merge remote-tracking branch 'upstream/master'

commit 34e05bce2b0b8c708a8a8de673f1d7ece28519af
Author: lburgazzoli <[email protected]>
Date:   2013-12-18T14:03:34Z

    CAMEL-5958: Bindy ignores bean class type

commit 8a2457896aa4f49246463f1c8b9f9e1736d3d08b
Author: lburgazzoli <[email protected]>
Date:   2013-12-18T15:57:51Z

    CAMEL-5958: Bindy ignores bean class type

commit a6c89854ed13cabe263ad653b4c01299d7ece919
Author: lburgazzoli <[email protected]>
Date:   2014-09-20T11:54:57Z

    Merge branch 'master' into CAMEL-5958

commit 3aeed745fa1603da13512008070a9e8231ac5e07
Author: lburgazzoli <[email protected]>
Date:   2014-09-20T17:29:48Z

    CAMEL-5958: Bindy ignores bean class type

commit 95edacb6a6f3a106e4569ed65ee0f86109388d4b
Author: lburgazzoli <[email protected]>
Date:   2015-06-07T18:04:04Z

    Upgrade QuickFIX-J to version 1.6.0

commit 4a008d9cf2931f2d9c76b2f916cad8df25158fff
Author: lburgazzoli <[email protected]>
Date:   2015-06-07T18:48:02Z

    Merge remote-tracking branch 'upstream/master' into CAMEL-5958

commit fa2afe2f80b8b83de69dc224badf756228603f6d
Author: lburgazzoli <[email protected]>
Date:   2015-07-01T20:44:26Z

    Merge branch 'master' of github.com:lburgazzoli/camel

commit 9744d3593d9e75c974742e774c56f8c62bd520f5
Author: lburgazzoli <[email protected]>
Date:   2015-07-01T21:51:10Z

    Merge remote-tracking branch 'upstream/master'
    
    Conflicts:
        
components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
        
components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java

commit c523e5644d7eeb8ff4f236a6cca32c602482c6ec
Author: lburgazzoli <[email protected]>
Date:   2015-07-21T20:33:01Z

    Merge remote-tracking branch 'upstream/master'

commit ece0643a8c7124131c5171d51973a02e74da8fea
Author: lburgazzoli <[email protected]>
Date:   2015-07-21T20:34:42Z

    Merge branch 'master' into CAMEL-5958

commit 6bb2f2d6ca9610546bc6bcd70bde264e3e0a479a
Author: lburgazzoli <[email protected]>
Date:   2015-07-21T20:45:59Z

    merge main codebase

commit 80121f94f63e60497353733c19ace5d4b574bb95
Author: lburgazzoli <[email protected]>
Date:   2015-07-22T13:32:39Z

    CAMEL-5958 : merge main codebase

commit 88aef642f298560bb603ee2e05338da0f6791607
Author: lburgazzoli <[email protected]>
Date:   2015-07-22T13:33:20Z

    Merge remote-tracking branch 'upstream/master'

commit 373bf34ebedefed8b28ba55129b8efa40b5a9408
Author: lburgazzoli <[email protected]>
Date:   2015-07-22T13:33:38Z

    Merge branch 'master' into CAMEL-5958

commit d0bd39eb57ac3deaad08a686c510717150cf4fec
Author: lburgazzoli <[email protected]>
Date:   2015-07-29T13:27:43Z

    Merge branch 'master' into CAMEL-5958

commit 048fa3a692ceb6c19b880ac1ff7d66ab113389eb
Author: lburgazzoli <[email protected]>
Date:   2015-08-01T17:33:55Z

    Merge branch 'master' of github.com:lburgazzoli/camel

commit f09613d35dadd28702ec8bda1e61385e7888c6f7
Author: lburgazzoli <[email protected]>
Date:   2015-08-01T17:34:29Z

    Merge remote-tracking branch 'upstream/master'

commit 23e5ab8876be711282c51d4d8d74a3e686089fae
Author: lburgazzoli <[email protected]>
Date:   2015-08-04T16:12:11Z

    Merge remote-tracking branch 'upstream/master'

----


> Bindy ignores bean class type
> -----------------------------
>
>                 Key: CAMEL-5958
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5958
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-bindy
>    Affects Versions: 2.10.3
>            Reporter: Luca Burgazzoli
>            Priority: Minor
>             Fix For: 3.0.0
>
>
> It looks like camel-bindy does not take into account the class specified in 
> the method:
>     bindy(BindyType.Csv, MyCamelBeans.TEST.class)
> I have class MyCamelBeans which includes several "bindies" among which I have 
> a really simple MyCamelBeans.TEST:
>     class MyCamelBeans {
>         @CsvRecord(separator=";",isOrdered=true)
>         public static final class TEST {
>             @DataField(trim=true,pos=  1) public String tradingDate;
>             @DataField(trim=true,pos=  2) public String isinCode;
>         }
>         ... some other @CsvRecord ....
>     }
> I also have some @FixedLengthRecord classes defined in the same package.
> If I run the following route:
>     
> from("file:data/test?noop=true&idempotent=true&fileName=test.csv&delay=60000")
>         .split(body(String.class).tokenize("\n")).streaming()
>         .unmarshal().bindy(BindyType.Csv, MyCamelBeans.TEST.class)
>         .to("log:DS?level=INFO&showHeaders=true");
> Camel (2.10.3) fails with an NPE:
>     java.lang.NullPointerException
>             at 
> org.apache.camel.dataformat.bindy.BindyCsvFactory.setDefaultValuesForFields(BindyCsvFactory.java:583)
>             at 
> org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:230)
> if I remove the other bindies, camel-bindy works as expected. 
> Looking at the code, I've found that in BindyAbstractFactory.java :
>     /**
>      * method uses to initialize the model representing the classes who will
>      * bind the data. This process will scan for classes according to the
>      * package name provided, check the annotated classes and fields.
>      *
>      * @throws Exception
>      */
>     public void initModel() throws Exception {
>         // Find classes defined as Model
>         if (packageNames != null)  {
>             initModelClasses(this.packageNames);
>         } else if (type != null) {
>             // use the package name from the type as it may refer to types in 
> the same package
>             String pckName = type.getPackage().getName();
>             initModelClasses(pckName);
>         } else {
>             throw new IllegalArgumentException("Either packagenames or type 
> should be configured");
>         }
>     }
> Looks like bindy scan the package even a class has been specified. 
> Accordin to Claus, bindy needs to be refactored so it
> - requires the class type (no more packages)
> - uses the class type as root model
> - ... and initializes the model from the root, and follow and
> references to other classes (if the root has childs)
> This avoids picking up any other models.
> And we would know to marshal/unmarshal based on the root. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to