RMI编组和序列化 [英] RMI marshal and serialization

查看:69
本文介绍了RMI编组和序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用RMI封送从远程类返回的对象的Java中,您只需要在该对象上实现Serializable?我有一个类节点,里面有要返回的变量.我只是实现可序列化吗?如果是这样,接收该对象的类又如何呢?它的类也需要实现可序列化吗?

In java using RMI to marshal an object that you are returning from the remote class do you just need to implement Serializable on that object? I have a class node with variables inside that i want to be returned. Do i just implement serializable? If so what about the class that is receiving the object? does its class need to implement serializable too?

示例:

public class node implements Serializable{
//variables
//variables
public node(//arguments to constructor here){

}

}

推荐答案

我不确定我是否正确理解了您的问题,但是...如果可序列化的类具有其他对象作为成员变量,则最好将它们设为也可以序列化,否则最好声明为要跳过的瞬态.这能回答您的问题吗?

I'm not sure whether I understand your question correctly or not, but ... if the serializable class has other objects as member variables, then better make them serializable also, otherwise better declare as transient to skip. does this answer your question?

如果代码检查器程序很方便,您可以在不发布该问题的情况下很快找到该问题的答案

if code inspector program is handy, you can have answer for such question very quickly without posting it

对于您的技巧,只有要保留或转移的对象才需要实现Serializable,因此可以通过序列化/反序列化将对象重构为类结构

for your tip, only the object you wan to persist or transfer needs to implements Serializable, so the object can be reconstructed as the class structure through serializing/unserializing

这篇关于RMI编组和序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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