I need to share some kind information (see HashMap) through different part of my code. I think that Singleton could be a perfect design pattern - except for one thing:
Information retrival (read init HashMap and populate it) is demand to another class (MVC). So, my question:
is possible to assign to my Singleton class this information from an external class, if yes, how?
And is a good usage of Singleton design pattern? Otherwise, what could you advise me?
I have a manager class that populates this Hashmap. HashMap contains information about "Users". Now, my manager starts n Threads. Every thread open a connection to db. In Db class handler, I have to check if this query contains users in my HashMap.
So at the moment I have: Manager -> Threads -> DBHandler
I want to avoid to pass my HashMap thourgh every constructor. That's why I thought about a Singleton.
Also, my HashMap, once populated, is just a READ-ONLY Map.