Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

similar interchangeable type with both singleton and instance objects

Thread view: 
sakcee@gmail.com - 08 May 2007 00:22 GMT
Hi

thanks in advance.

I have a situation in which I need a singleton to which multiple tasks
write.
I implemented it as signlton with bunch of static (yeeha) methods.

specificaly, a singlton logger which allows to log to single file.
(singleLog singlton object)

now i need situation in which each task can have individual singleton
type object to
log to different file.
i.e. a log for each task (logger non-singleton object )

the way I was thinking was to make an interface logProfider with few
functions,
that both singleLog and logger implements and each task has that
interface as member
and I chnage that instance on runtime or someother time i guess

i.e.

class Task(){
logProvider myLog= null

setLogger(logProvide l){
logProvider myLog= l;
}
}

task.setLogger(logger)
task.setLogger(singleLog)

the problem is that this does not work as the singleton has all static
methods while the interface
has instance methods.

how to solve it, or retrofit some design pattern in. with out breaking
all code that is
using singleton's static methods.

specificaly can singletons static methods and another objects instance
method conform to same interface

thanks
sakcee@gmail.com - 08 May 2007 01:41 GMT
Esmond Pitt - 08 May 2007 07:20 GMT
'individual singleton' is a contradiction in terms.

You just need to make up your mind which of these you need. You can't
have both.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.