What is the difference between @ApplicationScoped and @Singleton scopes in CDI?

后端 未结 6 1007
一生所求
一生所求 2020-12-02 11:00

In CDI there is the @ApplicationScoped and the (javax.inject) @Singleton pseudo-scope. What is the difference between them? Besides th

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 11:32

    @Singleton in JSR-299 refers to Singleton session beans (javax.ejb.Singleton, not javax.inject.Singleton), not JSR-299 managed beans in a built-in scope called Singleton.

    You might find in your server that @ApplicationScoped is one-per EAR or one-per WAR/EJB-JAR as it is not clear in the specification, but you should definitely not expect it to be one per JVM.

提交回复
热议问题