Hi all,

On 2015-01-18 10:16, Maarten Boekhold wrote:
Say I have an existing instance of org.eclipse.jetty.server.Server, and an existing class that has my JAX-RS annotations, how can I go about 'adding' an instance of that class to my Server object so that incoming requests are dispatched to my instance?

Did some more searching, and I might have stumbled across something. I found a reference to a CXFNonSpringJaxrsServlet, which seems to be the way to go.

If I understand the structure correctly, I'd do something like:

 * ctx = new CXFNonSpringJaxrsServlet()
 * holder = new ServletHolder(ctx)
     o holder.setName("jax-rs servlet")
     o /tell 'holder' to dispatch requests to a specific instance/
 * handler = new ServletHandler()
 * handler.addServlet(holder)
 * contextHandler = new ContextHandler(baseURI)
 * contextHandler.setHandler(handler)
 * collectionHandler = myserver.getHandler()
 * collectionHandler.addHandler(contextHandler)

I'm a bit confused still about the part where we tell the ServletHolder (or CFXNonSpringJaxrsServler?) to dispatch incoming requests to a specific object? The example I've seen of CXFNonSpringJaxrsServlet uses setInitParameter("javax.ws.rs.Application", "some.class.name"), but that implies that CXF manages the lifecycle of the application object, which won't work for me. I need to manage the lifecycle myself.

Maarten

Reply via email to