Is it possible to assign @Qualifier value at runtime. Let's say I have two beans of same type and a class with dependency injection
<bean id="typeA" class="com.debopam.test.Type">
<property name="typevalue" value="Export" />
</bean>
<bean id="typeB" class="com.debopam.test.Type">
<property name="typevalue" value="Import" />
</bean>
public class Product {
private Integer price;
private String name;
@Autowired
@Qualifier("typeB")
private Type type;
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Type getType() {
return type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Is there any way to define type in Product class in runtime instead of hard coding/specifying the value? If yes could you please post some code, otherwise is it advisable to use ApplicationContext.getBean("bean name") to load the bean at runtime?