- Posted by: Ben Nice
- Posted on: September 11 2003 19:46 EDT
I am wondering since so many people think singelton are bad design. How would you design sharing of expensive stateful resources. Like say JMSSender which shares a JMS Connection yet creates a session for each invoker efficent rather than creating multiple connections and other expensive to create objects. Another shared resource logger better to have a singleton than pass it from class to class? Another program properties so each class can read its properties better than passing the properties object around?I have a registery which is a groups of these shared resources efficently. I would like to here peoples alternatives people to have to singletons for sharing these resources.
- What ways are there to Share Resources other than singletons by Paul Strack on September 12 2003 10:42 EDT
- What ways are there to Share Resources other than singletons by Kingshuk Bandyopadhyay on September 12 2003 19:56 EDT
The stock answer on a J2EE server is to bind a resource factory to JNDI, and use that to manage your resources.
If you are not using J2EE, I would use a singleton.
I am wondering since so many people think singelton are bad design.
Can't think of anything other than tying your resource to the jndi tree - this is already proposed in the previous post. Curious about why you (or other people) think singleton is bad. Any pointer/url to other articles explaining the design issues with singleton will be very useful.