Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-332

Broken example for obtaining unmanaged instance

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 1.1.FD
    • 1.1.PFD
    • None
    • None

    Description

      The example in the spec text and javadoc:

      Unmanaged unmanagedFoo = new Unmanaged(Foo.class);
      UnmanagedInstance fooInstance = unManagedFoo.newInstance();
      Foo foo = fooInstance.produce().inject().postConstruct();
      // Use the foo instance
      fooInstance.preDestroy().dispose();
      

      should be replaced with something like this:

      Unmanaged<Foo> unmanagedFoo = new Unmanaged<Foo>(Foo.class);
      UnmanagedInstance<Foo> fooInstance = unmanagedFoo.newInstance();
      Foo foo = fooInstance.produce().inject().postConstruct().get();
      // Use the foo instance
      fooInstance.preDestroy().dispose();
      

      Note the generics, unManagedFoo -> unmanagedFoo and missing get().

      Attachments

        Activity

          People

            pmuiratbleepbleep Pete Muir (Inactive)
            mkouba@redhat.com Martin Kouba
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: