db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: [Proposal] Get rid of singletons
Date Sat, 12 Jun 2004 17:25:00 GMT
Thomas Dudziak wrote:

> On Sat, 12 Jun 2004, Armin Waibel wrote:
> 
> 
>>Hi all,
>>
>>OJB currently use a couple of classes/factories implemented as singletons:
>>- MetadataManager
>>- ObjectCacheFactory
>>- ConnectionFactoryFactory
>>- ConnectionManagerFactory
>>- JdbcAccessFactory
>>- StatementManagerFactory
>>- StatementsForClassFactory
>>- SequenceManagerFactory
>>- ... and more
>>
>>I think it will be better to manage all factories within one main class 
>>(OJB 1.1). OJB use two main classes PersistenceBroker and 
>>PersistenceBrokerFactory, so I propose to manage all factories within PBF:
>>PBF.getMetadataManager()
>>PBF.getObjectCacheFactory()
>>...
>>+ setter methods
>>
>>this allows us to control and manage all factories from one central 
>>class, replace factories,...
> 
> 
> +1 for removing singletons,
> -1 for putting them into the PBF
> 
> IMO, we don't need factories to be static/singleton at all.

this was my intention ;-)

> There needs to
> be only one static/singleton class which holds the configurations for
> all running OJB 'instances' (e.g. when multiple instances of OJB for
> different databases and models are running in the same or in
> different threads).

I think this should be optional (if possible). The PB-api use a static 
PBFImpl instance, so IMO this is the "natural" entry point to OJB.

> Factories can then be simple objects (no need to make
> them static).

I don't want to use static instances in PBFImpl class, all factory 
classes should be non static objects.

> The prime candidate then would be the MetadataManager.

hmm, IMO the metadata manager is a service of the kernel API (PBFImpl 
class). But it wouldn't be a problem to invert hierarchy and let PBF a 
service of metadata manager.

regards,
Armin

> This also applies to most Loggers: only a logger for a class that is
> instantiated a lot of times (e.g. Query) should be static, all other
> Loggers can be simple instance variables.
> 
> BTW, I was planning to revamp the configuration part for 1.1 (merge the
> metamodels of OJB and the XDoclet module, allow multiple OJB instances in
> the same thread (with different configurations and models) etc.). I'll
> think a bit more about it and then post my ideas.
> 
> Tom
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

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


Mime
View raw message