Difference Between Scope in JSF and Singleton Scope in Spring

Can anyone shade some light on the difference between ApplicationScope (JSF) and Singleton (Spring MVC). I have an application written in jsf in which one of the classes uses the application scope. And when converting to spring, I used the Singleton scope, which, in my opinion, is a bit equivalent to the scope of the application. But you want to go deeper in order to know what actually differs both in areas such as productivity, etc.

+4
source share
1 answer

Both are the same in the sense that after they start, they will live until the application finishes (or the class is garbage collected, which will not happen in a typical Java EE application until you deploy it).

  • Both are shared instances, and you must ensure that they are thread safe.

From Java EE 7 Tutorial

@ApplicationScoped General state for all users to interact with a web application.

From the Spring Documentation :

Spring singleton bean Singleton, Gang of Four (GoF). GoF Singleton , ClassLoader . Spring , bean. , bean Spring, Spring , bean.

, , , oneton bean - (, EAR -), Singleton bean bean / -, EAR) Spring -, ( bean Singleton Bean), .

, , Spring, JSF DI xml/ - . , (, , ).

, @Named @ApplicationScoped + , concurrency right = profit!:)

+1

All Articles