SST provides some infrastructure for managing access to objects in general and remote references in particular. The concept of a naming service is a familiar one, allowing you to associate arbitrary objects with names. File systems are a common example of a naming service, where the objects are files, within a hierarchical structure of named directories. The SST naming service facilities adopt the same API protocol as CORBA's CosNaming services, using the standard IDL-to-Smalltalk mapping for operations.
The benefit of using a naming service in a client-server environment is that only a single object--the naming service itself--needs to be made available by the server. Individual services the server supports are then bound to particular names within the naming service. Clients know either the name of the service in which they are interested or how to navigate the naming service itself. Given some name, the naming service resolves the name and answers the associated object.
In SST, a naming service is an instance of SstNamingContext, which contains bindings from instances of SstName to arbitrary objects. Strings are mapped to an instance of SstName using the following protocol:
The same protocol is provided by the class method nameFrom: in SstNamingContext. The basic API of SstNamingContext is:
The list:bl:bi: operation sets the @bindingListHolder object value to collection of SstNameBinding objects, where each object contains both a name and a type, indicating whether the object bound to the name is a naming context or an actual object. The @bindingIteratorHolder object value is set to an instance of SstNameBindingIterator if there are any more bindings left. This object supports API to progressively obtain more name bindings.
The following code illustrates creating a naming service within SST, creating a name myNames for another naming service and binding a new naming context to that name in the naming service. Then another name example.txt is created, and a string bound to that name within the naming context myNames. Note that myNames/example.txt is an example of a compound name, where all components but the last are expected to refer to existing naming contexts discovered by navigating through the naming hierarchy of the naming service itself. The naming service is then asked to resolve the name myNames/example.txt, and finally to unbind the binding for that name. The doit returns the example text object previously bound within the naming service.
| namingService serviceName name exampleText | namingService := SstNamingContext new. serviceName := SstName from: 'myNames'. namingService bindNewContext: serviceName. name := SstName from: 'myNames/example.txt'. namingService bind: name obj: 'This is an object in myNames'. exampleText := namingService resolve: name. namingService unbind: name. ^exampleText