Jersey – The @Context annotation for injection. How does it work?

I’ve run into some interesting results with the Rules of Injection, here’s what I’ve found:

public class TodoResource{
  @Context
  UriInfo uriInfo; // Set second
  public TodoResource(@Context UriInfo value){
    uriInfo = value; // Set first (makes sense)
  }
  @Context
  public void setUriInfo(UriInfo value){
    uriInfo = value; // Set third
  }
}

I hope this helps.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)