Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Enum a JVM wide singleton?

I have multiple wars deployed in jetty. Initially I had a singleton class but the problem was it was initialized in both the wars. So I'm trying by making the singleton as enum. Is there a way to make a JVM wide singleton ?

like image 256
high-voltage Avatar asked Jan 15 '23 10:01

high-voltage


1 Answers

You can't really enforce this. Your singletons will be classloader-specific, and since your apps can define multiple classloaders, you're going to be frustrated.

like image 113
Brian Agnew Avatar answered Jan 22 '23 12:01

Brian Agnew