Jakarta REST (JAX-RS) defines it’s own dependency injection using the @Context
annotation. REST resources also support CDI injection
if you enable CDI on the REST resource class (e.g. using a bean-defining annotation like @RequestScoped
).
But injection doesn’t work out of the box on JAX-RS sub-resources. How to create sub-resources so that both injection mechanisms work also in sub-resources? I’ll show you, it’s very easy.
(more…)