在JBoss Drools中评估XPath表达式 [英] Evaluating XPath expressions in JBoss Drools

查看:91
本文介绍了在JBoss Drools中评估XPath表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理大量XML消息的企业体系结构中工作.最近,我们被要求对这些XML消息中包含的数据执行一些计算,并将一些结果添加到消息头中,然后再将消息从企业传递到外部使用者.我们的体系结构基于JBoss SOA-P,我目前正在评估JBoss Drools 5.2.0来执行这些消息操作.

I am working within a enterprise architecture that is processing a large amount of XML messages. We have recently been given the requirement to perform some calculations on data contained in those XML messages and add some results to the message header before passing the message out of the enterprise to an external consumer. Our architecture is based on the JBoss SOA-P and I am currently evaluating JBoss Drools 5.2.0 for performing these message operations.

我知道我可以简单地从XML中合并POJO,对其执行规则,并添加适当的结果.但是,如果可能的话,由于围绕架构的动态要求以及将新的已编译代码部署到生产环境中的重大障碍,我想消除对XML消息结构的编译时依赖性(请参阅:繁文tape节).理想情况下,我想对.drl规则中的原始XML使用XPath评估.一些搜索打开了 SXC 项目,这似乎正是我所需要的,但是在那里关于如何使用它的信息很少,并且自2007年以来似乎处于休眠状态.此外,它是根据Drools 4.0.4编译的,我必须使用5.2.0.

I know that I can simply hydrate a POJO from the XML, execute the rules on it, and add the appropriate result. If possible, however, I would like to remove compile-time dependencies on the XML message structure due to dynamic requirements around the schema as well as significant hurdles in deploying new compiled code to our production environment (read: red tape). I would ideally like to use XPath evaluations on the raw XML in the .drl rules. Some searching turned up the SXC project, which appears to be exactly what I need, but there is very little information on how to use it and it seems to be dormant since 2007. Additionally, it has been compiled against Drools 4.0.4 and I am required to use 5.2.0.

有人知道Drools规则中针对XML评估XPath表达式的好方法吗?也欢迎使用XPath的替代方法,该替代方法允许在运行时在Drools规则中补偿XML结构更改.

Does anyone know of a good way to evaluate XPath expressions against XML in Drools rules? Alternatives to XPath that allow XML structure changes to be compensated for in Drools rules at runtime are also welcome.

谢谢!

推荐答案

我们有Drools的专家来我们公司参观,不久前还介绍了Drools.我正在开发具有许多不断变化的规则的服务,因此我们考虑使用Drools.

we had an expert on Drools visiting our company and taking about Drools short time ago. I am developing a Service with a lot of rules that are constantly changing and we thought about using Drools.

专家告诉我们使用代理对象包装Drools所需的数据.您可以尝试使用Proxy-Object,其中将XML和一些方法放在一起.当Drools尝试评估代理对象时,实际上是在评估XML. 与Drools规范相比,这有点脏-因为对象在输入Drools的工作内存时不会保存数据,而是在询问时提取数据.

The expert told us to use Proxy-Objects to wrap the data we needed for Drools. You could try to use a Proxy-Object in which you put the XML along with some methods. When Drools is trying to evaluate the Proxy-Object it is infact evaluating your XML. This is a littlebit dirty - comparing to Drools specifications - since the Object would not hold the data when entered into the Working-Memory of Drools, but rather extract the data when asked.

我不是Drools的专家,但是我看到的唯一选择是像前面提到的那样水合POJO",根据Drools的说明,这是最好的选择.

I am no expert in Drools, but the only alternative I see, is to "hydrate a POJO" as you mentioned before, which would be best according to Drools specifications.

这篇关于在JBoss Drools中评估XPath表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆