On 09/08/10 08:24, Matt Hammond wrote: > > If what you are after doing is swapping out a single component and > replacing it with a new one, then the Carousel component might help you: > > http://www.kamaelia.org/Components/pydoc/Kamaelia.Chassis.Carousel.html > > When you create a carousel, you provide it with a function for creating > new child components. When a message is sent to the "next" inbox of the > Carousel, your function is called, and is passed the message as its > argument. The new component that your function returns is activated as a > child of the component and wired up such that the inbox and outbox of > the Carousel component go straight to the inbox and outbox of the new > child. > > If there was already a child, then it is sent a message to its control > inbox to tell it to shut down, then its linkages are removed, before > activating and linking in the new child. > > The Carousel also has a 'requestNext' outbox that sends out a message > whenever the child terminates. You can therefore use this to trigger the > creation of a new component.
I hadn't fully appreciated the power of the Carousel component before reading this. I'm (ab)using it to restart a component that occasionally dies (a client of a server that sometimes breaks the connection) by linking its 'requestNext' outbox directly to its 'next' inbox. Every time the client terminates, the Carousel launches a new one and the rest of my pipeline carries on. Magic! -- Jim Easterbrook Senior Research Engineer BBC Research & Development South Lab BBC Centre House 56 Wood Lane London W12 7SB Phone: +44 303 040 9705 Mobile: +44 7590 307002 FAX: +44 20 8811 8815 -- You received this message because you are subscribed to the Google Groups "kamaelia" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/kamaelia?hl=en.
