[cdi-dev] [JBoss JIRA] (CDI-346) Unclear relation between bean discovery and @WithAnnotations

Pete Muir pmuir at bleepbleep.org.uk
Wed Mar 13 08:03:43 EDT 2013


On 12 Mar 2013, at 20:47, Mark Struberg <struberg at yahoo.de> wrote:

> 
> 
> Hi Pete!
> 
> I was drafting on a general 'implicit bean archive' mail for a few days, but I got side tracked and it is/was not yet ready. 
> 
> I feel a bit uncomfortable with the introduction of 'implicit bean archives' in general.

Ok, I don't think at this point we can drop this feature. It was very popular when proposed back in November, including from yourself.

> Or at least I don't yet have enough understanding to think it's well enough defined.

Ok, let's try to work through the issues :-)

> I'm not sure where the benefit over the clear beans.xml yes/no behaviour we had in CDI-1.0 is, but anyway. Let's put this aside and see how it might work
> 
> If I understood it correctly, the intended behaviour is as following:
> 
> * a JAR without any beans.xml but with beans with a CDI scope. Those classes (only the ones with cdi scopes) get scanned.

Yes.

> * only those cdi-scoped classes get fired to ProcessAnnotatedType, right?

Those, and any that would get notified by @WithAnnotations, this allows an extension to easily pick up other classes.

> * the Extension has no way to distinguish whether a class did come from an implicit or explicit bean archive. 

Yeah, I think this is a bug. We have an issue for this from Jozef, which I will address.

> 
> * What happens if the Extension removes the scope annotation via PAT? Will it become @Dependent or not?

Right, it becomes dependent, unless you PAT.veto() it.

> 
> * what about EJBs in such a jar without a beans.xml? Is this also a 'bean defining annotation'?

Yes, all session beans are automatically found. I did this not by making them bean defining annotations (as we also want to pick up those from ejb-jar.xml), but by simply stating they are always picked up.

> Do they lead to firing a PAT for them?

Yes

> Can an Extension rely on it?

Yes.

> While thinking about this: is this even defined in CDI-1.0? Section 12.1 + 11.5.5 define that a PAT must get fired for all jars with beans.xml, but is it forbidden in cdi-1.0 to fire a PAT for e.g EJBs in jars without any beans.xml in them?

It's not forbidden, but the container wasn't required to do it.

> The 'implicit but only a little'

I don't really understand what this statement means, I'm afraid. This is exactly the behaviour you have lobbied for, that only beans with a scope type are picked up. The fact that I have done this with the bean archive language may be what you dislike, but this is just a mechanism to achieve a result.

> behaviour just blurs things imo. My gut feeling is that we will see many corner cases where this will create problems / need for clarification.

Understood, however I don't agree, I think this is a fairly well constrained way to define this, within the existing structures of the specification. So far we've only found the one issue, which is the one around the PAT wanting to detect whether it's an implicit or explicit bean archive, and perhaps changing behaviour based on that.

In general, I think this fairly neatly allows for exactly the behaviour you have lobbied for (that only beans with scope type annotations or session beans are automatically picked up by default), whilst still supporting the 1.0 model.

>  
> 
> LieGrue,
> strub
> 
> 
>> ________________________________
>> From: Pete Muir <pmuir at bleepbleep.org.uk>
>> To: CDI-Dev <cdi-dev at lists.jboss.org>; Mark Struberg <struberg at yahoo.de> 
>> Sent: Tuesday, March 12, 2013 11:25 AM
>> Subject: Fwd: [JBoss JIRA] (CDI-346) Unclear relation between bean discovery and @WithAnnotations
>> 
>> 
>> The words I used were "explicit bean archive" and "implicit bean archive" - explicit because it has a beans.xml so is explicitly a bean archive, and implicit as the inverse of this.
>> 
>> 
>> If you've got other suggestions, I would love to hear them, but as usual, this is the best *I* was able to come up with, and so complaining without providing alternative ideas won't actually result in any improvement ;-)
>> 
>> 
>> Begin forwarded message:
>> 
>> From: "Mark Struberg (JIRA)" <jira-events at lists.jboss.org>
>>> 
>>> Subject: [JBoss JIRA] (CDI-346) Unclear relation between bean discovery and @WithAnnotations
>>> 
>>> Date: 11 March 2013 08:08:41 GMT
>>> 
>>> To: pmuir at bleepbleep.org.uk
>>> 
>>> 
>>> 
>>> Mark Struberg commented on  CDI-346
>>> Unclear relation between bean discovery and @WithAnnotations  
>>> Agree. Plus it's also not possible in an Extension to know from which 'kind' of bean archive the current PAT did come from. We e.g. cannot make this depending on any previously fired ProcessModule event as CDI containers might run the discovery in parallel threads.
>>> If some Extension gets a PAT with a class without any scope, should it handle this class? Well, that depends whether this BDA is an 'automatic' or a 'non-pickup' (whatever non-intuitive wording got chosen finally) bean archive.    
>>> This message is automatically generated by JIRA.
>>> If you think it was sent incorrectly, please contact your JIRA administrators
>>> For more information on JIRA, see: http://www.atlassian.com/software/jira
>> 
>> 
>> 




More information about the cdi-dev mailing list