You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Dale King <da...@gmail.com> on 2013/10/02 03:55:29 UTC

Scala DSL lacks a way to specify return type of language expressions

The language support in the Scala DSL is too simplistic in that it does not
support all the options of Java DSL.

In particular it does not allow setting the return type of the expression.
In my case I am trying to  set a header to the result of an xpath count
expression. In the Java DSL this fails unless you explicitly set the return
type of the xpath expression because the default return type for xpath is a
node set and it cannot convert a number to a node set.

It also lacks all the other overloads for things like Namespaces on xpath,
etc.

-- 
Dale King

Re: Scala DSL lacks a way to specify return type of language expressions

Posted by Claus Ibsen <cl...@gmail.com>.
We love contributions, so fell free to work on adding the pieces in
Scala DSL you would like.
http://camel.apache.org/contributing.html



On Wed, Oct 2, 2013 at 3:55 AM, Dale King <da...@gmail.com> wrote:
> The language support in the Scala DSL is too simplistic in that it does not
> support all the options of Java DSL.
>
> In particular it does not allow setting the return type of the expression.
> In my case I am trying to  set a header to the result of an xpath count
> expression. In the Java DSL this fails unless you explicitly set the return
> type of the xpath expression because the default return type for xpath is a
> node set and it cannot convert a number to a node set.
>
> It also lacks all the other overloads for things like Namespaces on xpath,
> etc.
>
> --
> Dale King



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Scala DSL lacks a way to specify return type of language expressions

Posted by Claus Ibsen <cl...@gmail.com>.
Yes as Dale points our, the Integer.class is to hint to the xpath
engine that it should evaluate it as a number and not NodeSet / Node
as it would do out of the box.

So an improvement is needed in the Scala DSL. Fell free to log a JIRA
and work on a patch.

On Wed, Oct 2, 2013 at 2:19 PM, Dale King <da...@gmail.com> wrote:
> A conversion after the fact does not help in this case as evaluating the
> expression itself fails with an exception unless you tell the xpath what
> the correct result type will be. If you don't specify, it assumes node set.
> In the case of a count expression the result is a number which cannot be
> converted to node set.
>
> For the record I am dealing with something like this in Java DSL:
>
>    setHeader("fooCount", xpath("count(/bar/foo)", Integer.class))
>
> Without the Integer.class parameter this throws an exception. The Scala DSL
> does not support adding the return type and no conversion after the fact
> will fix it.
> On Oct 2, 2013 1:46 AM, "kraythe ." <kr...@gmail.com> wrote:
>
>> Write an implicit conversion.
>>
>> Scala doesnt manage return types much. Its unnecessary baggage. I rather
>> like that and wish I could use it in my work.
>>
>> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
>> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
>> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
>>
>>
>> On Tue, Oct 1, 2013 at 8:55 PM, Dale King <da...@gmail.com> wrote:
>>
>> > The language support in the Scala DSL is too simplistic in that it does
>> not
>> > support all the options of Java DSL.
>> >
>> > In particular it does not allow setting the return type of the
>> expression.
>> > In my case I am trying to  set a header to the result of an xpath count
>> > expression. In the Java DSL this fails unless you explicitly set the
>> return
>> > type of the xpath expression because the default return type for xpath
>> is a
>> > node set and it cannot convert a number to a node set.
>> >
>> > It also lacks all the other overloads for things like Namespaces on
>> xpath,
>> > etc.
>> >
>> > --
>> > Dale King
>> >
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Scala DSL lacks a way to specify return type of language expressions

Posted by Dale King <da...@gmail.com>.
A conversion after the fact does not help in this case as evaluating the
expression itself fails with an exception unless you tell the xpath what
the correct result type will be. If you don't specify, it assumes node set.
In the case of a count expression the result is a number which cannot be
converted to node set.

For the record I am dealing with something like this in Java DSL:

   setHeader("fooCount", xpath("count(/bar/foo)", Integer.class))

Without the Integer.class parameter this throws an exception. The Scala DSL
does not support adding the return type and no conversion after the fact
will fix it.
On Oct 2, 2013 1:46 AM, "kraythe ." <kr...@gmail.com> wrote:

> Write an implicit conversion.
>
> Scala doesnt manage return types much. Its unnecessary baggage. I rather
> like that and wish I could use it in my work.
>
> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
>
>
> On Tue, Oct 1, 2013 at 8:55 PM, Dale King <da...@gmail.com> wrote:
>
> > The language support in the Scala DSL is too simplistic in that it does
> not
> > support all the options of Java DSL.
> >
> > In particular it does not allow setting the return type of the
> expression.
> > In my case I am trying to  set a header to the result of an xpath count
> > expression. In the Java DSL this fails unless you explicitly set the
> return
> > type of the xpath expression because the default return type for xpath
> is a
> > node set and it cannot convert a number to a node set.
> >
> > It also lacks all the other overloads for things like Namespaces on
> xpath,
> > etc.
> >
> > --
> > Dale King
> >
>

Re: Scala DSL lacks a way to specify return type of language expressions

Posted by "kraythe ." <kr...@gmail.com>.
Write an implicit conversion.

Scala doesnt manage return types much. Its unnecessary baggage. I rather
like that and wish I could use it in my work.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*


On Tue, Oct 1, 2013 at 8:55 PM, Dale King <da...@gmail.com> wrote:

> The language support in the Scala DSL is too simplistic in that it does not
> support all the options of Java DSL.
>
> In particular it does not allow setting the return type of the expression.
> In my case I am trying to  set a header to the result of an xpath count
> expression. In the Java DSL this fails unless you explicitly set the return
> type of the xpath expression because the default return type for xpath is a
> node set and it cannot convert a number to a node set.
>
> It also lacks all the other overloads for things like Namespaces on xpath,
> etc.
>
> --
> Dale King
>