🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8093

Code for a Factory Singleton class?

#8093
From: Andrew Shrosbree
Date: Wed, 25 Apr 2001 06:56
30 lines
2030 bytes
Greetings

I have an application which uses 4 separate factories. Each factory is a
singleton which maintains a hashtable of classes. I can ask each factory to
return a particular instantiated class by calling (for example)

jMyObject oObject = jFactory1.getObjectFor( "ClassName" );

As you can see, my getObjectFor method is static. In fact all the methods in my
factory classes are static.

Now all the factories work exactly the same, so I want to subclass them all from
a neat base-factory class. But of course, I can't do this because the Instance
method in each of my classes returns a different type.

I have grappled with Rod Waldhoff's article 'Implementing the Singleton Pattern
in Java' and cannot make head of tail of how to solve my subclassing problem.

Does anybody have some real code which demonstrates a solution to this (common)
problem?

--
Andrew N. Shrosbree
Project Manager and Technical Architect
Collaborative Centre for eHealth
University of Ballarat
Victoria, Australia
Tel: +61 (0)3 5327 9896
Fax: +61 (0)3 5327 9307
Mob: +61 (0)415 645 291
Technical Details
Message-ID: <3AE67517.5B43766@ballarat.edu.au>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!feeds.vnews.net!nntp.cifnet.net!newsfeed.gamma.ru!Gamma.RU!dispose.news.demon.net!demon!newspeer.monmouth.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,6e3c99b0815d7bc4,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-04-25 00:30:03 PST
Message-ID: <3AE67517.5B43766@ballarat.edu.au>
Date: Wed, 25 Apr 2001 16:56:23 +1000
From: Andrew Shrosbree <A.Shrosbree@ballarat.edu.au>
Organization: University of Ballarat
X-Mailer: Mozilla 4.73 [en] (Win98; I)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Code for a Factory Singleton class?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 141.132.70.47
X-Trace: dnews 988181952 141.132.70.47 (24 Apr 2001 23:59:12 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!feeds.vnews.net!nntp.cifnet.net!newsfeed.gamma.ru!Gamma.RU!dispose.news.demon.net!demon!newspeer.monmouth.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews