PicoContainer
  1. PicoContainer
  2. PICO-3

Patch submission for handling of multiple types

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.0-beta-1
    • Fix Version/s: None
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      2

      Description

      Guys,

      Here is a better draft at implementing support for multiple implementations in HierarchicalPicoContainer. To support this thing:

      public class Component {
      public Component(OtherComponent []others, String []keys);
      }

      The patch is taken from the src directory.

      There is a new exception class picocontainer.hierarchical.InconsistentLookupTypeRegistrationException which I also attach.

      Cheers,
      Mike

        Activity

        Mike Hogan made changes -
        Field Original Value New Value
        Attachment patch.diff [ 10381 ]
        Mike Hogan made changes -
        Hide
        Mike Hogan added a comment -

        Refactoring steps in case I have to do it again:

        1. Refactor HierarchicalPicoContainer to use methods to access componentTypeToInstanceMap
        2. Refactor so that componentTypeToInstanceMap contains a map, keyed by component. Redundant for now.
        3. Rename componentTypeToInstanceMap to componentTypeToLookupMap
        4. Add key to ComponentSpecification
        5. Enable first commented out test case in HierarchicalPicoContainerTestCase - testCannotMixLookupTypesWithKeyFirst
        6. Add void registerComponent(Class componentType, Class componentImplementation, String key) throws PicoRegistrationException to ClassRegistrationPicoContainer
        7. Implement this method in HierarchicalPicoContainer.
        8. Add checkLookupTypeConsistency to HierarchicalPicoContainer to help registerComponent.
        9. Chain registerComponent methods to call this new one.
        10. testCannotMixLookupTypesWithKeyFirst passes.
        11. testCannotMixLookupTypesWithTypeFirst passes.
        12. testKeepingLookupTypesConsistentWorks passes.
        13. Enable commented out test case testCanPassMultipleImplsAsArray
        14. Write AnimalConsumer
        15. Add Object getComponent(Class componentType, String key); to ClassRegistrationPicoContainer. Maybe should be in PicoContainer but that has to much effect for now.
        16. Refactor getImplForType to take a key with special case for null (normal pico behaviour)
        17. Refactor mapImplToType to take a key with same special case.
        18. Add key to hookEmUp and propagate to mapImplToType
        19. Add key to reuseImplementationIfAppropriate and propagate to mapImplToType
        20. Add allLookupImplsResolved to help array handling in hookEmUp
        21. Replace use of Map.Entry with ComponentInstantiation (because some Map.Entry instances now contain Strings as keys)
        22. Re-write for Arrays

        Show
        Mike Hogan added a comment - Refactoring steps in case I have to do it again: 1. Refactor HierarchicalPicoContainer to use methods to access componentTypeToInstanceMap 2. Refactor so that componentTypeToInstanceMap contains a map, keyed by component. Redundant for now. 3. Rename componentTypeToInstanceMap to componentTypeToLookupMap 4. Add key to ComponentSpecification 5. Enable first commented out test case in HierarchicalPicoContainerTestCase - testCannotMixLookupTypesWithKeyFirst 6. Add void registerComponent(Class componentType, Class componentImplementation, String key) throws PicoRegistrationException to ClassRegistrationPicoContainer 7. Implement this method in HierarchicalPicoContainer. 8. Add checkLookupTypeConsistency to HierarchicalPicoContainer to help registerComponent. 9. Chain registerComponent methods to call this new one. 10. testCannotMixLookupTypesWithKeyFirst passes. 11. testCannotMixLookupTypesWithTypeFirst passes. 12. testKeepingLookupTypesConsistentWorks passes. 13. Enable commented out test case testCanPassMultipleImplsAsArray 14. Write AnimalConsumer 15. Add Object getComponent(Class componentType, String key); to ClassRegistrationPicoContainer. Maybe should be in PicoContainer but that has to much effect for now. 16. Refactor getImplForType to take a key with special case for null (normal pico behaviour) 17. Refactor mapImplToType to take a key with same special case. 18. Add key to hookEmUp and propagate to mapImplToType 19. Add key to reuseImplementationIfAppropriate and propagate to mapImplToType 20. Add allLookupImplsResolved to help array handling in hookEmUp 21. Replace use of Map.Entry with ComponentInstantiation (because some Map.Entry instances now contain Strings as keys) 22. Re-write for Arrays
        Hide
        Aslak Hellesøy added a comment -

        Mike, what's the status of this one?

        Show
        Aslak Hellesøy added a comment - Mike, what's the status of this one?
        Aslak Hellesøy made changes -
        Status Unassigned [ 1 ] Assigned [ 2 ]
        Assignee Mike Hogan [ m081072 ]
        Hide
        Mike Hogan added a comment -

        Aslak,

        Status is that this is waiting to see whether the Joe/Jon's parameter stuff solves the problem. I need to check the code that Jon submitted with a test case.

        Show
        Mike Hogan added a comment - Aslak, Status is that this is waiting to see whether the Joe/Jon's parameter stuff solves the problem. I need to check the code that Jon submitted with a test case.
        Aslak Hellesøy made changes -
        Affects Version/s 1.0-beta-1 [ 10144 ]
        Original Estimate 0
        Fix Version/s 1.0-beta-1 [ 10144 ]
        Remaining Estimate 0 minutes [ 0 ]
        Show
        Mike Hogan added a comment - Duplicate of PICO-33 http://jira.codehaus.org/secure/ViewIssue.jspa?key=PICO-33
        Mike Hogan made changes -
        Resolution Duplicate [ 3 ]
        Status Assigned [ 2 ] Closed [ 6 ]
        Fix Version/s 1.0-beta-1 [ 10144 ]

          People

          • Assignee:
            Mike Hogan
            Reporter:
            Mike Hogan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: