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

BeanBuilder.produceConstant()

XMLWordPrintable

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

      Proposal to add a method:

      <U extends T> BeanBuilder<U> produceConstant(U instance);
      

      This would be a shortcut so the common case when an existing instance whose lifecycle is not managed by CDI is exposed to CDI so instead of

      Foo existing = getFoo();
      builder.produceWith(() -> existing)
      

      you can use

      Foo existing = getFoo();
      builder.produceConstant(existing)
      

      The name is terrible and should really actually implement a better one. I can only think of:
      produceConstant()
      produceSingleton()
      produceInstance()
      produce()

      at the moment but neither of them seems right so we should keep searching for a good one.

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

                Created:
                Updated:
                Resolved: