Hello Guillaume,
First of all, I really meant maps, not only for an example.
ConstantExpression is already handling maps correctly, I tried. I
guess PropertyExpression will handle any complex type, too. So only
XPath expressions are unable to deal with maps.
It's needed to use maps instead of primitives if you implement a
Command Pattern in the endpoint. For example, database named query has
a name and a list of named parameters with their values. It may be
implemented with a method like query(String queryName, Map<String,
Object> params). Instead of hard coding XPath of params in the
NormalizedMessage, it would be useful if you could configure where to
find it, like this:
<jpa:jpa-query service="test:jpa"
endpoint="updateQuery">
<queryName>
<bean
class="org.apache.servicemix.expression. JAXPXPathXStreamExpression">
<constructor-arg value="/
query/name"/>
</bean>
</queryName>
<params>
<bean
class="org.apache.servicemix.expression.JAXPXPathXStreamExpression">
<constructor-arg value="/
query/params/map"/>
</bean>
</params>
</jpa:jpa-query>
Then it can handle messages with content like
<query>
<name>updateVideoTitle</name>
<params>
<map>
<entry>
<key>id</key>
<value>10</value>
</entry><entry>
<key>title</key>
<value>Office space</value>
</entry>
</map>
</params>
</query>
What do you think?
Andrew.
On May 19, 2008, at 10:15, Guillaume Nodet wrote:
How would one use such an expression ? Usually, predicates use
simple types
such as boolean or string, not complex objects as maps. I know map
is just
an example, but other simple types are already handled by subtypes
of the
JAXPXpathExpression. Just wondering...
On Sun, May 18, 2008 at 3:27 PM, Andrew Skiba <[EMAIL PROTECTED]> wrote:
Existing JAXPXPathExpression evaluates only to strings. This
subclass allows
to use XStream to evaluate a part of a message into an object of
any type.
For example if a message carries XML like <message> <params> <map>
<entry>
<key>key1</key> <value>value1</value> </...> and xpath=/message/
params/map
then this JAXPXPathXStreamExpression evaluates it into java.util.Map
Please tell me what you think.
Andrew.
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/