Disteributed objects and data encoding
Memory allocation vor Java variables and objects instances
Method call as a message - or two messages: the call message and the return-result message
Message encodings
Messages transmitted over a network (exchange between the memories of two computers): message is a sequence of bits
- Ad-hoc encoding: An example - TCP packet
- Systematic object encoding: the message represents an instance of an object (with attributes - message parameters, possibly nested objects as parameters)
- Java serialization (if interested, see http://download.oracle.com/javase/6/docs/technotes/guides/serialization/index.html )
- XML
- JSON (JavaScript Object Notation)
- CORBA
- History:
- one of the first was used around 1980 for a distributed mail system build by Xerox-Park
- standardized version ASN.1 (in the context of OSI) - around 1983)
- There is the interesting problem of how to represent these objects in the programming language of the sending or receiving program. Java serialization is only used with Java. However, the other encoding schemes can be used with different programming languages.
- CORBA defines an abstract language IDL (interface definition language) for defining object types (classes). The CORBA support provides automatic transition from such data type definitions into data structure definitions in different programming languages. If these representations are used in the programs, the encoding and decoding routines for CORBA messages are also automatically generated by the CORBA support tools.
Remote Procedure Call (RPC)
The idea is that method invocations on remote objects can be programmed like method invocations on objects that are local within the same program.
To make the calling program largely independent of the questio whether the called object instance is local or remote, one uses a local proxy object in the case that the called object is remote. The proxy object has the same interface and when a method of the proxy object is called, it send a message including the call parameters to the remote object; the latter executes the method and when it returns, the environment of the object, called sceleton, returns a message with the return parameter to the proxy object, which now returns to the calling program.
One needs some form of directory service where a valid pointer to a remote can be found (the first one to be called by an application). Note that the call parameters and return parameters may include copies of object instances, or valid remote references to objects. These remote references include information about where these objects reside.
More details
The most important RPC standards are the following:
- Java RMI (using Java serialization)
- Web Services: SOAP (using XML)
- JSON-RPC used for JavaScript clients communicating with a server (messages encoded in JSON)
XML (additional information for the curious reader)
- Introduction
- XML allows the construction of complex data structures. It is therefore important to also be able to defined data types and have a method by which one can check that a given instance of a data structure has all the properties defined by a given data type definition. Such a method is implicitely given my the programming environment of any strongly typed programming language, e.g. Java. For XML data structures, the following notations for defining data types have been created:
- DTD: The SGML notation for writing a Document Type Definition (DTD) (for example, see recipee example in "XML for the absolute beginner")
- XML Schema: a more elaborate notation (which is written in XML).
- UML Class Diagram: In the context of UML, a meta-model defines the concepts of a language; the meta-model is written in the form of a Class Diagram showing classes (the concepts of the language) and their relationships. An instance of a UML model is often stored (and exchanged) in the form of a XML-encoded file, using the so-called XMI format. Tools exist that are able to create an XML Schema for the XMI format of a language from the meta-model Class Diagram of the language.
- There are programing frameworks and tools that generate code for performing XML encoding and decoding for specific data structures. You will see one in Lab 11.
- Note: Only the basic aspects of XML are part of this course.
Last update: April 5,
2016