RMI有哪些优点和缺点?
答案 0 :(得分:12)
优点和缺点类似于任何类RPC(远程过程调用)系统。简洁的表面外观,因为事实上遥远的物体可以被视为本地的。
这对简化编程似乎是一个很大的好处,但是有隐藏的成本。分布式系统存在延迟问题以及程序员必须意识到的部分故障的可能性。远程方法的调用受到安全性,延迟问题,网络故障等的潜在故障的影响。对这些问题进行论文可能会给可靠性带来灾难。
Waldo et al.对这些问题进行了很好的讨论。
答案 1 :(得分:5)
根据我的经验:
优点:
您可以实现两个类似的接口:
常见任务界面:
public interface Task<T extends Serializable> extends Serializable {
T execute();
}
Rmi界面:
public interface RmiTask extends Remote {
<T extends Serializable> T executeTask(Task<T> task) throws RemoteException;
}
服务器端的 RmiTask
实现:
public class RmiTaskExecutor implements RmiTask {
public <T extends Serializable> T executeTask(Task<T> task) {
return task.execute();
}
}
客户Task
实施示例:
public class IsFileTask implements Task<Boolean> {
final String path;
public IsFileTask(String path) {
this.path = path;
}
public Boolean execute() {
return new File(path).isFile();
}
}
缺点:
method()
上调用PassedObject
,但是奇妙的客户端可以覆盖此方法并执行无论他想要什么...... Callable
中并使用定义的超时运行它们。)答案 2 :(得分:0)
优势
Minimizes the complexity of the application.
Preserves type safety.
Distributed garbage collection.
Minimizes the difference between working with local and remote objects.
Java developers may already have experience with RMI
Existing systems may already use RMI - the cost and time to convert to a new technology may be prohibitive
Security for client and servers
缺点
Tied only to platforms with Java support
Security threats with remote code execution, and limitations on functionality enforced by security restrictions
Learning curve for developers that have no RMI experience
Can only operate with Java systems - no support for legacy systems written in C++, Ada, Fortran, Cobol, and others
Proprietary protocol by single vendor
Requires RMI-lookup
Requires non-standard port
我们可以写很多其他的东西,但我想写主要的东西。