4 Replies Latest reply on Mar 26, 2013 11:33 AM by Ievgen Shulga

    CDI alternative stereotype don't work properly with JBoss 7.1.1.

    Ievgen Shulga Newbie

      Hi everyone,

       

      I want to apply alternative stereotype, but cant make it work. I have 2 implementation of interface:

       

      @Stateless

      @AlternativeStereotype

      public class ItemExtensionServiceBean implements ItemService {

       

      and

       

      @Stateless

      public class ItemServiceBean implements ItemService {

       

      alternative stereotype annotation:

       

      @Alternative

      @Stereotype

      @Retention(RUNTIME)

      @Target({ TYPE, METHOD, FIELD })

      public @interface AlternativeStereotype {

       

      beans.xml:

       

      <alternatives>

              <stereotype>org.jboss.as.quickstarts.cdi.annotation.AlternativeStereotype</stereotype>

      </alternatives>

       

      and JSF bean where I inject ItemService interface.

       

      @Named("itemBean")

      @RequestScoped

      public class ItemBean {

          @Inject

          private ItemService itemService;

       

      But after deploy aletrnative implementation ItemExtensionServiceBean is not used.

      Tutorial http://docs.jboss.org/weld/reference/1.1.0.Final/en-US/html/stereotypes.html says it supposed to work.

       

      1. Is it supopsed to work?

      2. How can I make it work?

      I have a simple reproducer on github: https://github.com/ishulga/cdi

       

      Thanks,

      Ievgen.