Java:强大的代码移动性如何? [英] Java: Strong Code mobility How to?

查看:104
本文介绍了Java:强大的代码移动性如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何将Java用于强大的代码移动性吗?你以前做过吗?

Does anyone know how to use Java for Strong code mobility? Have you ever done it before?

这就是我想要达到的目标.

Here's what I try to achieve.

假设我们有2个独立的Java应用程序,它们通过网络进行通信. App A和App B.

Suppose we have 2 separate Java applications that communicate over network. App A and App B.

App A具有实例化为对象的类x,并且一直在使用它. App B没有此类x的先验知识.

App A has a class x instantiated as an object, and has been using it. App B has no prior knowledge of this class x.

应用A需要将类x的实例迁移到应用B.应用B应该能够动态加载类x,并保留类x的 state

App A needs to migrate the instance of class x over to App B. App B should be able to dynamically load class x, and retains the state of class x.

我在Google周围搜索,找到了大量关于如何在运行时动态加载类的资源.但是,我不确定是否涵盖了通过网络传输对象实例及其状态并动态调用它的机制.

I have Googled around and found a bunch of resources on how to dynamically load class at run-time. However, I'm not sure if the mechanism of transferring an object instance over network along with its state, and to invoke it dynamically is covered.

任何指针都将非常有帮助,在此先感谢您!

Any pointers would be very helpful, and thank you in advance!

注意::我最感兴趣的是如何(即方法,思维方式)解决了这个问题,而不是什么用于解决这个问题;这是因为我的任务是提出自己的解决方案来解决此问题.尽管指出库/框架很棒,但是如果从以前做过这样的事情的人那里发布答案(那是罕见的),那将是理想的选择.

NOTE: I'm mostly interested in how (i.e. the approach, way to think) this problem is solved, not what is used to solve this; this is because I'm tasked to come up with my own solution to solve this problem. Though pointing out libraries/framework is great, it would be ideal if answers are posted from people who have done something like this before (however rare).

推荐答案

您要求强大的移动性,但是您需要通过弱移动性来满足您的要求,RMI协议提供了一些限制. RMI不仅支持RPC,对象序列化和分布式对象图,而且还支持通常使用的代码共享,以便客户端可以加载仅服务器已知的类的字节码,并在本地执行该字节码.

You ask about strong mobility, but your requirements are fulfilled with weak mobility, which with some limitations is provided by the RMI protocol. RMI does not only support RPC, object serialization and distributed object graphs, but also code sharing usually used so that the client can load the bytecode of classes only known to the server and execute that bytecode locally.

Java不支持强大的移动性,如果不对VM进行专有扩展,我想不出一种实现它的方法.从本质上讲,Java上下文中的强大移动性意味着您可以在一个VM中挂起或暂停一个线程,将可从该线程访问的所有对象实例,执行所需的字节码以及内部线程st(调用堆栈等)传输到不同的VM,并使其重新创建线程状态,并在原始VM中线程被暂停的位置继续执行.

Strong mobility is not supported by Java and I can't think of a way to implement it without making proprietary extensions to the VM. Essentially, strong mobility in a Java context would mean that you suspend or pause a thread in one VM, transfer all object instances reachable from that thread, potentially bytecode required for the execution and the internal thread st (call stack, etc.) to a different VM and make it recreate the thread state and continue execution at the point where the thread was paused in the original VM.

这篇关于Java:强大的代码移动性如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆