One weaknesses in the current PicoVisitor design is that it does not allow for aborting the traversal.
For example, if you wish to traverse only the components in one container, then you should be able to: (pseudocode)
public OnePicoVisitor implements PicoVisitor {
private PicoContainer visitingPico;
public OnePicoVisitor (PIcoContainer target) {
visitingPico = target;
}
public boolean visitContainer(PicoContainer pico) {
if (visitingPico.equals(pico)) {
return true;
}
//Stop traversal, we don't want more containers.
return false;
}
public boolean visitCA(CA componentAdapter) {
//do stuff
return true;
}
///......
}
Without this 'continue' flag, you must traverse the entire pico hierarchy whether you want it or not. (With larger container hierarchies this can be time consuming)
Anyway, since its a significant API change in the visitor behavior I'll have to file this under "Wish", but I still want to get it in there. 