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

Mark Struberg (JIRA) issues at jboss.org
Sun Jan 31 05:02:00 EST 2016

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

Mark Struberg commented on CDI-420:

With getting more and more feedback for cdi-1.1 and 1.2 in the last 2 years it became clear that the bean-discovery-mode 'annotated' is not or less not used by developers! Simply by the fact that not picking up interfaces and stuff create way too many problems with Extensions. That's why I'm pushing this idea again. I just like to rename the new bean-discovery-mode to 'scoped'.

The behaviour is the following:
1.) Scan all interfaces and classes etc just like with 'all'
2.) Fire the ProcessAnnotatedType event for all of them (just like with 'all')
3.) But for all classes in a jar or classpath entry with bean-diescovery-mode=
scoped' _only_ create Bean<T> of those AnnotatedTypes which either
 * have an explicit CDI scope annotation, or
 * are an Interceptor or a Decorator, or
 * are a JavaEE bean, or
 * have a StereoType

This will 
* improve boot times 
* reduce the memory footprint by not storing away tons of useless Bean<T> instances

> 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