PicoContainer
  1. PicoContainer
  2. PICO-167

SICA fails order of instantiation for dependencies

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-RC-1
    • Fix Version/s: 1.0-RC-1
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      2

      Description

      The order of instantiation and dispose in the lifecycle should be honored by SICA as it is done by CICA. Since the callback for the container is handled in the ICA this works for CICA painlessly. SICA fails badly, since it uses the delegated CICA just for the standard ctor, that has obviously no dependencies. Later on it determins its dependencies on its own, but fail to inform the PicoContainer.

      See tes cases for SICA, the tests are "commented out"

      Proposed solution: "Resurrect" the inheritance from 1.0-beta-5 and let SICA extend ICA again. There is significant code, that can be shared, that will fix this issue here. And both CAs have a basic purpose: Instantiation of components, so the inheritance seem for me natural.

      I'll start working on this ...

      1. SICA-refactoring.diff
        20 kB
        Jörg Schaible
      2. SICA-test-case.diff
        7 kB
        Jörg Schaible

        Issue Links

          Activity

          Hide
          Jörg Schaible added a comment -

          It's even worse: Verify is totally useless, since it is just delegated and the CICA does know nothing at all about the setter dependencies ...

          Show
          Jörg Schaible added a comment - It's even worse: Verify is totally useless, since it is just delegated and the CICA does know nothing at all about the setter dependencies ...
          Hide
          Thomas Heller added a comment -

          You might consider looking at PICO-166 and PICO-165 and alot of mails on the mailing list concerning a topic I mentioned often beeing that ComponentAdapters knowing of other (and working with) ComponentAdapters makes things more complex than they need to.

          IMHO the PicoContainer should be the only one doing anything with ComponentAdapter. If a ComponentAdapters wants to know if its Component is statisfied it should ask the container. If the CA wants to dependency instance it should ask the container (removes the need for a addOrderedComponentAdapter callback). Right now the ComponentAdapter is doing all the work and the PicoContainer is merely a HashMap giving away all the logic to the Adapters. He should be able to do some work.

          Aslak proposed to let this "problem" rest until after v1.0 and I agreed cause I also want to have a v1.0 release.

          Before "you start working on this" you might consider taking a look at my proposed solution. I never had the time to do the actual code and I don't know if that fixes all issues but it fixes the 3 most recents issues and makes lifecycle instantiation order alot more easier.

          Nevertheless I'm -1 to doing this before v1.0. Don't know who uses SICA but probably we should just postpone this feature to a v1.1?

          Show
          Thomas Heller added a comment - You might consider looking at PICO-166 and PICO-165 and alot of mails on the mailing list concerning a topic I mentioned often beeing that ComponentAdapters knowing of other (and working with) ComponentAdapters makes things more complex than they need to. IMHO the PicoContainer should be the only one doing anything with ComponentAdapter. If a ComponentAdapters wants to know if its Component is statisfied it should ask the container. If the CA wants to dependency instance it should ask the container (removes the need for a addOrderedComponentAdapter callback). Right now the ComponentAdapter is doing all the work and the PicoContainer is merely a HashMap giving away all the logic to the Adapters. He should be able to do some work. Aslak proposed to let this "problem" rest until after v1.0 and I agreed cause I also want to have a v1.0 release. Before "you start working on this" you might consider taking a look at my proposed solution. I never had the time to do the actual code and I don't know if that fixes all issues but it fixes the 3 most recents issues and makes lifecycle instantiation order alot more easier. Nevertheless I'm -1 to doing this before v1.0. Don't know who uses SICA but probably we should just postpone this feature to a v1.1?
          Hide
          Jörg Schaible added a comment -

          Hello Thomas,

          I agree with you that the basic concept could be improved past 1.0 in a way you described earlier. But the current implementation fails basic functionality and I would rather return to a solution as it was in beta-5 than to release the current one. The conversion of SICA to a delegator was with the current Pico implementation only possible because of lacking unit tests. When we improve the complete design and remove the addOrderedComponentAdapter in past 1.0 we might also return to another solution for SICA again. And remember, the current implementation was not released at all, for the released versions SICA is still an ICA, so you don't know how this impacts our users.

          If we support SICA for 1.0, we might do that as well as possible, but not with an implementation that fails such basic tests. IMHO we will gain a lot attention releasing 1.0 final and a lot more people will compare Pico with Spring.

          So what I am basically saying:

          • with the current Pico design it was a bad idea to make SICA a delegator
          • return to a similar solution for SICA as in beta-5 at least for 1.0 final
          • improve unit tests to ensure basic Pico functionality

          nothing of this does mean, that it is carved in stone, but we should do our best for 1.0 final with the current "restriction" of PicoContainer itself.

          Regards,
          Jörg

          Show
          Jörg Schaible added a comment - Hello Thomas, I agree with you that the basic concept could be improved past 1.0 in a way you described earlier. But the current implementation fails basic functionality and I would rather return to a solution as it was in beta-5 than to release the current one. The conversion of SICA to a delegator was with the current Pico implementation only possible because of lacking unit tests. When we improve the complete design and remove the addOrderedComponentAdapter in past 1.0 we might also return to another solution for SICA again. And remember, the current implementation was not released at all, for the released versions SICA is still an ICA, so you don't know how this impacts our users. If we support SICA for 1.0, we might do that as well as possible, but not with an implementation that fails such basic tests. IMHO we will gain a lot attention releasing 1.0 final and a lot more people will compare Pico with Spring. So what I am basically saying: with the current Pico design it was a bad idea to make SICA a delegator return to a similar solution for SICA as in beta-5 at least for 1.0 final improve unit tests to ensure basic Pico functionality nothing of this does mean, that it is carved in stone, but we should do our best for 1.0 final with the current "restriction" of PicoContainer itself. Regards, Jörg
          Hide
          Jörg Schaible added a comment -

          Patch for SICA, CICA, ICA, SICAFactory and unit tests.
          Aslak, please have a look at this.
          Unit tests will be polished later on.

          Show
          Jörg Schaible added a comment - Patch for SICA, CICA, ICA, SICAFactory and unit tests. Aslak, please have a look at this. Unit tests will be polished later on.
          Jörg Schaible made changes -
          Field Original Value New Value
          Attachment ICA.diff [ 11773 ]
          Hide
          Jörg Schaible added a comment -

          Aslak, can you have a look at this? Your latest change to CICA introduced already minor merge conflicts and I would like to close this issue as soon as possible.

          Show
          Jörg Schaible added a comment - Aslak, can you have a look at this? Your latest change to CICA introduced already minor merge conflicts and I would like to close this issue as soon as possible.
          Aslak Hellesøy made changes -
          Assignee Aslak Hellesoy [ rinkrank ]
          Hide
          Jörg Schaible added a comment -

          Waiting for refactored SICA

          Show
          Jörg Schaible added a comment - Waiting for refactored SICA
          Jörg Schaible made changes -
          Link This issue is depended upon by PICO-160 [ PICO-160 ]
          Hide
          Jörg Schaible added a comment -

          Just added two dependencies for outstanding patches, that will have priority.

          Show
          Jörg Schaible added a comment - Just added two dependencies for outstanding patches, that will have priority.
          Jörg Schaible made changes -
          Link This issue is depended upon by PICO-161 [ PICO-161 ]
          Jörg Schaible made changes -
          Attachment ICA.diff [ 11773 ]
          Hide
          Jörg Schaible added a comment -

          Updated patch for SICA refactoring, that applies again without merge conflict.

          Show
          Jörg Schaible added a comment - Updated patch for SICA refactoring, that applies again without merge conflict.
          Jörg Schaible made changes -
          Attachment SICA-refactoring.diff [ 11943 ]
          Hide
          Jörg Schaible added a comment -

          Separate patch for the unit test, that demonstrate the current design flaw. Makes validation esier.

          Show
          Jörg Schaible added a comment - Separate patch for the unit test, that demonstrate the current design flaw. Makes validation esier.
          Jörg Schaible made changes -
          Attachment SICA-test-case.diff [ 11944 ]
          Jörg Schaible made changes -
          Attachment SICA-refactoring.diff [ 11943 ]
          Hide
          Jörg Schaible added a comment -

          Updated patch after new changes.

          Show
          Jörg Schaible added a comment - Updated patch after new changes.
          Jörg Schaible made changes -
          Attachment SICA-refactoring.diff [ 11952 ]
          Jörg Schaible made changes -
          Attachment SICA-refactoring.diff [ 11952 ]
          Hide
          Jörg Schaible added a comment -

          Refactoring now XStream compatiple

          Show
          Jörg Schaible added a comment - Refactoring now XStream compatiple
          Jörg Schaible made changes -
          Attachment SICA-refactoring.diff [ 11991 ]
          Hide
          Paul Hammant added a comment -

          Go for it Jörg

          Show
          Paul Hammant added a comment - Go for it Jörg
          Jörg Schaible made changes -
          Assignee Aslak Hellesoy [ rinkrank ] Joerg Schaible [ joehni ]
          Hide
          Jörg Schaible added a comment -

          Resolved.

          Show
          Jörg Schaible added a comment - Resolved.
          Jörg Schaible made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Hide
          Aslak Hellesøy added a comment -

          test

          Show
          Aslak Hellesøy added a comment - test

            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: