Details
-
Type: Bug
-
Status: Closed
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.1
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Number of attachments :
Description
I would like to use GenericCollectionComponentAdapter to inject a composite comp with an array of children components in an instance of the composite pattern. The attached patch has a couple of points:
1. Before I could successfully resolve dependencies to the array I had to make the change to the GCCA to pass the collection type to the AbstractCA. I added the collectionType.isArray() check which seemed prudent. Original test case was modified to pass String[].class for the collection type and it still passes.
2. For the second test case, I had to tweak the container config for a composite since the composite itself is an instance of the component I'm aggregating in the array. The test is more of an integration test since I'm using a container (I realize tests using the container are discouraged), but I wanted to test the container lookup logic with the GCCA present. In order to avoid the cyclic dependency of the array->CompositeComponent->array, I had to wrap a caching CA around the GCCA and pre-instantiate the array before registering the composite. Not ideal, but it works.
Does this approach seem reasonable or is there a better way?
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | GenericCollectionComponentAdapter.patch [ 12745 ] |
Attachment | GenericCollectionComponentAdapter.patch [ 12746 ] |
Assignee | Joerg Schaible [ joehni ] |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Fix Version/s | 1.1 [ 10307 ] |
Cleaned up imports in the second version