1.About Stub:
java.rmi.server.RemoteStub is a class that implements the Serializable interface. The RMI serialization mechanism knows that whenever a remote server is "sent" over the wire, the server object should be replaced by a stub that knows how to communicate with the server (e.g.,a stub that knows on which machine and port the server is listening).Calling Naming.rebind( ) actually winds up passing a stub to the RMI registry.
When clients make calls to Naming.lookup( ), as in the following code snippet, they also receive copies of the stub. Since the stub is serializable, there's no problem in making a copy of it.
2. About serialVersionUID:
serialVersionUID: serialization detects Class Change.
serialVersionUID doesn't have to be private. However, it must be static, final, and long.
Setting serialVersionUID is a simple, and often surprisingly noticeable, performance improvement. If you don't set serialVersionUID, the serialization mechanism has to compute it. This involves going through all the fields and methods and computing a hash. If you set serialVersionUID, on the other hand, the serialization mechanism simply looks up a single value.
An important point is that you can decide whether to implement Externalizable or Serializable on a class-by-class basis. Within the same application, some of your classes can be Serializable, and some can be Externalizable. This makes it easy to evolve your application in response to actual performance data and shifting requirements. The following two-part strategy is often quite nice:
· Make all your classes implement Serializable.
· After that, make some of them, the ones you send often and for which serialization is dramatically inefficient, implement Externalizable instead.
This gets you most of the convenience of serialization and lets you use Externalizable to optimize when appropriate.
Experience has shown that, over time, more and more objects will gradually come to directly extend Object and implement Externalizable. But that's fine. It simply means that the code was incrementally improved in response to performance problems when the application was deployed.
Note: Serialization mechanism is deep copy, so, the class will be serialized should be as 'thin' as possible.
分享到:
相关推荐
java rmi java rmijava rmi javajava rmi java rmi rmi
RMI简单实例RMI简单实例RMI简单实例
Java implementation of RMI
完整的Rmi调用示例,极难得的Rmi应用示例
rmi的详细例子,rmi的详细用法,一看就懂
RMI 规范 RMI 详细介绍 共10章
RMI教程 Java RMIRMI教程 Java RMIRMI教程 Java RMIRMI教程 Java RMIRMI教程 Java RMI
rmi小程序,RMI文档,为RMI初学者使用
RMI远程方法调用RMI远程方法调用RMI远程方法调用RMI远程方法调用RMI远程方法调用
《Java RMI》一书的英文版本,With Java RMI, you'll learn tips and tricks for making your RMI code excel. This book provides ... In short, a treasure trove of valuable RMI knowledge packed into one book.
Spring-RMI (RMI调用, HTTP调用) 本人测试过了
1. Unpack RMI.rar and put the package "features" and "plugins" under the package "net.genady.rmi_2.0.2.1" to <%eclipse%> directory; 2. Copy rmi.jar and lic.jar under the package "crack" to ...
java RMI
spring RMI 简单例子
Weblogic Server与RMI RMI的使用介绍
java rmi上传文件 在这次的项目中,对于客户端与服务器之间的通信,想了许多办法,由于做的是富客户端应用,最终将技术选定在了RMI和Java-sockets两种之间,其中RMI的灵活性不高,客户端和服务器端都必须是java编写...
web服务器 RMI meeting sokect
本项目使用socket直接发送数据包来攻击rmi,通过反序列化攻击rmi,双击直接运行,对1099端口的rmi服务直接进行漏洞检测。
Java编程rmi实例,给出远程方法调用技术在java方面的具体例子。
SpringRMI小例子代码,仅供参考。SpringRMI小例子代码,仅供参考。