-
1. Re: Scope type without @Scope or @NormalScope
nickarls Feb 9, 2010 8:09 AM (in response to koichik0818)If this it the case, I would call it a bug. Could you file a JIRA?
-
2. Re: Scope type without @Scope or @NormalScope
koichik0818 Feb 9, 2010 10:30 AM (in response to koichik0818)Does that mean it's a Weld's bug?
If so, I have another question.CDI spec (2.4.2. Defining new scope types) says
Custom scopes are normally defined by portable extensions, which must also provide a context object, as defined in Section 6.2, 'The Context interface', that implements the custom scope.But, I can use a scope type without register (I must register only context).
Is this portable? Depends on implementation(Weld)? or Weld's bug?
-
3. Re: Scope type without @Scope or @NormalScope
nickarls Feb 9, 2010 1:29 PM (in response to koichik0818)Without digging that much into the spec, I'm guessing:
They are not linked. Context.getScope() returns the scope type but I'm not sure if the container is obliged to check if it's a registered scope. Of course, if you intend to use it normally @FooScoped, you should register it.
-
4. Re: Scope type without @Scope or @NormalScope
koichik0818 Feb 10, 2010 2:21 AM (in response to koichik0818)Thanks for the reply, but I want to know the correct interpretation of CDI spec.
I think that the Weld's behavior is rational.
1) I do not have to register a scope type with @Scope or @NormalScope.
2) I must register a scope type without @Scope or @NormalScope.However, 2) does not match CDI spec.
Then I do not have to call BBD#addScope() when using Weld.In CDI spec, when do I have to register a scope type?
Why is there BBD#addScope()? -
5. Re: Scope type without @Scope or @NormalScope
pmuir Feb 17, 2010 12:23 PM (in response to koichik0818)
Koichi Kobayashi wrote on Feb 10, 2010 02:21:
Thanks for the reply, but I want to know the correct interpretation of CDI spec.
I think that the Weld's behavior is rational.
1) I do not have to register a scope type with @Scope or @NormalScope.
2) I must register a scope type without @Scope or @NormalScope.
However, 2) does not match CDI spec.
Then I do not have to call BBD#addScope() when using Weld.
In CDI spec, when do I have to register a scope type?
Why is there BBD#addScope()?Both (1) and (2) are correct and are contained in the spec. addScope() has the effect of causing the CDI implementation to see the annotation as having @Scope/@NormalScope.
-
6. Re: Scope type without @Scope or @NormalScope
koichik0818 Feb 17, 2010 2:04 PM (in response to koichik0818)
Pete Muir wrote on Feb 17, 2010 12:23:
Both (1) and (2) are correct and are contained in the spec.(2) means that I can use a scope type without @Scope or @NormalScope.
for example,
@Target( { TYPE, METHOD, FIELD }) @Retention(RUNTIME) public @interface BadScoped {}
I can use the scope type if (and only if) I register it.
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd) { bbd.addScope(BadScoped.class, true, false); }
But CDI spec (2.4.2. Defining new scope types) says
All scope types must also specify the @javax.inject.Scope or @javax.enterprise.context.NormalScope meta-annotationTherefor, @BadScoped Should become error, shouldn't it?
-
7. Re: Scope type without @Scope or @NormalScope
pmuir Feb 17, 2010 2:09 PM (in response to koichik0818)This is not the intent of the spec, I guess it just needs some clarification - Gavin reads these forums, so will pick it up.
-
8. Re: Scope type without @Scope or @NormalScope
gavin.king Feb 17, 2010 3:21 PM (in response to koichik0818)
Pete Muir wrote on Feb 17, 2010 12:23:
Both (1) and (2) are correct and are contained in the spec. addScope() has the effect of causing the CDI implementation to see the annotation as having @Scope/@NormalScope.Right, exactly.
-
9. Re: Scope type without @Scope or @NormalScope
gavin.king Feb 17, 2010 3:24 PM (in response to koichik0818)There is no problem here, the whole SPI is understood to be about overriding and
messing with
the annotation-based metamodel. That's the point of it. -
10. Re: Scope type without @Scope or @NormalScope
koichik0818 Feb 17, 2010 4:44 PM (in response to koichik0818)Thanks for the reply. I understood it.