Check out the new USENIX Web site. next up previous
Next: Consequences. Up: Protocol Algorithms as Strategies Previous: Protocol Algorithms as Strategies

Strategy/Context Interactions.

Figure 3 (a) sketches the way protocol objects and algorithm objects interact. On the left side, protocol object atex2html_wrap_inline777 Object offers the services it inherits from its superclasses, as well as the new services that are specific to protocol tex2html_wrap_inline777. The actual algorithm implementing protocol tex2html_wrap_inline777 is not part of atex2html_wrap_inline777 Object's code: instead, the latter uses services provided by strategy atex2html_wrap_inline777 Algo (on the right side of Figure 3 (a)). Whenever an operation related to protocol tex2html_wrap_inline777 is invoked on atex2html_wrap_inline777 Object, the execution of the protocol is delegated to strategy atex2html_wrap_inline777 Algo. In turn, the services required by the strategy to run protocol tex2html_wrap_inline777 are based on the inherited services of context atex2html_wrap_inline777 Object. Such required services merely identify entry point operations to underlying protocols needed to solve problem tex2html_wrap_inline777.

  figure135
Figure 3: Strategy pattern in BAST

Each instance of class tex2html_wrap_inline777 Algo represents one execution of protocol tex2html_wrap_inline777 implemented by that class, and holds a reference to the context object for which it is running; any call to the services required by the strategy will be issued to its context object. There might be more than one instance of the same ProtoAlgo's subclass used simultaneously by atex2html_wrap_inline777 Object. At runtime, the latter maintains a table of all strategies that are currently in execution for it. Each message is tagged to enable atex2html_wrap_inline777 Object to identify in which execution of what protocol that message is involved, and to dispatch it to the right strategy. Figure 3 (b) presents the relationship between classes tex2html_wrap_inline777 Object and tex2html_wrap_inline777 Algo, using a class diagram based on the Object Modeling Technique notation [19]. The correspondence between tex2html_wrap_inline777 Algo strategy objects and layered protocol stacks is pictured in Figure 3 (c): at runtime, each strategy object represents a layer in one of the protocol stacks currently in execution.



Benoit GARBINATO
Wed May 14 17:28:46 MET DST 1997