PicoContainer
  1. PicoContainer
  2. PICO-247

RootVisitingLifecycleManager cannot work with container hierarchies

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.2
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The RootVisitingLifecycleManager fails completly for Pico hierarchies, because the container will invoke the LC methods on its children and the PicoVisitors will do that also. A LicecylcleManager is not compatible with a PicoVisitor by design!

      LifecycleManager lcm = new RootVisitingLifecycleManager();
      PicoContainer father = new DPC(lcm);
      PicoContainer child = new DPC(father, lcm);
      father.start(); ===> IllegalStateException

      IMHO we should drop this class at all. We changed LC from 1.1 to 1.2 and all we can do is to deliver the old functionality deprecated. To support customized LC I will factor out from the DLM an AbstractLM.

        Activity

        Hide
        Jörg Schaible added a comment -

        Since the architecture prevents a fix, I just removed the class. The failing unit test (just for the records):

        public void testShouldVisitEveryComponentOnlyOnce()

        { Mock mockStartable1 = mock(Startable.class, "Startable1"); Mock mockStartable2 = mock(Startable.class, "Startable2"); LifecycleManager lifecycleManager = new RootVisitingLifecycleManager(); MutablePicoContainer parent = new DefaultPicoContainer(lifecycleManager); MutablePicoContainer child = new DefaultPicoContainer( new DefaultComponentAdapterFactory(), parent, lifecycleManager); parent.addChildContainer(child); parent.registerComponentInstance(mockStartable1.proxy()); child.registerComponentInstance(mockStartable2.proxy()); mockStartable1.expects(once()).method("start").id("1"); mockStartable2.expects(once()).method("start").after(mockStartable1, "1"); parent.start(); }
        Show
        Jörg Schaible added a comment - Since the architecture prevents a fix, I just removed the class. The failing unit test (just for the records): public void testShouldVisitEveryComponentOnlyOnce() { Mock mockStartable1 = mock(Startable.class, "Startable1"); Mock mockStartable2 = mock(Startable.class, "Startable2"); LifecycleManager lifecycleManager = new RootVisitingLifecycleManager(); MutablePicoContainer parent = new DefaultPicoContainer(lifecycleManager); MutablePicoContainer child = new DefaultPicoContainer( new DefaultComponentAdapterFactory(), parent, lifecycleManager); parent.addChildContainer(child); parent.registerComponentInstance(mockStartable1.proxy()); child.registerComponentInstance(mockStartable2.proxy()); mockStartable1.expects(once()).method("start").id("1"); mockStartable2.expects(once()).method("start").after(mockStartable1, "1"); parent.start(); }
        Jörg Schaible made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]

          People

          • Assignee:
            Jörg Schaible
            Reporter:
            Jörg Schaible
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: