Integration of Suppliers in Java 8 DSL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Integration of Suppliers in Java 8 DSL

lburgazzoli
Hi,

I'm working to make the Java DSL more Java 8 friedly adding missing
pieces from the previous Java 8 round and one of the thing that was
missing was the possibility to use Suppliers to provides objects to
the routes.

As today:

    from("direct:start")
        .idempotentConsumer()
            .header("messageId")
            .messageIdRepository(createRepo())
        .to("mock:result");


With suppliers:

    from("direct:start")
        .idempotentConsumer()
            .header("messageId")
            .messageIdRepository(this::createRepo)
        .to("mock:result");


Adding that does not result in such a big improvement for the DSL but
it adds some overhead to the underlying definitions as we may need to
add additional variables to hold the suppliers and other stuffs to
convert suppliers i.e. to expression clause so I'm unsure if we should
add such things in 2.19 or maybe delay to 3.0 (where we may have the
chance to do a deeper refactor and suppliers may play better),


What do you think ?


---
Luca Burgazzoli
Reply | Threaded
Open this post in threaded view
|

Re: Integration of Suppliers in Java 8 DSL

Claus Ibsen-2
Hi

Yeah I think its fine to wait for Camel 3.0.
I suggest to log a JIRA and point to this thread so its not lost/forgotten.

It also takes time for Camel users to be on Java 8 and provide
feedback on the Camel DSL where they can see ways to do this in a
natural Java 8 way. And also users want to be able to migrate their
existing Camel applications that are using pre Java 8 style and not
have to change their code to comply with a changed Java DSL due to
java 8 etc.




On Wed, Feb 15, 2017 at 3:39 PM, Luca Burgazzoli <[hidden email]> wrote:

> Hi,
>
> I'm working to make the Java DSL more Java 8 friedly adding missing
> pieces from the previous Java 8 round and one of the thing that was
> missing was the possibility to use Suppliers to provides objects to
> the routes.
>
> As today:
>
>     from("direct:start")
>         .idempotentConsumer()
>             .header("messageId")
>             .messageIdRepository(createRepo())
>         .to("mock:result");
>
>
> With suppliers:
>
>     from("direct:start")
>         .idempotentConsumer()
>             .header("messageId")
>             .messageIdRepository(this::createRepo)
>         .to("mock:result");
>
>
> Adding that does not result in such a big improvement for the DSL but
> it adds some overhead to the underlying definitions as we may need to
> add additional variables to hold the suppliers and other stuffs to
> convert suppliers i.e. to expression clause so I'm unsure if we should
> add such things in 2.19 or maybe delay to 3.0 (where we may have the
> chance to do a deeper refactor and suppliers may play better),
>
>
> What do you think ?
>
>
> ---
> Luca Burgazzoli



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