In this post, we will see, how to implement JAX-RS with CXF without using the Spring. Instead of using the Servlet org.apache.cxf.transport.servlet.CXFServlet we will be using the Servlet org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet. When using the CXFNonSpringJaxrsServlet, there is no need for servlet.xml, since the configuration of the endpoints and provider will be taken
automatically done, by the jaxrs.serviceClasses at runtime. Note: this will not generate the WADL file, that's the only disadvantage.
Rest of the items are similar to the normal CXF implementation.
Happy Programming...!!
automatically done, by the jaxrs.serviceClasses at runtime. Note: this will not generate the WADL file, that's the only disadvantage.
Rest of the items are similar to the normal CXF implementation.
<web-app>
<display-name>cxf</display-name>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
</servlet-class>
<init-param>
<param-name>jaxrs.serviceClasses</param-name>
<param-value>com.school.service.StudentService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
Happy Programming...!!
No comments:
Post a Comment