mardi 7 avril 2015

HashMap accessible from whole project

I have defined HashMap



<bean id="userMap" class="pl.test.pojo.UserMap">
<property name="userMap">
<map>
</map>
</property>
</bean>


I want to be able to access this content from any class in my project I write to it like:



@Autowired
UserMap userMap;
Status s = new Status();
User req = new User();
s.setStatus(3);
s.setErrorCode("0");
s.setErrorDescription("OK");
s.setCorrelationId(addToQuarantineRequest.getCorrelationId());
userMap.getUserMap().put(req, s);


and it is ok, but from another class I want to read content of the userMap firstly declaring it with @autowired annotation I have got NullPointerException how can I make Map to be accesible from whole project?


Aucun commentaire:

Enregistrer un commentaire