Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.4
-
Fix Version/s: 2.5
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
Test cases:
Plunk them into AbstractPicoContainerTest for demo:
/**
* Sample class that demonstrates literal collection handling.
*/
static class Searcher {
private final List<String> searchPath;
public Searcher(List<String> searchPath) {
this.searchPath = searchPath;
}
public List<String> getSearchPath() {
return searchPath;
}
}
@Test public void canInstantiateAutowiredCollectionThatAreDefinedExplicitly() {
MutablePicoContainer pico = this.createPicoContainer(null);
List<String> searchPath = new ArrayList<String>();
searchPath.add("a");
searchPath.add("b");
pico.addComponent("searchPath",searchPath)
.addComponent(Searcher.class);
assertNotNull(pico.getComponent(Searcher.class));
assertNotNull(pico.getComponent(Searcher.class).getSearchPath());
}
@Test public void canInstantiateExplicitCollectionWithComponentParameter() {
MutablePicoContainer pico = this.createPicoContainer(null);
List<String> searchPath = new ArrayList<String>();
searchPath.add("a");
searchPath.add("b");
pico.addComponent("searchPath",searchPath)
.addComponent(Searcher.class, Searcher.class, new ComponentParameter("searchPath"));
assertNotNull(pico.getComponent(Searcher.class));
assertNotNull(pico.getComponent(Searcher.class).getSearchPath());
}
Issue Links
- is related to
-
PICO-323
Handle differentiation of components by Type rather than Class.
-
Yeah, we never got that far in terms of functionality.
If you add a and b to the container as strings individually, it will work.
I think to get what you want working perfectly we'd have to change addComponent(Class, Class) to addComponent(Type, Type)