如何访问 Mule 4 DataWeave 中内置函数的源代码或定义?

问题描述 投票:0回答:1

我主要依赖为特定需求创建的自定义模块和函数。然而,我也在 DataWeave 中利用了 Mule 提供的许多内置函数,例如 upper 函数,它以大写字符返回提供的字符串,语法为 upper(text: String): String。

Mule 如何实现这一点?或者哪里可以找到这个函数的源码?

dataweave mulesoft mule4
1个回答
0
投票

要查看 Anypoint studio 中 DataWeave 函数的实现,请使用 [CTRL] 按钮并 LMB 单击函数名称。

picture of Set Payload where to CTRL and LMB

例如上:

/**
* Returns the provided string in uppercase characters.
*
* === Parameters
*
* [%header, cols="1,3"]
* |===
* | Name   | Description
* | `text` | The string to convert to uppercase.
* |===
*
* === Example
*
* This example converts lowercase characters to uppercase.
*
* ==== Source
*
* [source,DataWeave,linenums]
* ----
* %dw 2.0
* output application/json
* ---
* { "name" : upper("mulesoft") }
* ----
*
* ==== Output
*
* [source,JSON,linenums]
* ----
* { "name": "MULESOFT" }
* ----
**/
fun upper(text: String): String = native("system::StringUpperFunctionValue")

你可以看到

native("system::StringUpperFunctionValue")
。函数
native
表示实现在jar或类文件中。具体来说,
system::StringUpperFunctionValue
StringUpperFunctionValue.class
位于maven包groupId
org.mule.weave
artifactId
runtime
.

© www.soinside.com 2019 - 2024. All rights reserved.