Alex Rivera | Logout

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

Asked 2010-12-29T16:28:06.123
124

In CDI there is the @ApplicationScoped and the (javax.inject) @Singleton pseudo-scope. What is the difference between them? Besides the fact that @ApplicationScoped is proxied, and @Singleton is not.

Can I just change my @Singleton bean to @ApplicationScoped? Can @ApplicationScoped bean have two (or more) instances?

Edit
Report

1 Answer

10

@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.

answered 2011-01-08T14:26:23.493

Your Answer