camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vitalii Tymchyshyn <...@tym.im>
Subject Re: Java8 DSL (CAMEL-7831)
Date Wed, 07 Sep 2016 12:16:31 GMT
Hi.

Why BodyFunction is a BiFunction? It would be great to have some method to
pass any Functional interface (any function) that would receive body as
parameter and result would be stored as an answer. This would allow to use
tons of existing functional method.
E.g. something like this would be possible:
.transform(function(String.class, String::toUpperCase))
Another thing is that often body type is not needed, e.g.
.transform(onBody(String::toUpperCase)) looks more readable.
i'd also rename other "function" calls with something that gives more
information like "onExchange", "onMessage" (or even simply body(),
exchange(), message()). This would also make casting unnesessary.

Best regards, Vitalii Tymchyshyn

Вт, 6 вер. 2016 о 11:38 Luca Burgazzoli <lburgazzoli@gmail.com> пише:

> Hello everyone,
> I've started working on CAMEL-7831 to create a Java8 example to use
> Expressions and I've ended up with a simple example - see [1].
> Of course it is only for demonstrative purpose.
>
> Java8 lambda support to Expressions has been added to
> - ExpressionClause to avoid adding overload method for every method
> accepting an Expressions definition
> - ExpressionBuilder so you can use something like transform(function(e ->
> ...))
>
> There are some additional functional interfaces to select the argument
> of the lambda
> - ExchangeFunction
> - MessageFunction
> - BodyFunction
>
>
> Any feedback would be really appreciated.
>
> Regards,
> Luca
>
>
> [1]
> https://github.com/lburgazzoli/apache-camel/blob/CAMEL-7831/examples/camel-example-dsl-java8/src/main/java/org/apache/camel/example/dsl/java8/MyRoute.java
>
>
> ---
> Luca Burgazzoli
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message