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: cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata MetadataManager.java
Date Sat, 12 Jun 2004 17:23:44 GMT
On Sat, 12 Jun 2004, Armin Waibel wrote:

> Does this cause problems?
> We have to make sure that it is guaranteed that only one instance of 
> MetadataManager was created. With the old version it is not guaranteed 
> (the old singleton problem ;-))

Well yes, if you want to initialize logging and OJB at runtime (which I'm
working on at the moment). Any why was this not guaranteed in the old
version (aside from the fact that there was no synchronized guard in the
method) ? How about:

    public syncronized static MetadataManager getInstance()
    {
        // lazy initialization
        if (singleton == null)
        {
            singleton = new MetadataManager();
        }
        return singleton;
    }

Shouldn't that work ?

Tom


---------------------------------------------------------------------
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