0


I am using jboss modules in our enterprise application.
we have a jboss module (let's assume it is packed to "a.jar").
This jboss module contains a singleton (not a Java EE singleton bean, but a POJO singleton, with "getInstance" method).
There are several servlet filters and servlets that would need to access this singleton.
Am I going to experience multiple instances of the class of the singleton, or due to the class loading nature of jboss modules, I am going to get only one instance?

Thanks!

Yair Zaslavsky
  • 4,091
  • 4
  • 20
  • 27

2 Answers2

0

I would like to say that I've tested it by printing "toString" of the instance. i saw that both for the webapp, and for other modules that accessed the singleton - same object id was printed.

Yair Zaslavsky
  • 4,091
  • 4
  • 20
  • 27
0

The same module will load the same classes and instances. It would have to or you'd get type mismatches due to different class loaders. You're safe to assume that if you create a module a singleton will only be loaded once.

James R. Perkins
  • 16,800
  • 44
  • 60