Singleton Service behaves like a Per-Thread service

2009-02-04 Thread superoverdrive
Hello everyone! I am a bit confused. I thought the default service binding is a singleton? But why do I see a database query every time I load the same page? public class DomainPropertyService { private Session session; private ListDomain domains = null;

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread superoverdrive
An: users@tapestry.apache.org Betreff: Singleton Service behaves like a Per-Thread service Hello everyone! I am a bit confused. I thought the default service binding is a singleton? But why do I see a database query every time I load the same page? public class DomainPropertyService

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread Martin Strand
Are you sure you're seeing a query or do you mean your code returns queries the database ? That method will always return queries the database. I'm not sure what it's for but perhaps you would want to change it something like if (domains==null){ domains =

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread Christian Edward Gruber
Not sure, but you're probably doing yourself a disservice by storing state in a singleton. For instance, you have to guard against race conditions and so forth. It's doable, but you might want to use a transparent cache instead that does a lot of that sort of thing for you, and then have

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread nillehammer
Hy Toby, you might be fooled by your own code. if (domains!=null){ return queries the database; Should be if (domains==null){ return queries the database; Regards, nillehammer -- http://www.winfonet.eu superoverdr...@gmx.de schrieb: Hello everyone! I am a bit confused. I thought the default

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread superoverdrive
christianedwardgru...@gmail.com An: Tapestry users users@tapestry.apache.org Betreff: Re: Singleton Service behaves like a Per-Thread service Not sure, but you're probably doing yourself a disservice by storing state in a singleton. For instance, you have to guard against race conditions and so

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread superoverdrive
:54 +0100 Von: nillehammer tapestry.nilleham...@winfonet.eu An: Tapestry users users@tapestry.apache.org Betreff: Re: Singleton Service behaves like a Per-Thread service Hy Toby, you might be fooled by your own code. if (domains!=null){ return queries the database; Should be if (domains

Re: Singleton Service behaves like a Per-Thread service

2009-02-04 Thread Christian Edward Gruber
Datum: Wed, 4 Feb 2009 16:40:47 -0500 Von: Christian Edward Gruber christianedwardgru...@gmail.com An: Tapestry users users@tapestry.apache.org Betreff: Re: Singleton Service behaves like a Per-Thread service Not sure, but you're probably doing yourself a disservice by storing state