jeudi 23 juillet 2015

Jax-rs how do I nest resources while passing the injection properties

I've been developing jax-rs webapi and I'm struggling to find the answer to this question. I have the following pieces of code:

`

@Path("user")
@Stateless
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class UserController {

@Inject
private UserDAO userDAO;

@Inject
private OfferDAO offerDAO;

@Inject
private UserContext current;


@Path("addOffer")
public OfferController invokeOffers(@Context ResourceContext rc) {
    return rc.initResource(new OfferController(current));
}
}

And this one: `

 @Path("/")
 public class OfferController {

private UserDAO userDAO;

private OfferDAO offerDAO;

private UserContext current;

public OfferController() {
}

And my question is how do I pass the injections from UserController to OfferController?

Aucun commentaire:

Enregistrer un commentaire