[cdi-dev] [JBoss JIRA] (CDI-420) add a bean-discovery-mode 'scoped'
Mark Struberg (JIRA)
issues at jboss.org
Tue Feb 2 04:02:00 EST 2016
[ https://issues.jboss.org/browse/CDI-420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13157439#comment-13157439 ]
Mark Struberg edited comment on CDI-420 at 2/2/16 4:01 AM:
-----------------------------------------------------------
Regarding bean-discovery-mode="annotated":
I _never_ saw this in any real world app. Because it makes so many problems. Think about e.g. DeltaSpike @MessageBundle, or all the JPA Archive things. There you just annotated an interface and let the Extension create a Proxy for it. Basically all those who use ProcessAnnotatedType as a 'scanning' tool. All these Extensions don't work with 'annotated' - and there are many, both public and also tons of company internal ones.
Ad 'scoped' vs 'scanning' vs whatever.
I thought pretty long about it. My first take was 'explicit'. Because you have to explicitly define the classes you like to get picked up. Otoh this term doesn't define _what_ you need to define. For example: just an @Inject somewhere would be nuts as the detection would be pretty expensive.
And this was the point which did lead me to 'scoped'. Because that's what you need to do: Define a Scope OR an annotation which leads to a defined default scope (decorator, interceptor or stereotype). Those are _very_ easy and fast to find and are very clear rules imo.
But I'm happy to get further nominations ;)
was (Author: struberg):
Regarding bean-discovery-mode="annotated": I _never_ saw this in any real world app. Because it makes so many problems. Think about e.g. DeltaSpike @MessageBundle, or all the JPA Archive things. There you just annotated an interface and let the Extension create a Proxy for it. Basically all those who use ProcessAnnotatedType as a 'scanning' tool. All this doesn't work
> add a bean-discovery-mode 'scoped'
> ----------------------------------
>
> Key: CDI-420
> URL: https://issues.jboss.org/browse/CDI-420
> Project: CDI Specification Issues
> Issue Type: Bug
> Components: Packaging and Deployment
> Affects Versions: TBD
> Reporter: Mark Struberg
> Fix For: 2.0 (discussion)
>
>
> This is for some future CDI release.
> We currently only have 3 bean-discovery-modes
> * none
> * all
> * annotated
> The spec also currently says that ProcessAnnotatedType will only get fired (12.4) for
> • each Java class, interface or enum deployed in an explicit bean archive, and
> • each Java class with a bean defining annotation in an implicit bean archive.
> • each session bean
> Which means that we do not get the ProcessAnnotatedType (PAT) event for any class in an 'annotated' or 'implicit' BDA which does _not_ have a bean defining annotation.
> It might be useful to fire the ProcessAnnotatedType for all classes, but do not pick them up as Beans if they (after PAT) do not have a valid scope. Effectively doing the processing but not make them @Dependent automatically if there is no scope annotation at the end of the PAT processing.
> I'm not yet 100% sure how important this distinction is in practice. Just writing this up to not forget about the idea...
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the cdi-dev
mailing list