Here's the Map
@Autowired
private Map<String, ISendableConverter> converters;
and ISendableConverter
public interface ISendableConverter {
ISendableMsg convert(BaseMessage baseMessage);
String getType();
}
There are some classes that implements ISendableConverter
I want to inject them into the variable converters
by using spring @Autowried
annotation.
The instance of class as value, and the result of method getType()
as key.
like this one
@Component
public class SendableVoiceMsgConverter implements ISendableConverter {
@Override
public ISendableMsg convert(BaseMessage baseMessage) {
// TODO Auto-generated method stub
return null;
}
@Override
public String getType() {
return "VOICE";
}
}
Is this possible? and how?
question from:
https://stackoverflow.com/questions/20918825/can-spring-autowired-map 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…