Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Programmer > Initializing Si...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 52587 of 55513
Post > Topic >>

Initializing Singletons

by Jason Cavett <jason.cavett@[EMAIL PROTECTED] > May 8, 2008 at 07:15 AM

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
 




 8 Posts in Topic:
Initializing Singletons
Jason Cavett <jason.ca  2008-05-08 07:15:30 
Re: Initializing Singletons
Tom Anderson <twic@[EM  2008-05-08 15:55:03 
Re: Initializing Singletons
"Mike Schilling&quo  2008-05-08 11:54:42 
Re: Initializing Singletons
Daniel Pitts <newsgrou  2008-05-08 08:02:07 
Re: Initializing Singletons
"Peter Duniho"   2008-05-08 10:59:26 
Re: Initializing Singletons
Jason Cavett <jason.ca  2008-05-08 13:37:28 
Re: Initializing Singletons
Daniel Pitts <newsgrou  2008-05-08 18:10:33 
Re: Initializing Singletons
Owen Jacobson <angryba  2008-05-08 20:40:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 19:14:57 CST 2008.