3 Replies Latest reply: Mar 2, 2010 2:44 AM by Gavin King RSS

Singleton pseudo scope

Matthieu Chase Heimer Newbie

Wanted to check before I file a bug on the docs because I'm not 100% sure on this one. The Weld Docs mention a @Singleton pseudo scope as one of the 6 built-in scopes but the spec mentions there being 5 built-in scopes with the one @Dependent pseudo-scope. However the spec mentions @Singleton on session beans.... same thing or different? Did the @Singleton pseudo-scope not make it into the final spec?

  • 1. Re: Singleton pseudo scope
    Gavin King Master

    The @Singleton pseudo-scope is defined by javax.inject, not by CDI. The @Singleton annotation in EJB is something different (not a scope).

  • 2. Re: Singleton pseudo scope
    Matthieu Chase Heimer Newbie

    Regardless of who defines it, should a CDI implementation support it? The Weld docs imply it is supported but the spec doesn't mention that everything from JSR330 would be available.


    Where does it say (directly or indirectly) that I can use a @Singleton scope when I use CDI? Looking at the spec it seems like support for @java.inject.Singleton would fall under the category of a custom scope to be implemented by a portable extension. Wouldn't that mean that it should be a Seam3 feature and not a Weld feature?


    Or is this just something that needs to be clarified in the spec? (any chance of getting a JIRA project for the spec?)


    Thanks.

  • 3. Re: Singleton pseudo scope
    Gavin King Master

    Regardless of who defines it, should a CDI implementation support it?

    Well, there is not exactly a hard requirement in the CDI spec that all APIs defined by JSR-330 are supported by an implementation of JSR-299. However, all EE 6 containers are required by the EE spec to support both 299 and 330, and I imagine that most CDI implementations will support @Singleton out of the box. It would surprise me if an implementation did not support it.