I have the following field called someMap in which I need to inject a map at runtime depending upon the inputs I have received.
I have tried using the @Resource
annotaion but it is tightly coupled to the beanId specified in the xml file.
@Resource(name="someMap")
private final Map<String,String> someMap;
<bean id="someMap" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="Engraving1" value="@Engraving1" />
<entry key="Engraving2" value="@Engraving2" />
<entry key="Engraving3" value="@Engraving3" />
<entry key="LeaveBlank" value="@LeaveBlank" />
</map>
</constructor-arg>
</bean>
<bean id="someOtherMap" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="Descirption" value="@Desc" />
<entry key="Engraving2" value="@Engraving2" />
<entry key="Engraving3" value="@Engraving3" />
<entry key="UniqueId" value="$60034" />
</map>
</constructor-arg>
</bean>
What I want is to get rid of this tight coupling & initialize the someMap field to a differnt flavour of the Map defined in spring xml let's say someOtherMap