anti-pattern? why it makes testing much harder?
I use singleton for my own connection pooling and cache and cluster system. All works very fine! 2009/10/13 Olle Hallin <olle.hal...@hit.se> > Singletons is an anti-pattern that the Java community abandoned years ago! > The main reason is that it makes testing much harder. > > Besides, your example is wrong. The constructor must be private, or else > the > singleton is broken. > > Olle Hallin > Senior Java Developer and Architect > olle.hal...@crisp.se > www.crisp.se > > > > > 2009/10/13 Argo Vilberg <wilps...@gmail.com> > > > very simple solution is creata Singleton java class. > > > > > > public class MallBean{ > > public final static MallBean INSTANCE = new MallBean(); > > > > public MallBean() { > > } > > > > .... > > > > } > > > > > > And access > > > > MallBean.INSTANCE.getSomething. > > > > > > And if you first time calling this, class is created and only ONE this > type > > of class can be created. > > And this class is accessible everyone. > > > > > > Enjoy! > > > > Argo > > > > > > 2009/10/13 TomMax <tryk...@poczta.onet.pl> > > > > > > > > Hi all, > > > > > > I'm working in a developers team with Tapestry applications (version > > 4.0.2) > > > for more than 2 years. Our Tapestry applications works on various > > > Application Servers (JBoss, SAP Netweaver), and usually we were able in > > our > > > team to resolve all problems, recently however, we spotted a problem > with > > > Application State Object, which is responsible for user session data > and > > we > > > can't find the bug. > > > > > > The problem is that two users see sometimes the same data on a page. In > > our > > > scenario User1 and User2 have their own userSession objects (they are > ASO > > > object with session scope), these objects keep all their data, and > these > > > objects are injected to every page in .page file: > > > > > > <inject property="userSession" object="userSession" type="state" /> > > > > > > Every user has own userSession object, so every user should see only > his > > > own > > > data on a page, but sometimes (quite rarely), we got the situation, > that > > > User2 sees the data from User1 userSession object when he get the page, > > > where User1 was earlier. > > > So far I know, in case of ASO objects, the references in a page to > these > > > objects, should be set to null on pageDetach action. So each time when > > the > > > user is receiving the page from PagePool (or newly created page), he > > should > > > obtain also fresh ASO object from ApplicationStateManager. > > > We have got currently this problem not so often (usually it is one or > two > > > times in a two week period, in case when the application is used by 3-4 > > > persons 8 hours per day), and when the problem happens, usually all > > working > > > users are receiving wrong data (they see the data from other users). > > > > > > I hope someone will be able to help me. > > > > > > Thanks > > > Tomek > > > > > > > > > -- > > > View this message in context: > > > > > > http://www.nabble.com/-T4--Two-users-see-the-same-data---problem-with-ASO-objects-tp25872478p25872478.html > > > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > > > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > > > > > >