Fair enough.
Christian.
On 4-Feb-09, at 17:39 , superoverdr...@gmx.de wrote:
I am not storing state, I am storing configuration data.
So the idea is on Application startup, config data is read from the
database and stored in a HashMap of a singleton service.
-------- Original-Nachricht --------
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 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 the hibernate query just resolve from cache.
Not a
hard rule, but often helpful.
Christian.
On 4-Feb-09, at 16:32 , superoverdr...@gmx.de wrote:
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 List<Domain> domains = null;
public DomainPropertyService(Session session){
this.session=session;
}
public String getString(String key){
if (domains==null){
domains = session.createCriteria(Domain.class).list();
}
if (domains!=null){
return "queries the database";
}
else {
return "read from cache";
}
}
}
public static void bind(ServiceBinder binder)
{
binder.bind(DomainPropertyService.class);
}
Thanks!
Toby
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
Christian Edward Gruber
christianedwardgru...@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
Christian Edward Gruber
christianedwardgru...@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org