Well, thanks for thr reply. My application is a complex one in JADE where I am developing a multi agent system. So, I can't really create a new class that binds everyhting togther (although its the ideal way to do it).
But how do I solve my problem?
Class RecruitmentOfficer creates an object of JobsDB. JobsDB has a hashmap.(the only hashmap for the whle application).
OperationsManager agent wants to access this hashmap and make some searches in it. How can OperationsManager get a hold of the Hashmap?
author and iconoclast
Well, although I think the Singleton pattern is overused, that's really what you're asking for here. If there's ever only supposed to be one JobsDB, then make it a static member of its own class, and put a static method in the JobsDB class which retrieves that one object. Now, you said another class creates that one instance, but perhaps you could let the JobsDB class create it itself?
Now any class that wants to get ahold of that one JobsDB instance just has to call "JobsDB.get()" to get it. JobsDB is a "Singleton class."
Joined: Jan 19, 2004
Thats interesting. I did study the Singleton pattern but this thought never occurred to me. Thanks a lot. I'll try it out right away.