Remote references
Object handles are useful as global identifiers of objects but do not present you with a transparent view of the referenced objects. Methods must be written with an explicit understanding that certain variables and arguments are remote objects and do not implicitly respond to normal protocols. Remote references, on the other hand, transparently forward all received messages to the remote objects indicated by their embedded object handle. You can use exactly the same message sends they would use if you were programming only with local objects.
Since remote references are transparent, the issue of object identity is raised. To maintain the view that remote references are just like local objects each remote object is uniquely represented locally by one and only one remote reference object. This correspondence is maintained by the space's import set. Once an object handle has been imported and a corresponding remote reference created, subsequent imports of the same remote object are replaced with the same local remote reference object--identity is maintained and operations such as == behave as expected.
Since remote references are designed to forward all messages, there is little API required. Class methods for SstRemoteReference provided as API are:
export: object in: space
Answers an instance of the receiver which is the remote representation of @object in @space. @object can be either a import key or an object. If it is an object then its export key is looked up in @space.
for: object in: space
Builds and returns a new instance of the receiver for the object identified by @object in space @space.
The following instance API methods are also provided:
sstIn: space
Answers a reference to the remote object in @space whose ID is the receiver. @space must be an actual space as opposed to just a space name.
sstIn: space context: context
Answers a reference to the remote object in @space in @context whose ID is the receiver. If @context is nil then @space must be an actual space. If a real context is provided then @space can be either a space from that context or the name of a space in that context.
sstIsRemote
Returns true to indicate that the receiver is a reference to a remote object.
sstIsValid
Returns true if the receiver is a valid reference. That is, that the local representation of the space containing the receiver is still valid.
sstSpace
Returns the space which contains the object represented by the receiver.
Despite their transparency, there are a few places remote references cannot be used. The most significant being as arguments to primitives which either directly access instance variables or the class slot of their arguments. Since remote references are only representations of the actual remote object, they will not have the format (slots and so on) expected by the primitive and the results could well be catastrophic.
Do not change the shape of a remote reference while instances of that remote reference exist in the system!
Remote references (and other instances of subclasses of nil) should never be put directly in the Smalltalk dictionary or in class or pool variables. While this may appear to work while your distributed system is up and running, various parts of the normal Smalltalk infrastructure scans these objects (Smalltalk compiled methods) and sends them messages such as isClass which are not appropriate for general implementation on remote references.
Last modified date: 01/29/2015