[cdi-dev] [JBoss JIRA] (CDI-420) add a bean-discovery-mode 'scoped'

Mark Struberg (JIRA) issues at jboss.org
Wed Jun 8 01:43:00 EDT 2016

    [ https://issues.jboss.org/browse/CDI-420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13249330#comment-13249330 ] 

Mark Struberg commented on CDI-420:

I fear it's confusing for the user.

Please remember that the whole ticket is mostly for fixing a behaviour which is imo broken since the very early days: to prevent automatically pick up all classes as @Dependent scoped beans, even if they have no single CDI annotation at all. 
Those are in 99.9999% cases just pure waste in our memory.

Otoh we cannot enable this for all classes as there might be some jars which depend on it. Thus we need to activate this per classpath entry.
There was a first attempt to fix this behaviour with the bean-discovery-mode="anotated". And it didn't work out because of the aforementioned problems.

I thought about Martins proposal for two days now. It is certainly interesting but I don't yet see any benefit in having a second configurable exclude mechanism which exceeds this basic rules. 
Are there any other use cases you have in mind? Because if the above reason is the only one then I find it overreaching.

> 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

More information about the cdi-dev mailing list