S
Soefara
Dear Sirs,
Am I correct in understanding that once instantiated a Singleton
resides in memory until the JVM is shut down ?
For example, I have a Singleton (below) used for configuration
purposes. It simply stores all the configuration parameters for my web
application, and since it is used repeatedly on every single web page
it would be very convenient if it didn't unload from memory.
My intention is that once created, the configuration parameters will
be loaded from the database and never again discarded (until the web
application server is shut down), or until I intentionally make a call
to reloadConfig(), thereby saving me repeatedly calling the same
values from the database.
Is this what is going to happen ? Or will I actually not be making any
savings in database calls ?
Thank you very much.
Soefara.
public class Singleton {
private static Singleton theInstance = new Singleton();
private Singleton() {
// load configuration from database.
}
public static Singleton getInstance() {
return theInstance;
}
public reloadConfig() {
// reload config from database
}
}
Am I correct in understanding that once instantiated a Singleton
resides in memory until the JVM is shut down ?
For example, I have a Singleton (below) used for configuration
purposes. It simply stores all the configuration parameters for my web
application, and since it is used repeatedly on every single web page
it would be very convenient if it didn't unload from memory.
My intention is that once created, the configuration parameters will
be loaded from the database and never again discarded (until the web
application server is shut down), or until I intentionally make a call
to reloadConfig(), thereby saving me repeatedly calling the same
values from the database.
Is this what is going to happen ? Or will I actually not be making any
savings in database calls ?
Thank you very much.
Soefara.
public class Singleton {
private static Singleton theInstance = new Singleton();
private Singleton() {
// load configuration from database.
}
public static Singleton getInstance() {
return theInstance;
}
public reloadConfig() {
// reload config from database
}
}