我主要依赖为特定需求创建的自定义模块和函数。然而,我也在 DataWeave 中利用了 Mule 提供的许多内置函数,例如 upper 函数,它以大写字符返回提供的字符串,语法为 upper(text: String): String。
Mule 如何实现这一点?或者哪里可以找到这个函数的源码?
要查看 Anypoint studio 中 DataWeave 函数的实现,请使用 [CTRL] 按钮并 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包groupIdorg.mule.weave
artifactIdruntime
.