Should ProviderInjectionEndpoint be using javax.enterprise.inject.Instance vs javax.inject.Provider

8 views
Skip to first unread message

sst...@redhat.com

unread,
Sep 6, 2017, 10:51:33 PM9/6/17
to Eclipse MicroProfile
John pointed out that javax.inject.Provider is from the old JSR-299 spec that CDI 1.0 (JSR-33) extended with javax.enterprise.inject.Instance. He indicated it was preferable to use Instance over Provider, so should the ProviderInjectionEndpoint be using Instance in addition to Provider, or only be testing Instance?

I don't think it would make much difference to a CDI extension, but it could depending on how one is filtering the injection point types.

John D. Ament

unread,
Sep 6, 2017, 11:56:23 PM9/6/17
to Eclipse MicroProfile
I would recommend having tests that deal with both.  Both are valid.  Instance is preferred since it allows you to do qualifier and type refinement, as well as instance destruction.

It should be as simple as swapping a few injection points to Instance.  I wouldn't duplicate the entire test.

John
Reply all
Reply to author
Forward
0 new messages