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

Broken example for obtaining unmanaged instance

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

      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().

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

                Created:
                Updated:
                Resolved: