GlassFish allows creating N domains. Every domain has its own Java classes (libraries etc) and system settings.
For example, we have two domains - domain1 and domain2.
Via GF web console (http://localhost:4848) one system property was set for domain1 - com.temp.foo=test1
. Besides via GF web console (http://localhost:7575) one system property was set for domain2 - com.temp.foo=test2
.
Now, in domain1
System.out.println(System.getProperty("org.temp.foo"))
//returns `test1`
And in domain2
System.out.println(System.getProperty("org.temp.foo"))
//returns `test2`
As I understand GF and all its domains are running in one instance of JVM. And I don't understand how it is possible in one instance of JVM separate system properties. Could anyone explain?
Note: I understand that it can be a very long explanation that's why I am asking only about main principle and solutions/libraries names in an order I could read about them on the internet.
It seems that the understanding "GF and all its domains are running in one instance of JVM" is wrong.
As per GlassFish current version's documentation (chapter 3):
A domain contains a group of GlassFish Server instances that are administered together. [...] A GlassFish Server instance is a single Virtual Machine for the Java platform (Java Virtual Machine or JVM machine) on a single node in which GlassFish Server is running.
That means, every single instance of any domain is running in its own JVM! As a consequence, they all could have their own different system properties.
To be fair: There are means for administering virtual servers in GlassFish, that seem to share a JVM, but I think you are not speaking about them.