Object spaces
Typically in Smalltalk, all objects are local; they live in one running image and are processed by one virtual machine. With the introduction of remote messaging comes the notion of remote objects and the need for an addressing alternative to the standard memory address used by the local virtual machines.
Object spaces represent a home for objects. Essentially they manage a namespace and expose the names to objects in other object spaces thus allowing inter-space references. In the simplest case (with SstSimpleObjectSpace) the name assigned is just a simple key such as a number or symbol. Exporting an object is the act of assigning a key to an object. Objects used as export keys must conform to the IuSstExportKey interface, which defines the following protocol:
sstIsExportKey
Returns true to indicate that the receiver is a valid export key. Note that the receiver must be an immutable object. (See sstImmutable).
Objects referenced using this simple key are not globally unique in and of themselves. In combination with an invocation handler, however, they do uniquely specify an object. If used as the receiver of a request, invocation handlers will correctly resolve the key and replace it with the associated object.
This sort of export key is typically used in client-server applications. For example, a server would export its services by locally unique keys (such as DatabaseServer or http) and clients construct and send messages to these services specifying the export key as the message receiver.
Objects spaces provide the following API for explicitly managing exported objects:
export: object
Ensures that @object is externally known. If @object is not already exported, automatically generates an export key. Returns the export key used.
export: object as: objectId
Makes @object externally known as @objectId. Overwrites any existing mapping for @objectId. Returns @object.
exportIdFor: object
Answers the ID under which @object is exported. Answers nil if @object has not been exported.
objectExportedAs: key
Returns the object which has been exported using @key in the receiver. If @key is not found, returns nil.
objectExportedAs: key ifAbsent: absentHandler
Returns the object which has been exported using @key in the receiver. If @key is not found, returns the result of evaluating @absentHandler.
 
resolve: key ifAbsent: absentHandler
Returns the object exported by the receiver using @key. If @key is not found, returns the result of evaluating @absentHandler.
unexportId: key
Removes any mapping for @key from the export list of the receiver. Returns the object exported as @key or nil if none exists.
unexportObject: object
Removes any export mapping with @object as the value. Returns @object or nil if it cannot be found in the receiver.
Object handles are a more general exporting mechanism where objects are exported as {object space, object ID} pairs. Assuming that the object space IDs are globally unique (within some application context) and the spaces manage their namespace such that each object has a locally unique name, these pairs are globally unique (within that application context). The object-to-object handle mapping is maintained by the export set of each object space. When an object is passed by reference out of a space, it is replaced in the outgoing message by its globally unique object handle.
More sophisticated object spaces also have an import set which maintains a mapping from object handle to local representation (for example, proxy). This ability is essential for maintaining object identity. The same handle passed twice to the same object space will resolve to the same physical object in that space. Object spaces support the following API for managing the collection of imported objects:
import: handle as: object
Makes the external @object internally known as @handle. Overwrites any existing mapping for @handle.
import: handle as: object for: importer
Makes the external @object internally known as @handle. Overwrites any existing mapping for @handle.
objectImportedAs: key
Returns the object which has been imported using @key in the receiver. If @key is not found, returns nil.
objectImportedAs: key ifAbsent: absentHandler
Returns the object which has been imported using @key in the receiver. If @key is not found, returns the result of evaluating @absentHandler.
resolve: key ifAbsent: absentHandler
Returns the object imported by the receiver using @key. If @key is not found, returns the result of evaluating @absentHandler.
unimportHandle: key
Removes any import mapping with @key as the key. Returns the object imported as @key or nil if none exists.
unimportObject: object
Removes any import mapping with @object as the value. Returns @object or nil if it cannot be found in the receiver.
Last modified date: 01/29/2015