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

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

GitHub user lburgazzoli opened a pull request:

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

    CAMEL-5958: Bindy ignores bean class type

    re-build PR against latest sources

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/271.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 #271
    
----
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

----


> 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
>
> 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