Objects by Value

The ORB compilers and runtime provide standard support for passing Java objects by-value over newly defined RMI-IIOP standards from OMG. An argument to, or a return value from, a remote object can be any Java type that is serializable. This includes Java primitive types, and Java objects that implement the java.io.Serializable interface. In fact, in the Hello World application we have already seen the use of objects by value since a String is a Serializable object.

In this section we will see examples for passing already defined serializable objects, writing serializable objects with default and custom serialization, and passing remotes inside serializable objects.

Object Meta Data Example

In this example we will ask a Component remote object for its MetaData object. On the metadata object we will invoke methods to set/get arbitrary serializable java.lang.Objects as properties. The example demonstrates using JDK supplied serializable classes as well as writing application sepecific objects to be passed by value.

Custom Marshaling

A serializable object can provide its own readObject and writeObject methods that allows the class to control the serialization of its own fields. In this example we will look at the implementation of java.util.Hashtable which uses custom serialization. We will then send the hash table objects betwen client and server.

Passing Remote Objects inside Value Objects

A serializable object can contain Remote implementation objects. For simple transient objects (non POA case) ORB runtime automatically converts these Remote implementation objects into corresponding stubs before marshaling them out. In this example, we will return an Vector from the server to the client that will contain references for several objects that satisfy a query.

IDL Linked List Value Type Example

So far we have used Java RMI to express interfaces for value objects and have used RMI-IIOP to send/receive value objects. In this example, we will use IDL to define a LinkedList value type and write server interface also using IDL.



Copyright © 2003, 2004 Novell, Inc. All rights reserved. Copyright © 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.