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).
Architecture and design
At the moment, the integration of Apache CXF and CDI revolves around two key components, residing in new module called cxf-integration-cdi
- CXFCdiServlet servlet
- JAXRSCdiResourceExtension portable CDI extension
The fact of including cxf-integration-cdi as a dependency allows JAXRSCdiResourceExtension portable CDI extension to be discovered by CDI container. The JAXRSCdiResourceExtension creates the instance of the Bus and registers it with BeanManager. From this point, the Bus instance is a regular CDI bean (with @Application scope) available for injection. This instance of the Bus is being injected into CXFCdiServlet servlet once it is initialized by servlet container.
Depending on the design, JAXRSCdiResourceExtension may use zero-based configuration approach or rely on particular JAX-RS application instances.
Zero-based Configuration