You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Martin Kouba (JIRA)" <ji...@apache.org> on 2017/08/10 05:25:00 UTC

[jira] [Commented] (OWB-1209) Custom bean with isAlternative()=true should not be automatically enabled

    [ https://issues.apache.org/jira/browse/OWB-1209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16121074#comment-16121074 ] 

Martin Kouba commented on OWB-1209:
-----------------------------------

bq. If someone adds an Alternative Bean via an Extension then it's assumed that is is active for this Module.
This is the "feature" I'm questioning in this issue. If you add a custom bean with {{isAlternative()=true}} it should behave like if there is a bean class annotated with {{@Alternative}}. Otherwise, you wouldn't be able to add a custom bean which is only enabled when needed.

Again, check 5.1.1.2 Declaring selected alternatives for a bean archive. In case of OWB, the bean archive is the module. Still, the container should call {{isAlternative()}}, {{getBeanClass()}} ,etc.

> Custom bean with isAlternative()=true should not be automatically enabled
> -------------------------------------------------------------------------
>
>                 Key: OWB-1209
>                 URL: https://issues.apache.org/jira/browse/OWB-1209
>             Project: OpenWebBeans
>          Issue Type: Bug
>            Reporter: Martin Kouba
>            Assignee: Mark Struberg
>
> It seems that if you register a custom bean where {{isAlternative()}} returns true, the bean is automatically enabled. However, the container should use {{getBeanClass()}}, see also "Declaring selected alternatives for a bean archive":
> {quote}
> For a custom implementation of the Bean interface defined in The Bean interface, the container calls isAlternative() to determine whether the bean is an alternative, and getBeanClass() and getStereotypes() to determine whether an alternative is selected in a certain bean archive.
> {quote}
> Moreover, if I specify the bean class of a custom bean in the {{beans.xml}} I get :
> {noformat}
> Given alternative class : org.jboss.cdi.builtinbeans.IntegerEventBean is not annotated wih @Alternative or not an enabled bean
> {noformat}
> To reproduce, checkout https://github.com/mkouba/alternative-builtin-beans and modify https://github.com/mkouba/alternative-builtin-beans/blob/master/src/test/java/org/jboss/cdi/builtinbeans/BeansXml.java#L25 to always return beans.xml with enablement. Then run:
> {noformat}
> mvn clean test -DcdiImpl=owb1
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)