Introduction
The JAX-RS 2.0 specification (JSR-339) mandates the support of CDI and Apache CXF starting from the version 3.0 introduces the initial support of this feature. As the starting point, the emphasis has been done on supporting embedded Jety 8/9 and Tomcat 7/8 containers as primary deployment (though other application servers will be supported in the future).
...
Deploying with embedded Jetty 8/9 (programmatic configuration)
With Jetty 8/9 it possible to create fully embeddable REST / JAX-RS servers without web.xml or WAR files involved. For Apache CXF applications which are using CDI 1.1, the CXFCdiServlet servlet should be used as a starting point.Following examples demonstrates the necessary configuration points in order to create embedded Jetty 8/9 instance.
Code Block | ||||
---|---|---|---|---|
| ||||
// Register and map the dispatcher servlet
final ServletHolder servletHolder = new ServletHolder(new CXFCdiServlet());
final ServletContextHandler context = new ServletContextHandler();
context.setContextPath(contextPath);
context.addEventListener(new Listener());
context.addEventListener(new BeanManagerResourceBindingListener());
context.addServlet(servletHolder, "/rest/*");
server.setHandler(context); |
TODO: in progress
Deploying with embedded Jetty 8/9 (WAR-based deployment)
...