发布日期:2014-07-29 14:06:44

定义和摘要

Marshalling & Unmarshalling 常被翻译为列集和散集。 文字有点生硬。功能有点类似序列化和反序列化。有如下定义方式:

列集:将堆栈中的参数串行化送入一个平面(flat)存储器的过程。
散集:从flat读取参数数据,并且重建这个堆栈的过程。

wiki中这样解释列集:

In computer science, marshalling or marshaling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission, and it is typically used when data must be moved between different parts of a computer program or from one program to another. Marshalling is similar to serialization and is used to communicate to remote objects with an object, in this case a serialized object. It simplifies complex communication, using custom/complex objects to communicate instead of primitives. The opposite, or reverse, of marshalling is called unmarshalling (or demarshalling, similar to deserialization).

RFC2713中有段描述marshal的字段,如下:

 To "marshal" an object means to record its state and codebase(s) in  such a way that when the marshalled object is "unmarshalled," a copy  of the original object is obtained, possibly by automatically loading  the class definitions of the object.  You can marshal any object that  is serializable or remote (that is, implements the java.rmi.Remote  interface).  Marshalling is like serialization, except marshalling  also records codebases. Marshalling is different from serialization  in that marshalling treats remote objects specially. If an object is  a java.rmi.Remote object, marshalling records the remote object's  "stub" (see RFC 2713 Section 2.5), instead of the remote object itself.  Like  serialization, when an object is marshalled, the entire tree of  objects rooted at the object is marshalled. When it is unmarshalled,   the tree is reconstructed.

应用场景:

Marshal和Unmarshal应用的场景比较多,较多出现在程序间通信和远程通信的相关技术中。如

参考文档:

  1. RFC 2713​
  2. Marshalling (computer science)
  3. JAXB

发表评论