[PEAK] How to make components and offerOs(ISomeInterface) at runtime

Phillip J. Eby pje at telecommunity.com
Thu Sep 9 09:42:28 EDT 2004


At 08:16 AM 9/9/04 +0200, Sigve Tjora wrote:
>Hi everyone!
>
>I would like to add Component-children to a component at runtime, as well 
>as advertise those components to other children under certain Interfaces 
>or configuration paths. How do I do this?

Are the interfaces different each time, or is there a set of N interfaces 
with N instances that always occur?

If the latter, just define bindings like this:


       child1 = binding.Require("This is where child 1 goes", 
offerAs=[Interface1])

And set the 'child1' attribute at runtime.

If you don't know what interfaces you're using until runtime, then you need 
to have the parent subclass 'binding.Configurable' instead of 
'binding.Component', and you'll use the parent's
'registerProvider()' method to register child components.  See 
'peak.config.interfaces' for more details, especially IConfigurable and IRule.




More information about the PEAK mailing list