从 Java 控制 Jython 脚本的执行
我试图从 Java 内部控制 Jython 脚本的执行,并通过调用 PythonInterpreter.exec() 来执行。 该脚本包含对 Java 中定义的类的调用。 为了在这里讨论,我将这些类称为“命令”。 这些命令还可以通过 RMI 在不同的计算机上运行。
由于命令需要一段时间才能完成,因此我想在调用方检查命令执行的进度,例如执行完成的百分比。 我可以为类提供 getProgress() 方法,但访问此方法似乎是不可能的,因为 PythonInterpreter 不允许调用者访问在其中运行的命令对象。
关于如何做到这一点有什么想法吗?
I'm trying to control the execution of a Jython script from within Java and executed through a call to PythonInterpreter.exec(). The script contains calls to classes defined in Java. I'll call these classes "commands" for the discussion here. The commands can also be run on a different machine via RMI.
Since the commands take a while to complete, I want to check the progress of the commands' execution on the caller side, like at what percentage of the execution is complete. I can provide a getProgress() method to the classes but accessing this method seems to be impossible to do because PythonInterpreter doesn't allow the caller access to the command object running inside it.
Any ideas on how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的 0.10 欧元:
(这并不容易)
中的描述构建一个工厂
按照http://wiki.python .org/jython/JythonMonthly/Articles/September2006/1
和表示脚本类 (IJScript) 的 Java 接口
(包括 run() 和 getProgress() 方法)
您的脚本应该如下所示:
在访问 IJScript 接口(Java 接口)时运行您的脚本
(看员工的例子)
my 0.10 Eur :
(ist not easy)
Build a Factory as descripted in
http://wiki.python.org/jython/JythonMonthly/Articles/September2006/1
and a Java-Interface that represents a script-class (IJScript)
(including run() and getProgress() methods)
your scripts should then look like this:
run your scripts in accessing the Interface IJScript (the Java Interface)
(look at the employee example)