Announcement Announcement Module
Collapse
No announcement yet.
Injecting Map with Enum keys. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting Map with Enum keys.

    Hi,

    I have problem with injecting my property wich is a Map with Enum keys in my web application.

    My class with Map property:
    Code:
    public class SomeServiceImpl implements SomeService{
    
    private Map<MyEnum, String> myMap; public void setMyMap(Map<MyEnum, String> myMap) { this.myMap = myMap; }
    }
    here is my applicationContext.xml:

    Code:
    <bean id="someService" class="eu.xxx.SomeServiceImpl">
    <property name="myMap" ref="myMap"/>
    </bean> <util:map id="myMap" key-type="xxxxx.MyEnum">
    <entry key="1" value="some value 1"/> <entry key="2" value="some value 2"/> <entry key="3" value="some value 3"/> <entry key="4" value="some value 4"/> <entry key="5" value="some value 5"/>
    </util:map>
    Problem is, that in SomeServiceImpl bean, the keys in this Map are null. What's more: only last value ("some value 5") is injected into this map, but under key which is null, so the size of map is 1, the key is null and value is "some value 5".
    It looks as if the Enum type is not recognized in my applicationContext.xml

    Has anybody an idea, what am I doing wrong?
    I would be grateful for any help.
Working...
X