Daniel Krieg wrote:
I am attempting to implement my own Container and have some questions about Inversion of Control patterns. I am attempting to create a Container that manages a single component type at a time. The contained components may be associated with other components held within other container instances. The Container should be responsible for resolving these dependencies within the ServiceManager for the component. Correct so far?
Correct.
Now, the Container is also a component with associations to other components. Is it violating IOC if the Container-associated components are made available to the child components not within the ServiceManager but within the Context? After all, the Container-associated components are implicit services to the Contained components and therefore should not need to be declared as a dependency.
Are you saying that you have a Component that implements the "Containment" pattern (as I dubbed it), meaning that you have developed a component that also happens to be a container? Stricly speaking with IOC, as long as the Container provides and manages all the resources made available to the component, then you are implementing it correctly. If the resource being made available is from a container's container, then it is still IOC. However, it is not a clean use of the Context object to pass references to components. While we can't tell you not to do it, the ServiceManager was made for that purpose.
What this really means that a child Context has indirect access to the contents of its parent's ServiceManager. Does this seem reasonable or am I missing the boat somewhere?
You can do that with the ServiceManager as well. One of the contracts with ServiceManager is that they can be hierarchical.
I think a component's ServiceManager should only provide peer relationships and components related to a component's Container should be part of a component's Context.
Nope. Not necessarily. A ServiceManager is allowed to defer component lookups to a parent container, thus preserving IOC and the contracts surrounding where to get your components. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]