Crisp Reading Notes on Latest Technology Trends and Basics

Archive for the ‘Misc Technical’ Category

Java Remote Object Model

Java Remote Object Model

MS-Word format on this page



These notes assume the Reader is familiar with the “Remote Procedure Call – RPC” model.

  • The discussion centers around how to provide a “Distributed Object Model”.

Object Features

  1. Remote Method Invocations
    • Method invocations on objects across different JVMs
  2. Object Class Methods
    • The methods of the Object class – equals, hashCode, toString, clone, finalize
  3. Remote access and faults
    • Throwing RemoteException
    • Dynamic stubs and proxies

Remote Method Invocation Model

Interfaces and Objects

  1. Java has interfaces and objects
  2. For Remote invocations, Java defines RemoteInterface and RemoteObject classes.
  3. All clients are expected to use the Remote, or an interface extended from it.
    • This is a marker interface to convey that remote calls need to be invoked on the same
  4. The servers implement “Remote Objects” by extending RemoteObject class.

Stubs and Serialization

  1. For every call that is made, stubs on the client side
    • convert the object-calls to network protocol and vice-versa
  2. To allow for generic stubs to be written,
    • Java defines a standard Object Serialization format, to convert to the wire and vice-versa

Dynamic Stubs

For consistency between the server version and the server stubs,

  • The Java class-loader can load the stubs from an external URL. This could be the RMI server

Remote Exceptions

Every Remote Method must be declared to throw a RemoteException

  • This is to handle when there is a communication failure across systems.

Object Implementation

All Object methods need to be revisited for re-implementation under the new “Distributed Object Model”.

getClass Returns the stub-class. Requires no changes
hashCode Re-implemented to hash the ReferenceId – not “Content based”This is done to avoid a RPC for performance and integration reasons
equals Re-implemented to hash the ReferenceId – not “Content based”This is done to avoid a RPC for performance and integration reasons
clone Implemented to clone the reference
wait Lock on the local objectObject on server can be accessed by different clients
notify Unlock on local object
notifyAll Unlock on local object
toString Objectifies the string reference

Internationalization in a Internet Environment


Document Encodings

HTTP Responses

  • HTTP responses usually contain a “Content-Type: xxxx; charset=yyy”
    • Based on the charset, the encoding can be inferred
  • This requires the WebServer to either
    • know the encoding up-front,
    • or to understand it by reading a bit of the document
  • A XML document always begins with <?xml encoding=”…”>
  • A HTML document would have this as part of its meta-tag itself

In the Document itself

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”>

Browser Inferring the Encoding

  • For many encodings, the browser tries to infer the encoding from the distribution of characters
  • This applies for variants of the Code-page encodings
    • Each language gets its own set of mappings, that have their own distributions in typical documents
    • If the browser did not get it right, we just change the encoding manually on the browser, and read the document.

URL Encodings

  • The URL encodings are relevant in two places
    • As the URL in the HTTP request ( Both GET and POST )
    • For posting the contents of the form
  • The encoding for URLs is
    • Convert to UTF-8 first
    • Then, replace all reserved characters with their %-escaped sequences
    • Other sequences may also be %-escaped.
  • During form-submit, the payload could be www-form-url encoded.
    • This also follows the URL encoding rules for the most part.

UTF Encodings

UTF encodings have the following interesting features that make them very good encodings

  1. The beginning of a character has a zero in the first bit or  11 in the first two bits
    • This makes it easy to synchronize the bytes
    • The number of bytes occupied is specified by the number of Contiguous 1s in the first byte.
  2. This makes it easy to skip over this character and move to the next
    • Also, it clearly shows what kind of UTF encoding is being used (JSON)

Tag Cloud