mvc-api icon indicating copy to clipboard operation
mvc-api copied to clipboard

Support for parameter injection in CDI

Open chkal opened this issue 5 years ago • 8 comments

Issue by mvcbot Thursday Oct 16, 2014 at 17:01 GMT Originally opened as https://github.com/mvc-spec/mvc-spec/issues/16


Original issue MVC_SPEC-4 created by Santiago Pericas-Geertsen:

Data binding in MVC will likely take advantage of injection in general, and parameter in injection in particular. Will CDI.next be able to handle the kind of parameter injection that MVC needs?

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Monday Jan 05, 2015 at 18:10 GMT


Comment by Santiago Pericas-Geertsen:

Layering on top of JAX-RS, this becomes more of a JAX-RS issue than an MVC one. However, since MVC is focused exclusively on CDI (unlike JAX-RS), we should look for opportunities to improve parameter injection.

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Monday Mar 09, 2015 at 18:03 GMT


Comment by Santiago Pericas-Geertsen:

Under discussion with CDI spec lead.

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Thursday Mar 19, 2015 at 11:00 GMT


Comment by antoinesd:

You'll find my parameter injection POC here: https://github.com/antoinesd/CDI-Sandbox/tree/CDI-1.2/param-inject

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Thursday Mar 19, 2015 at 11:28 GMT


Comment by Jozef Hartinger:

Who is calling the methods whose parameters should be injected? If it is the MVC implementation code calling them then there is no need for any further CDI support for this. The caller (MVC impl) can use the existing CDI SPI to obtain values for the parameters and call the method with these values.

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Thursday Mar 19, 2015 at 12:17 GMT


Comment by Santiago Pericas-Geertsen:

It's actually done through JAX-RS. But that's beyond the point, there is no question that this can be done "manually". The point is that it shouldn't be done in multiple places (APIs) and possibly in incompatible ways; it should really be factored out and placed where it belongs which is CDI. As an example, JAX-RS supports its own parameter injection mechanism and has never been able to fully align with CDI, among other reasons, due to this missing feature.

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Thursday Mar 19, 2015 at 12:25 GMT


Comment by Jozef Hartinger:

I see. So there is nothing actually preventing this right now. The painful point is that it requires several API calls and your request is to add an abstraction to CDI to cover those several steps in a single API call. Is that correct?

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Tuesday Jul 14, 2015 at 12:52 GMT


Comment by Manfred Riem:

Jozef, that is indeed correct. Is it possible to get that in the BeanManager API?

chkal avatar Jul 19 '20 09:07 chkal

Comment by mvcbot Wednesday Mar 30, 2016 at 07:46 GMT


Comment by rmannibucau:

Like Antoine showed it is doable - even with CDI 1.0 - with a small glue code. Now for JAX-RS it is pretty clear to me it is not the way to go otherwise you would loose - or get in a not deterministic way - the JAX-RS bindings (@Context, @XParam) which are not CDI instances - and will not be cause primitives for instance are not supported by CDI.

chkal avatar Jul 19 '20 09:07 chkal