Hello
I am having some issues related to binding entries to map property:
Suppose I have several instances of classes implementing interface
for example:Code:interface MyInterface{ int[] getPossibleMapKeys() }
and I have another class C likeCode:@Component public class ClassA{ int[] getPossibleMapKeys(){ return new int[2] // suppose we have some values } }
and I want to define in xml that all my instances of MyInterface class would be autowired to myMap property:Code:@Component class ClassHavingMap{ @Autowired private Map<Integer, MyInterface> myMap; }
How can i assure that the same instance of MyInterface class will be stored under all different map keys, returned by getPossibleMapKeys() method? Do you know if it is even possible or it is totally wrong approach?Code:<bean class="ClassHavingMap"> <property name="myMap"> <map> <entry key="???" value-ref="???"/> </map> ...


Reply With Quote