You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Beto Flores <be...@gmail.com> on 2019/06/27 22:08:34 UTC

Complex datatypes in DataFormatClause.

Hi all.

I am working in adding configurability to the Any23 DataFormat creation
through DataFormatClause.

I was thinking in two polymorphic forms like these:

marshal().any23(conf, extractorsList)....
marshal().any23(conf)....

Where conf would be a Map<String, String> containing Any23 Configuration
parameters as Key-Value pairs. And extractorsList a List <String>
 containing a list of active extractors to be used by the dataformat.

But I noticed that other dataformats do not use complex structures (Map,
List) in DataFormatClause, instead they use simple types such as int,
String, boolean.  Is there a specific reason for that?, I mean it is a
standard to use only simple types. Am I going to have trouble in the any23
Reifier implementation if  I use the aforementioned approach?.

Best,
Roberto.

Re: Complex datatypes in DataFormatClause.

Posted by Zoran Regvart <zo...@regvart.com>.
Hi Roberto,
we want to be as typesafe as we can so specifying narrow types and
having classes that hold configuration options in specific fields.
That might not be a good approach for Any23 if it has numerous options
that need to be set and having to maintain this over time becomes
cumbersome.

Here's something you can think about: if you find that the values in
those Maps or Lists need to be parsed from Strings to other types to
configure Any23 then it's probably better to introduce a class to hold
those values so no conversion is needed. There's no need to add
another layer on top of Any23, if there's a Configuration class in
Any23 that ends up being created from the Map<String, String> it would
be better just to use it instead of the Map. If the extractors List is
a list of object instances or classes it would be better to narrow
that list to List<ExtractorInterface> or
List<Class<ExtractorInterface>>.

Hope this helps,

zoran

On Fri, Jun 28, 2019 at 12:08 AM Beto Flores <be...@gmail.com> wrote:
>
> Hi all.
>
> I am working in adding configurability to the Any23 DataFormat creation
> through DataFormatClause.
>
> I was thinking in two polymorphic forms like these:
>
> marshal().any23(conf, extractorsList)....
> marshal().any23(conf)....
>
> Where conf would be a Map<String, String> containing Any23 Configuration
> parameters as Key-Value pairs. And extractorsList a List <String>
>  containing a list of active extractors to be used by the dataformat.
>
> But I noticed that other dataformats do not use complex structures (Map,
> List) in DataFormatClause, instead they use simple types such as int,
> String, boolean.  Is there a specific reason for that?, I mean it is a
> standard to use only simple types. Am I going to have trouble in the any23
> Reifier implementation if  I use the aforementioned approach?.
>
> Best,
> Roberto.



-- 
Zoran Regvart

Re: Complex datatypes in DataFormatClause.

Posted by Beto Flores <be...@gmail.com>.
Hi Zoran and Claus

Thanks for your replies.
I agree with Claus, it is probably better to move this discussion to a PR
in Github with the dataformat in a basic state. I will clean-up my code and
remove some experiments that I have doing on local and send a PR.

Thank you,
Roberto

El vie., 28 de jun. de 2019 a la(s) 06:42, Claus Ibsen (
claus.ibsen@gmail.com) escribió:

> Hi Roberto
>
> When writing a dataformat then keep in mind that it should be both
> useable and configurable from both Java and XML DSL.
> That is why we have model classes tied into camel-core that specify
> the options you can configure, so they get generated in the XML DSL as
> well, as in Java DSL via getter/setters and fluent builders.
>
> This works well when there are limited number of options.
>
> If you need to configure any kind of arbitrary key/value pairs etc,
> then we have a way of setting an option as Map so it can be key/value
> in the XML DSL etc.
>
> Its probably easier if you get to a point with a basic implementation
> of any23 we can look at first, and then take a review how to add more
> complex configurations.
>
> On Fri, Jun 28, 2019 at 12:08 AM Beto Flores <be...@gmail.com>
> wrote:
> >
> > Hi all.
> >
> > I am working in adding configurability to the Any23 DataFormat creation
> > through DataFormatClause.
> >
> > I was thinking in two polymorphic forms like these:
> >
> > marshal().any23(conf, extractorsList)....
> > marshal().any23(conf)....
> >
> > Where conf would be a Map<String, String> containing Any23 Configuration
> > parameters as Key-Value pairs. And extractorsList a List <String>
> >  containing a list of active extractors to be used by the dataformat.
> >
> > But I noticed that other dataformats do not use complex structures (Map,
> > List) in DataFormatClause, instead they use simple types such as int,
> > String, boolean.  Is there a specific reason for that?, I mean it is a
> > standard to use only simple types. Am I going to have trouble in the
> any23
> > Reifier implementation if  I use the aforementioned approach?.
> >
> > Best,
> > Roberto.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: Complex datatypes in DataFormatClause.

Posted by Claus Ibsen <cl...@gmail.com>.
Hi Roberto

When writing a dataformat then keep in mind that it should be both
useable and configurable from both Java and XML DSL.
That is why we have model classes tied into camel-core that specify
the options you can configure, so they get generated in the XML DSL as
well, as in Java DSL via getter/setters and fluent builders.

This works well when there are limited number of options.

If you need to configure any kind of arbitrary key/value pairs etc,
then we have a way of setting an option as Map so it can be key/value
in the XML DSL etc.

Its probably easier if you get to a point with a basic implementation
of any23 we can look at first, and then take a review how to add more
complex configurations.

On Fri, Jun 28, 2019 at 12:08 AM Beto Flores <be...@gmail.com> wrote:
>
> Hi all.
>
> I am working in adding configurability to the Any23 DataFormat creation
> through DataFormatClause.
>
> I was thinking in two polymorphic forms like these:
>
> marshal().any23(conf, extractorsList)....
> marshal().any23(conf)....
>
> Where conf would be a Map<String, String> containing Any23 Configuration
> parameters as Key-Value pairs. And extractorsList a List <String>
>  containing a list of active extractors to be used by the dataformat.
>
> But I noticed that other dataformats do not use complex structures (Map,
> List) in DataFormatClause, instead they use simple types such as int,
> String, boolean.  Is there a specific reason for that?, I mean it is a
> standard to use only simple types. Am I going to have trouble in the any23
> Reifier implementation if  I use the aforementioned approach?.
>
> Best,
> Roberto.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2