Raul Kripalani created CAMEL-5680:
-------------------------------------

             Summary: Create a set/assign DSL where the target is determined by 
an expression
                 Key: CAMEL-5680
                 URL: https://issues.apache.org/jira/browse/CAMEL-5680
             Project: Camel
          Issue Type: New Feature
          Components: camel-core
            Reporter: Raul Kripalani
            Assignee: Raul Kripalani


Right now we have three setXYZ DSLs: {{setBody}}, {{setHeader}}, 
{{setProperty}}. We could create a generic {{<set />}} DSL where the target of 
the assignment is determined by an expression.

Imagine you had a POJO in your payload, and you want to invoke a setter with 
the value of a header. You could write something like:

{code}
<set>
  <from>
    <header>abc</header>
  </from>
  <to>
    <ognl>body.setName($value)</ognl>
  </to>
</set>
{code}

Kind of like BPEL's <assign />.

If you had a HashMap as the body, you could do ad-hoc setting of entries (now 
using the assign variant):

{code}
<assign>
  <from>
    <xpath headerName="myHeader">/my/expression</xpath>
  </from>
  <to>
    <ognl>body.put('key', $value)</ognl>
  </to>
</assign>
{code}

And if we could support XPath to XPath mapping, like BPEL's assign, that would 
be excellent.

{code}
<assign>
  <from>
    <xpath headerName="foo">/my/expression</xpath>
  </from>
  <to>
    <xpath>body.put('key', $value)</xpath>
  </to>
</assign>
{code}

But the latter is much more complex because the XPath standard by itself 
doesn't encompass setting of elements for obvious reasons. However, XProc does 
(p:insert).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to