PicoContainer
  1. PicoContainer
  2. PICO-386

Component resolution should respect scope from which it was resolved

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.14.1
    • Fix Version/s: None
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I've encountered behavior which looks like a bug to me, but this is maybe by design. I'm not really fluent in Java so I'll write example in Scala. Hope that's ok.

      class A(b: B)
      class B(name: String)

      val container = new DefaultPicoContainer
      container.addComponent(classOf[A])
      container.addComponent(new B("root"))
      val scope = container.makeChildContainer
      scope.addComponent(new B("child"))

      val a = scope.getComponent(classOf[A])

      expected: a.b.name = "child"
      actual: a.b.name = "root"

      It seems that Pico doesn't respect full dependency path when resolving components registered in parent container. It resolves component based on registration path, not resolution path. This makes it unusable for chaining state and overriding non-trivial components.

      I suspect that this change will probably be code invasive, so before I take a better look at what Pico is doing I'm just wondering if you are interested in this behavior, did you try to implement it, but it was to complex, or any other info.

      Thanks,
      Rikard

        People

        • Assignee:
          Paul Hammant
          Reporter:
          Rikard Pavelic
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated: