Server Smalltalk Guide
-
- The following section is intended for advanced developers who are going
beyond the default behavior the lightweight marshaler provides.
Normally, you will not need to know about or use these capabilities unless you
are optimizing performance or customizing behavior.
The lightweight marshaler uses much the same infrastructure ideas
(e.g., wrappers, strategies) as discussed above. As with
the Swapper marshaler, the sending of messages to the objects being marshaled
is controlled by a strategy object.
The lightweight marshaler uses a custom stream for marshaling
objects. The policies for marshaling objects onto this stream are
defined for standard base classes. For user-defined objects, specific
marshaling behavior can be altered when marshaling these objects onto the
stream through the use of the following API on all objects:
- sstMarshalInstVarAt: index
with: marshaler
- Answers the object to dump when @marshaler is trying to dump
the index--the instance variable of the receiver. Typically the
result is the object in that slot but you can override this method to filter
out slots etc.
- sstMarshalIterateOnto: stream
- Iterates over the receiver dumping each of its instance variables to
@stream. See also
sstMarshalInstVarAt:with: and
sstLoadFrom:register:.
- sstMarshalMaintainIdentity
- Answers true if the marshaling mechanism must maintain identity
for the receiver. Identity is maintained within the scope of the
current object set (object graph reachable from the root).
- sstMarshalReferenceOnly
- Answers true if the receiver can only be marshaled as a
reference.
- sstMarshalValueOnly
- Answers true if the receiver can only be marshaled as a
(shallow) value.
- sstReplacementWith: marshaler
- Answers the object to dump when @marshaler is trying to dump
the receiver. Typically, the result is the receiver itself but you can
override this method to vary that behavior.
Object loading behavior is defined by loaders. Typically, an
object's loader is its class. The default loading behavior is
defined in the behavior specified below. You can override this method
on particular classes as needed.
- sstLoadFrom: stream register:
flag
- Loads and returns the next object from @stream according to the
loading format defined by the receiver. Typically, the receiver will be
a class and will be able to load instances of itself and its
subclasses.
If @flag is true then ensure that the resultant
object is registered with @stream. Registering an object is
required to maintain object identity within a particular marshaled object
group. It is vital that the resultant be registered before any other
sub-objects.
As with the Swapper marshaler, the marshaling behavior is controlled by the
strategy. By plugging in a by-reference strategy, the lightweight
marshaler changes the messages it sends to objects (replace sst
with sstBR in the above API list) and dumps mutable objects as
references.
- Note:
- The behavior of the lightweight marshaler varies slightly from that of the
Swapper marshaler in that the Swapper maintains various low-level flags of the
objects dumped and loaded (for example, basicHash).
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]