avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: (absence of) singletons
Date Sun, 02 Sep 2001 15:54:01 GMT
On Mon, 3 Sep 2001 01:48, Leo Simons wrote:
> > > thoughts? votes? bad idea?
> >
> > Difficult.
> >
> > 1) What is a singleton? Is it one instance per classloader, one per JVM
> > or one per a cluster of machines?
> once per classloader. If you want to go beyond that you need another
> mechanism (it's just not possible within Java otherwise, as you need
> "static").

The problem then becomes ... which ClassLoader ;) Because in theory you could 
have several shared or in hierarchies it becomes difficult to determin 
certain behaviour in different environments. ie is it in base, shared, 
api-layer, app layer, ContextClassLoader (which could be different again).

In my opinion Singletons are a programatic shortcut. They are very prevelent 
in what I call stage 1/2 frameworks but unless they are performing "system" 
services then they are probably a kludge (though I have heard many claim that 
even system services such as security/System.* etc are also kludges).

Instead of creating singletons in an Avalon-style system I would just create 
one instance and then place it with the same name in all ComponentManagers or 
in a "root" component manager as suggested.

In a way I think I am glad that Avalon makes it difficult to use singletons 
because it makes for much more easily modifiable (and scalable) architectures.



Clarke's Third Law: "Any technology distinguishable from 
magic is insufficiently advanced".

To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org

View raw message