Server Smalltalk Guide : Building server applications : Distributed objects using application contexts
Distributed objects using application contexts
Tip icon
To better understand this section, examine the sample SstPingPongByReference.
The by-reference ping-pong classes provide several examples of using and setting up application contexts. The methods below summarize the steps needed to set up the application contexts for your application.
context
^SstApplicationContext
contextNamed: 'PingPong'
ifNone: [SstApplicationContext createContextNamed: 'PingPong']
setupPing: ping pinging: pong
self context
addSpace: #ping at: (Array with: (self urlFor: ping));
addSpace: #pong at: (Array with: (self urlFor: pong));
setupFor: #ping using: SstSpaceConfiguration proxyConfiguration;
startUp
cleanUpPingPong
self context clear
First, a context is allocated. The system automatically manages the set of existing contexts by name. The context method looks up ping-pong's context under the name PingPong and, if none is found, creates and installs one. This method is called from setupPing:pinging:.
Once you have a context, you add the known spaces. The order of adding spaces is not important. Each space is defined to zero or more endpoints, specified as a collection of URLs. You can add additional remote spaces and URLs at any time.
After adding the desired spaces the context can be set up. Setup is done by specifying the name of the local space and a configuration object to use in building that space. The only restriction on this operation is that the space specified as the local space must have been added before the context is set up.
A context which has been set up can then be started. Sending startUp to the context builds and initializes all the SST components and starts them running. Once this has completed the system is ready to run your application.
Shutting down a context can be done either with shutDown or clear. Both operations stop all SST resources controlled by the context. shutDown leaves the context partially configured such that it can be restarted using startUp. clear completely wipes the context and all its contents clean. Components that have been sent clear cannot be restarted.
Last modified date: 04/20/2020