I would like to add the buisiness bean service to an additional resource, which is defined in the allocated class and delivered by the auxiliary resources locator.
Code example:
Root resource
@RequestScoped
@Path("service")
public class MyResource {
@Context
ResourceContext resourceContext;
@Path("subservice")
public MySubResource locateToSubResource () {
return resourceContext.getResource(MySubResource.class);
}
}
Corresponding resource
@RequestScoped
public class MySubResource {
@Inject
private BusinessBean businessBean;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String get () {
return businessBean.doStuff();
}
}
Jersey will not have CDI to cause dependencies ... Note that resources are managed objects. Otherwise, it would even be impossible to insert a bean in the root resource ( here I push the number of views of my other questions to get more opinions ;-) )
I tried everything I could, but it just won't work ...
I am currently using libraries that come with glass fish 4.
And, of course, thank you in advance (almost forgot)!