Java:在应用程序中嵌入脚本引擎:JSR 223 (ScriptEngine) 仍然是一个好的解决方案吗?
我想在我的 Java 应用程序中使用一种或多种脚本语言。
从JRuby网站我发现有3种方法:
- 使用Java 6(使用JSR 223:脚本)
- 嵌入 Bean 脚本框架(BSF)
- 直接调用 $YOUR_SCRIPTING_ENGINE$ API
由于我需要支持超过 1 个脚本引擎,我认为选项 3 不够好。
在寻找解决方案 1. JSR 223: Scripting 时,我开始寻找包含所有脚本引擎集成的 zip 存档,
Download and unzip the collection of jars from the documents and files section of the site (jsr223-engines.tar.gz or jsr223-engines.zip).
但该文件在网上找不到(项目主页 是空的。如果我愿意,我可以下载源代码并构建我需要的引擎集成。源代码看起来很旧(我所看到的
已经有 2 年多了) JSR 223 仍然存在并且是一个好的解决方案可供选择吗? 如果不是,Bean 脚本框架是一个不错的选择吗?最后一个的文档页面非常差,并且只支持少数脚本语言(但它支持我想要的大多数语言)...
I want to use one or many script languages in my Java application.
From JRuby website I found that there are 3 ways:
- Using Java 6 (using JSR 223: Scripting)
- Embedding with Bean Scripting Framework (BSF)
- Directly calling $YOUR_SCRIPTING_ENGINE$ APIs
As I need to support more than 1 script engine, I don't think option 3 will be good enough.
When looking for solution 1. JSR 223: Scripting, I start to look for the zip archive containing all script engine integration
Download and unzip the collection of jars from the documents and files section of the site (jsr223-engines.tar.gz or jsr223-engines.zip).
But this file is nowhere on the net (dowload section of project home is empty. If I want I can download the sources and build my needed enngines integration. Sources code are looking old (2+ years for what I saw)
Is the JSR 223 still alive and a good solution to choose?
If not is the Bean Scripting Framework a good alternative ? This last have a very poor documentation page and only few script languages are supported (but it is supporting most of the language I want to have)...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已将沙盒 Rhino 嵌入到几个应用程序中,发现直接使用 Rhino 代码要容易得多。
除非您想要嵌入多种不同的语言或者想要在已经安装了 JSR 223 jar 的虚拟机上进行部署,否则我认为您不会从额外的抽象层中受益匪浅。
我强烈建议您在选择嵌入语言时考虑沙箱的易用性。
I've embedded sandboxed Rhino in a couple applications and found it much easier to just work directly with the Rhino code.
Unless you want to embed multiple different languages or want to deploy on VMs that already have JSR 223 jars in place, then I don't think you'll benefit much from the extra layer of abstraction.
I would strongly suggest, that you take ease of sandboxing into account when choosing a language to embed.