PicoContainer
  1. PicoContainer
  2. PICO-65

ImplementationHidingComponentAdapter does not work properly with TransientComponentAdapters

    Details

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

      Description

      Since the getComponentInstance() from mplementationHidingComponentAdapter verifies if a proxy was already created and returns it, a TransiendComponentAdapter will not be able to create a new component instance.

      uploading a patch for the test case

      1. patch.txt
        1 kB
        Paulo Silveira

        Activity

        Hide
        Paulo Silveira added a comment -

        The simple test is

        public void testBigamy()

        { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHidingComponentAdapterFactory( new TransientComponentAdapterFactory())); pico.registerComponentImplementation(Woman.class, Wife.class); Woman firstWife = (Woman) pico.getComponentInstance(Woman.class); Woman secondWife = (Woman) pico.getComponentInstance(Woman.class); assertNotSame(firstWife, secondWife); }

        And it should give to us different proxy instances, since the delegateAdapter is a Transient one.

        Moreover, I think that this code should throw an exception, since I did not registered a component to act as the Man. How can pico instantiate a Wife? The proxy lazy instatiates a Wife, then the NoSatisfiableConstructorsException is only thrown after the first call!

        Show
        Paulo Silveira added a comment - The simple test is public void testBigamy() { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHidingComponentAdapterFactory( new TransientComponentAdapterFactory())); pico.registerComponentImplementation(Woman.class, Wife.class); Woman firstWife = (Woman) pico.getComponentInstance(Woman.class); Woman secondWife = (Woman) pico.getComponentInstance(Woman.class); assertNotSame(firstWife, secondWife); } And it should give to us different proxy instances, since the delegateAdapter is a Transient one. Moreover, I think that this code should throw an exception, since I did not registered a component to act as the Man. How can pico instantiate a Wife? The proxy lazy instatiates a Wife, then the NoSatisfiableConstructorsException is only thrown after the first call!
        Paulo Silveira made changes -
        Field Original Value New Value
        Attachment patch.txt [ 11041 ]
        Aslak Hellesøy made changes -
        Assignee Aslak Hellesoy [ rinkrank ]
        Aslak Hellesøy made changes -
        Fix Version/s 1.0 [ 10145 ]
        Aslak Hellesøy made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Aslak Hellesøy made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Aslak Hellesøy made changes -
        Fix Version/s 1.0 [ 10145 ]
        Fix Version/s 1.0-beta-4 [ 10412 ]
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Closed [ 6 ]

          People

          • Assignee:
            Aslak Hellesøy
            Reporter:
            Paulo Silveira
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: