Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [rest-dev] [External] : Deprecating @Context and Supporting CDI



James R. Perkins

Principal Software Engineer

Red Hat



On Tue, Mar 25, 2025 at 10:27 AM Santiago Pericasgeertsen <santiago.pericasgeertsen@xxxxxxxxxx> wrote:
Hi,

 Thanks for starting this James, I agree we need to get this going.

 Inlined ...

I'd like to propose we make an attempt to resolve the issue of deprecating @Context and supporting CDI.

 +1

My proposal is that we add @Deprecated(forRemoval = true) to the @Context annotation. We should probably also deprecate the ContextResolver as that can be replaced by a CDI producer.

 I suspect we have agreement on this. +1 for me.

For the client, I think we should just be explicit in the specification that if a client is running within a CDI container, that CDI will be supported.

 Yes, it must be supported. 

If it's outside a CDI container, it will not be.

 Correct.

The question there becomes, how do we support injection for resources which @Context injection previously worked on. We could just say, it no longer supports it and you need to boot a CDI container if you want that. Or, potentially, there is a way to say we support Jakarta Injection and allow @Inject to effectively replace @Context.

 We should make the transition as smooth as possible, if we can support @Context via CDI, it would be a better option IMO. However, I’d like to hear from those actually implementing the spec on this one.

I agree on making the transition smooth. We could potentially I guess make @Context a qualifier, but I'm not sure otherwise how we'd get it to work. Next week I will try to look at how this could be done in RESTEasy.

Currently RESTEasy does allow for field injection of all the types @Context works with. It doesn't yet work for method parameters or constructor parameters well, but that is something I will shift some focus to.
 

— Santiago


Back to the top