Are statics global to the JVM in J2EE or local to web Applications? If I have a static property in a class, and use the class definition in multiple webapps, will all webapps reference the same instance? I.e if I have a singleton in a library, and get an instance of it in two different web applications packaged in the same EAR, will it be the same instance? Does it make a difference if the singleton is part of an library packaged externally to the webapp?
posted 13 years ago
As long as your two web apps are runing in the same VM and the singleton is "visible" to other packages, they will us the same instance of the singleton class. BTW, you can do a test to get the object id of that instance from different packages and see if it is the same.
SCJP, SCJD, SCWCD, SCBCD, SCEA, IBM Certified Enterprise Developer, WebSphere Studio V5.0