2 Replies Latest reply on Oct 23, 2013 6:20 AM by bryncooke

    Retrieving beans using related generic class

    bryncooke

      Hi,

      I wonder if anyone could clarify for me whether it should be possible to get a bean via related generic type or if the type should exactly match?


      For instance:

           class Test implements ConfigurationProvider<ServletContext>


      Should I be able to get the Test bean by selecting?

           Set<Bean<?>> beans = manager.getBeans(new ParameterizedTypeImpl(ConfigurationProvider.class, new Type[]{Object.class}, null)); //(Does not work on weld 2.1.0)

       

      Or does the generic type have to exactly match?

           Set<Bean<?>> beans = manager.getBeans(new ParameterizedTypeImpl(ConfigurationProvider.class, new Type[]{ServletContext.class}, null));


      Many thanks

      Bryn