title: Where do @Context objects come from
body: <p>I've been searching everywhere, but can't seem to find a clear answer...</p>
  
  <p>What is the mechanism whereby a server (glassfish for my problem) injects actual objets that are annotated with @Context? More specifically, if I wanted to write a class that did something like:</p>
  
  <pre><code>@Path("/")
  public class MyResource {
    @GET
    public String doSomething(@Context MyObject obj) {
      // ...
    }
  }
  </code></pre>
  
  <p>then how would I do it? Where is it that the MyObject is instanciated, who does it, and how?</p>
  
  <p>Edit: I've seen stuff like the following:</p>
  
  <p><a href="https://stackoverflow.com/questions/3047400/using-context-provider-and-contextresolver-in-jax-rs">Using @Context, @Provider and ContextResolver in JAX-RS</a></p>
  
  <p><a href="http://jersey.576304.n2.nabble.com/ContextResolver-confusion-td5654154.html" rel="nofollow noreferrer">http://jersey.576304.n2.nabble.com/ContextResolver-confusion-td5654154.html</a></p>
  
  <p>However, this doesn't square with what I've seen, e.g. in the constructor of org.neo4j.server.rest.web.RestfulGraphDatabase, which has the following signature:</p>
  
  <pre><code>public RestfulGraphDatabase(
    @Context UriInfo uriInfo,
    @Context Database database,
    @Context InputFormat input,
    @Context OutputFormat output,
    @Context LeaseManager leaseManager )
  </code></pre>