2.4.4 says:
"If there are two different stereotypes declared by the bean that
declare different default scopes, then there is no default scope and
the bean must explicitly declare a scope. If it does not explicitly
declare a scope, the container automatically detects the problem and
treats it as a definition error."
This is the rule that applies in this situation. The bean is required
to explicitly resolve conflicts between the scope declarations of its
stereotypes.
On Mon, Jan 18, 2010 at 9:43 AM, Pete Muir <pmuir(a)redhat.com> wrote:
On 18 Jan 2010, at 07:52, Stuart Douglas wrote:
> Does the spec define what happens in the following situation?
>
> @RequestScoped @Stereotype @Target(TYPE) @Retention(RUNTIME) public @interface Action
{}
>
> @ApplicationScoped @Action @Stereotype @Target(TYPE) @Retention(RUNTIME) public
@interface Home {}
>
> @Home
> public class MyBean{}
2.7.1.5 "Stereotype declarations are transitive—a stereotype declared by a second
stereotype is inherited by all beans and other ste- reotypes that declare the second
stereotype." means that the way the stereotypes of MyBean are computed as the
transitive closure of the stereotype graph. Which means MyBean has two stereotypes, @Home
and and @Action.
And the scopes is covered in 2.4.4, "If there are two different stereotypes declared
by the bean that declare different default scopes, then there is no default scope and the
bean must explicitly declare a scope. If it does not explicitly declare a scope, the
container automatically detects the problem and treats it as a definition error."
(it's an error).
BTW we don't check stereotypes which aren't used.
>
>
> As far as I could see the spec does not define what to do when stereotypes declare
stereotypes that have conflicting scopes. In this situation it would make sense to have
Home's scope override Actions, but we can also get situations like this:
>
>
> @RequestScoped @Stereotype @Target(TYPE) @Retention(RUNTIME) public @interface Action
{}
>
> @ApplicationScoped @Stereotype @Target(TYPE) @Retention(RUNTIME) public @interface
Home {}
>
> @Stereotype @Home @Action @Target(TYPE) @Retention(RUNTIME) public @interface
HomeAction {}
>
> @Home
> public class MyBean{}
>
> I think this should be an error.
Likewise :-)
_______________________________________________
weld-dev mailing list
weld-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/weld-dev
--
Gavin King
gavin.king(a)gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org