J
Jason Cavett
I'm curious - is it possible (and if so, how) to initialize a
Singleton class when the class used for initialization must also get
an instance of the Singleton class?
Here's a pseudocode example to make that more clear...
class SingletonClass {
private SingletonClass() {
ConfigFileReader reader = new ConfigFileReader();
reader.read();
}
// other singleton stuff
}
class ConfigFileReader {
public ConfigFileReader() {
// do stuff
}
public void read() {
// read in the config file and get the appropriate information
SingletonClass.getInstance().setValues(...);
}
}
I don't *think* what I want to do is possible. But, if it is, I'm not
sure how to do it. Any insight would be appreciated.
Thanks
Singleton class when the class used for initialization must also get
an instance of the Singleton class?
Here's a pseudocode example to make that more clear...
class SingletonClass {
private SingletonClass() {
ConfigFileReader reader = new ConfigFileReader();
reader.read();
}
// other singleton stuff
}
class ConfigFileReader {
public ConfigFileReader() {
// do stuff
}
public void read() {
// read in the config file and get the appropriate information
SingletonClass.getInstance().setValues(...);
}
}
I don't *think* what I want to do is possible. But, if it is, I'm not
sure how to do it. Any insight would be appreciated.
Thanks