In a CDI extension, what's the easiest way to tell whether an injection point will be satisfied? -


i writing cdi extension.

what easiest way find out if given injection point satisfied during bean deployment, , remove if won't satisfied?

processinjectionpoint-time early, because bean discovery hasn't completed yet, can't tell, of given injectionpoint, whether bean exists satisfy it.

processinjectiontarget-time seems wrong place, because although injection points have been read there isn't way remove one.

i need event lets me remove injection point injection target if can determine injection point won't satisfied.

(background: messing programmatically translating guice's com.google.inject.inject annotation (which features optional attribute).)

i don't think possible that, not way @ least. issue sounds similar discussed in cdi-45 issue, might worth describing use case there.

for case, 1 thing comes me usage of @inject instance<mybeanclass> instead of classical injection. allows detect (in runtime) whether have (or more one) bean satisfy ip. don't know com.google.inject.inject , optional feature, cdi instance seems pretty close that.

edit: colleague of mine came 1 brilliant idea might you. still use extension , observe afterbeandiscovery phase. want verify if there unsatisfied resolution manually using beanmanager. purpose go bm.resolve(bm.getbean()). if find of optional ips not satisfied, want call afterbeandiscovery.addbean(mywrapperbean). mywrapperbean impl (wrapper) of javax.enterprise.inject.spi.bean interface. wrapper 'dummy producer' returning null.

and should it, although not work custom beans, e.g. beans added via afterbeandiscovery, guess ok you.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -