db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <to...@first.fhg.de>
Subject Re: [Proposal] Get rid of singletons
Date Sat, 12 Jun 2004 16:49:32 GMT
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. 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). Factories can then be simple objects (no need to make
them static). The prime candidate then would be the MetadataManager.
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.


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

View raw message