title: Using Atmosphere-jersey with embedded jetty and Object injection
body: <p>I have a jersey application running in embedded jetty. I want to convert it to use atmosphere-jersey to take advantage of the comet functionality and I'm a bit stuck. Any help greatly appreciated.
  My jersey code uses the jersey ServletContainer configured with a ResourceConfig to specify resource instances</p>
  
  <pre><code>ResourceConfig.registerInstances(resourceInstance);
  new org.glassfish.jersey.servlet.ServletContainer(ResourceConfig);
  </code></pre>
  
  <p>I can't work out how to get the same setup to work with atmosphere. I can see that there's an AtmosphereServlet. Is it possible to provide a resource instance to it?</p>
  
  <p>This is how jersey/jetty is set up at the moment...</p>
  
  <pre><code>import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  import org.eclipse.jetty.server.Server;
  import org.eclipse.jetty.servlet.ServletContextHandler;
  import org.eclipse.jetty.servlet.ServletHolder;
  import org.glassfish.jersey.server.ResourceConfig;
  
  public class HelloWorldJerseyJetty {
  
      // http://localhost:8080/resources/resource
  
      public static void main(String[] args) throws Exception {
  
          Server server = new Server(8080);
  
          ResourceConfig config = new ResourceConfig();
          config.registerInstances(new Resource("Hello World"));
          org.glassfish.jersey.servlet.ServletContainer jerseyServlet = new org.glassfish.jersey.servlet.ServletContainer(config);
  
          ServletContextHandler handler = new ServletContextHandler();
          handler.addServlet(new ServletHolder(jerseyServlet), "/resources/*");
  
          server.setHandler(handler);
          server.start();
          server.join();
  
      }
  
      @Path("resource")
      public static class Resource {
  
          private final String message;
  
          public Resource(String message) {
              this.message = message;
          }
  
          @GET
          @Produces(MediaType.TEXT_PLAIN)
          public String get() {
              return message;
          }
      }
  }
  </code></pre>
  
  <p>How can I switch from jersey to the AtmosphereServlet and how can i configure it to use an instance?</p>
  
  <pre><code>        ResourceConfig config = new ResourceConfig();
          config.registerInstances(new Resource("Hello World"));
          AtmosphereServlet atmosphereServlet = new AtmosphereServlet();
          atmosphereServlet.???
  
          ServletContextHandler handler = new ServletContextHandler();
          handler.addServlet(new ServletHolder(atmosphereServlet), "/resources/*");
  </code></pre>