I am designing a JSF application, in this application I have 5 beans and I need to share information between them. I tough that implementing a singleton class would help me, because I want that only one object of this singleton class is created and we can use it to share information between the beans, Every time an user log in into the system application, one Bean1 object is created, one Bean2 object , several Bean3 objects, several Bean4 object and one Bean5 object. The huge problem that I have is, as this application is a JSF application, several users can log in into the system at the same time, every time a user log in, the beans object are created for each user (Each user has a different bean copy) but only one singleton object is created, only one for all the different users, all the user share the same singleton object, this is creating a huge problem because the data from one user overrides the data from other user!!!
I still need to create and object that can share information between the beans, but I need that each user has a different copy.
What design patter would you suggest me? or what kind of modification can I do to my actual design ???
I can't name a design pattern, but if each user needs a unique copy of a bean, then they should not be singletons, they should be session beans, since each user gets a discrete session. Singleton beans would normally be used at application scope, although because of the way JSF constructs beans, actually making a true singleton for an application scope object is usually overkill.
JSF is based on the Inversion of Control paradigm. In IoC, you don't connect things together via logic, you have a framework that manages the connections. In the case of JSF, that's the Managed Bean facility. By proper coding of the faces-config.xml file (or annotation equivalences), you can inject beans into other beans.
An IDE is no substitute for an Intelligent Developer.