在之前的文章里,介绍了OMG的复杂DMN的例子.其中Recommended Loan Products.7z这个例子是最复杂,场景跟真实.其中有个很在意的点是居然可以调用java代码

这里第一行是创建一个函数, 名字叫string fromat, 函数两个参数.返回值是any
实际的处理是调用的 java的 String类,的public static方法. 具体可以
E:\Program Files\Java\jdk-11.0.15\bin> .\javap.exe -s java.lang.String
看到,每个函数的签名.
OMG给的解释是
The class-name SHALL be the string name of a Java class on the classpath. Classpath configuration is
implementation-defined. The method-signature SHALL be a string consisting of the name of a public static method in the
named class, followed by an argument list containing only Java argument type names. The argument type information
SHOULD be used to resolve overloaded methods and MAY be used to detect out-of-domain errors before runtime.
所有就有个想法,应该是可以调用自定义的类的.
如下是一个错误的尝试:
然后看

本文档详述了一位开发者如何在DMN中调用自定义Java代码,通过创建函数并利用Java类路径实现。过程中遇到了部署到kie-server时类找不到的问题,最终通过将自定义代码打包为Maven依赖并重启kie-server服务解决。文章强调了只能调用public static方法的限制,并指出未来可能引入更多依赖以扩展功能。
最低0.47元/天 解锁文章
1万+





