aspose file tools
The moose likes Servlets and the fly likes Singleton vs application context Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Singleton vs application context" Watch "Singleton vs application context" New topic
Author

Singleton vs application context

shaju joseph
Ranch Hand

Joined: Jun 28, 2001
Posts: 30
Hello,
What's the difference between making a class singleton and setting a class variable in the application context ? If I make a class singleton , is it available till the server is shutdown ?
Thanks
Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
Application context is actually just "WAR-context" whereas singleton context is JVM wide(If your JAR is put in server's class path).
Stuffs being stored in ServletContext will be unloaded, and reloaded when you reload the WAR, or updates the WAR. Singletons in the JVM will not be reloaded until you shutdown the server.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Singleton vs application context
 
Similar Threads
singleton class can be mutithreaded?
Spring - Multiple IoC Containers with Singleton Bean in a JVM
Singleton Pattern
injection and lookup
Application level list of users logged in