All Packages Class Hierarchy This Package Previous Next Index
Parts implementing this interface should be designed to easily replace themselves using these methods. Note how we encourage indefinite replacement by defining how replaceable state is smoothly passed from each generation to the next.
In conjunction with this interface some parts may need to
implement StateCommandable so that they can pause
and resume while being replaced. Replacement is a normal
lifecycle step.
This interface is used by tools, not this layer. The interface is in this layer merely so all parts, even core parts, can implement it. A tool part such as PartReplacer would manipulate core parts to do the replacement algorithm steps. A sophisticated PartReplacer would include features such as rollback, replacing client Direct Links gained via Part User, replacing entire branches, replacing all instances of a part, and DK updates. These are not shown or designed yet, but it all hinges on this interface.
There are some related modifications needed to MessageRouter,
Cell and such to support this algorithm, which was added recently.
For example Cell may need
replacePart(String name, Object newPart), which
would combine the Remove and Add algorithm steps. We may add the
same method to MessageRouter, plus
pausePartMessages(String partName) and
resumePartMessages(String partName). Or to keep it
simple we may just have the router do pause and resume.
The algorithm for part replacement is quite interesting, and takes full advantage of Messages and other features. Imagine trying to do this generically in a system without UHR. :-)
Transfer state is done without either part knowing about the other, a beautiful trick. Both parts must implement Replaceable. A mediator part (such as PartReplacer) calls
Pause Old Part if supported
Disconnect Messages on Old Part
Remove Old Part from Cell
Transfer state from Old to New Part
Add New Part to Cell
Connect Message on New Part
Resume New Part if supported
oldPart.getReplaceableState() and then
newPart.setReplaceableState(infotron). Infotron is
a type of Datatron. This is a case of Datatrons at their finest,
flowing data from one part to another without the parts ever
knowing what kind of sneaky game is up! :-)
public abstract Infotron getReplaceableState()
This method is called first, before setReplaceableState(Infotron).
public abstract String setReplaceableState(Infotron newState)
In case the new part objects to being replaced, we can call this method on the old part. It should restore itself to normal state. If it released references it can get them back from the newState, which in this case is the old state. A part doesn't know if it's an old or new part, so this works exactly the same for both in a transparent manner. Beautiful....
All Packages Class Hierarchy This Package Previous Next Index