The Externalization Service
Authors
- Günter Karjoth, IBM Zurich
- Michael Steiner, IBM Zurich
Check out the
Implementation Architecture, Design
for additional details related to Externalization.
Externalization Service Description
The externalization service specification defines protocols and
conventions for externalizing and internalizing objects.
Externalizing an object is to record the object state in a stream of
data. Objects which support the appropriate interfaces and whose
implementations adhere to the proper conventions can be externalized
to a stream (in memory, on a disk file, across the network, etc.) and
subsequently be internalized into a new object in the same or a
different process. The externalized form of the object can exist for
arbitrary amounts of time, be transported by means outside of the Java
process, and can be internalized in a different Java process.
Externalizing and internalizing an object is similar to copying the
object. The copy operation creates a new object that is initialized
from an existing object. The new object is then available to provide
service. Externalization, on the other hand, does not create an
object that is initialized from an existing object. Externalization
"stops along the way". New objects are not created until the stream
is internalized.
Usage
Client TargetStream Streamable
O O
| new |
|---------------> O |
| | |
|writeObject(Object)| |
|------------------>| |
| | |
| | writeObject() |
| |---------------------> |
| | |
| | |
| | write<type>(); |
| |<--------------------- |
| | |
| | writeObject(Object) |
| |<----------------------|
| | |
An object implementing the Streamable interface can use the
following helper methods of class TargetStream to write scalar values of
type = Boolean, Byte, Char, Double, Float, Int, Long,
Short, UTF.
Client SourceStream Streamable
O
| new
|--------------->O
| |
| readObject() |
|--------------->|- - - - - - - - - - - -> O
| | |
| |readObject(SourceStream) |
| |-----------------------> |
| | |
| | |
| | read<type>(); |
| |<----------------------- |
| | |
| | readObject() |
| |<------------------------|
| | |
Version 2 supports following object classes:
- Boolean, Character, Double, Float, Integer, Long, String
- any object class implementing the Streamable interface
- Vector if its elements are as above
Class TargetStream provides a number of class methods to compute
the size of the flattened image of an object (in bytes):
- sizeOfBoolean(), sizeOfChar(), sizeOfDouble(), sizeOfFloat(),
sizeOfInt(), sizeOfLong()
- sizeOfObject(Object o)
Method sizeOfObject() works only for objects which are either
of class String and Vector or implement the Streamable
interface providing method myStreamSize().
Attention:
The TargetStream constructor writes a header to the stream
that will be read by the corresponding SourceStream
constructor. The size of the header is 1 byte.
Relationship to Other Services
- Used by Communication Manager
- Used by Archive Manager
- ...
Documentation
Issues
- Is there a need to support Array externalization ?
- Livelock on composite objects with circular structure
- Objects with more than one incoming pointer will be duplicated.
Delivery Dates
- March, 1996 (version 1)
- May 28, 1996 (version 2)