Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1957

BeanBuilder should be smarter about qualifiers

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Major
    • 3.0.0.Alpha10
    • 3.0.0.Alpha9
    • Extensions
    • None

    Description

      Currently, adding a couple of beans with the @Default qualifier requires more code than is IMHO necessary:

      Weld builder = new Weld().disableDiscovery().addPackage(false, Main.class);
      builder.addBean().producing(conf.getEmailConfiguration()).addType(EmailConfiguration.class).addQualifier(DefaultLiteral.INSTANCE);
      builder.addBean().producing(conf).addType(MainConfiguration.class).addQualifier(DefaultLiteral.INSTANCE);
      builder.addBean().producing(client).addType(Client.class).addQualifier(DefaultLiteral.INSTANCE).scope(ApplicationScoped.class).disposeWith(c -> c.close());
      builder.addBean().producing(executor).addType(ScheduledExecutorService.class).addQualifier(DefaultLiteral.INSTANCE);
      WeldContainer weld = builder.initialize();
      

      Notice the .addQualifier(DefaultLiteral.INSTANCE) call being repeated for all the beans. The builder should instead handle this automatically.

      Attachments

        Activity

          People

            mkouba@redhat.com Martin Kouba
            rhn-engineering-jharting Jozef Hartinger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: