Java singleton class vs JSF application with limited bean control - differences?

Is there a difference using a singleton class and managed by a bean to store application data?

I need to find specific JNDI resources, such as remote bean interfaces, and so I wrote myself a singleton to cache my links and allow only single links. (ServiceLocator)

I opened my site in two different browsers and got one singleton only once. So, I guess its scope?

Any other benefits of a managed bean application area and then access to its properties in jsf?

+7
source share
1 answer

Singletones are not checked per unit, are not absorbed or expanded. Singletones are also unnecessarily complex to reliably create and maintain if your only goal is to have data with the application area (at least if you really want a full-fledged singleton for this for some reason - all starters don't even understand what a singleton is )

β€œJust create one,” as managed by a bean application, is much easier to develop, test, and maintain. JSF as a framework ensures that only one instance will be created and reused during the lifetime of the web application.

See also:

+4
source

All Articles