[cdi-dev] [JBoss JIRA] (CDI-377) automatic JSR-330 annotation processing problematic

Antoine Sabot-Durand (JIRA) issues at jboss.org
Fri Feb 14 03:41:29 EST 2014

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

Antoine Sabot-Durand commented on CDI-377:

You can write CDI code in @Singletons as long as your archive also has something else than singletons in it. Agreed that this is more complicated than just getting rid of @Singleton. On the other hand, all CDI implementations are also supposed to implement CDI-330 so I am no sure if we can just get rid of it.

I agree [~jharting]. We have to support all JSR-330 (including {{@singleton}}) but specify that {{@singleton}} *alone* cannot trigger implicit CDI discovery for the present jars. 

# Deal with @Singleton somehow. For instance, we could keep @Singleton a bean defining annotation but say that out of the bean defining annotations used in a bean archive, at least one has to be a normal scope or a built-in scope for the bean archive to be recognized. That way we would still be picking up @Singletons as long as they are used together with pure CDI scopes. If there are only @Singletons or non-normal non-builtin scopes in the archive, it will not be recognized. This solution is:
#* similar to your recent proposal
#* probably trickier to define nicely
#* backwards incompatible, but the class of applications possibly affected by this is very small (basically only the apps using only @Singleton or non-normal non-builtin scopes)

And saying that you forgot all CDI apps that are using {{@Singleton}} only but have explicit CDI activation thru {{beans.xml}} file. It makes the number of impacted apps very small.
> automatic JSR-330 annotation processing problematic
> ---------------------------------------------------
>                 Key: CDI-377
>                 URL: https://issues.jboss.org/browse/CDI-377
>             Project: CDI Specification Issues
>          Issue Type: Bug
>          Components: Java EE integration
>    Affects Versions: 1.1.PFD
>         Environment: glassfish-4
>            Reporter: Reuben Pasquini
>              Labels: CDI_spec_chge, CDI_tck_chge
>             Fix For: 1.2 Proposed
> The jsr-330 dependency injection annotations (javax.inject.*) find use in javase environments using IOC packages like guice.
> Adding a dependency on a jar that uses guice or whatever in a javase environment
> to a war deployed to a jee7 container 
> results in CDI processing annotated classes intended for 
> app-managed injection.  See this ticket filed with guava for a concrete example:
>     https://code.google.com/p/guava-libraries/issues/detail?id=1433

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