El día Wed, 30 Dec 2009 14:50:59 +0200 anatoly techtonik <[email protected]> escribió:
> Hello, Augusto > > I've tried to summarize, but failed. Need some help. > > The first meta-problem I've faced is that > TracDev/ComponentArchitecture is missing a Chapter about component > lifetime. I.e. what happens with components when Trac is loaded, when > ComponentManager instantiates them, what happens when it just > enumerates them, what methods are called at which point? > > The summary with questions. Please correct. > trac.ini allows to choose between components implementing the same > extension point. > components with extension point should offer user a choice. > components with extension point provide an option to chose > implementing component in trac.ini using trac.config.ExtensionOption > or trac.config.OrderedExtensionsOption > trac "loads" all components on startup. > 1. what does "loads" mean? > ? enumeration of available component class names > ? building list of dependencies among class names according to > extension point -> implementation > ? initializing components using dependency chain by creating > objects and calling their __init__ method > > trac reads configuration. > 2. does it need components to be loaded at this stage to parse config > > trac configures components > 3. are there any layers of component configuration? > ? trac decision if component should be loaded based on internal > architecture > ? trac decision if component should be loaded based on some > general permissions > ? trac decision if component should be loaded based on explicit > component configuration > ? component decision if it should be loaded > > components with extension points may choose component that implement > it among available choices based on configuration > > everything is set. request processing start execution > > > If all above is correct (that I am really unsure of), then your > proposal for components that should choose implementation for their > extension point without initializing all other components can have two > alternatives (depending on actual Trac loading sequence): > > 1. load configuration before components are "loaded", analyze > dependency chains and "load" only required components > > 2. postpone initialization of components (i.e. calling __init__ method) until > 2.1 implementing component is used for the first time > 2.2 extension point component decides to choose one (and discard all > others from init chain) > > > Is everything above is right? > Hello, I can't answer with precision. Sorry if I was not clear, I will try to clarify my point. ExtensionOption is basicaly an extension point that lets you choose what component should be used. When ExtensionOption is acceced the first time it loads *all* components that implement ceirtan interface and not just those that should be used. ExtensionOption internally call ExtensionPoint.extensions() that returns all components instances that declare to implement the extension point interface, then find which one matches the choosed and return that. At this point all components (which implements the extension point) have been instantiated. My suggestion is to provide to ExtensionPoint with a method that return component classes instead of components instances, then select one that matches the chosen and instantiate that component only. The instantiation is delegated to ComponentManager. This is your second alternative [2. postpone initialization ...] OrderedExtensionOption uses the same internal mechanism with a list of components. -- You received this message because you are subscribed to the Google Groups "Trac Development" 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/trac-dev?hl=en.
