What ways are there to Share Resources other than singletons

Discussions

EJB design: What ways are there to Share Resources other than singletons

  1. Hi,
      
    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.
  2. 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.
  3. 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.

    thanks
    Kingshuk