...
- the instance of the JAX-RS Application (annotated with @ApplicationPath) is being created and registered with BeanManager
- all instances of the discovered JAX-RS providers (annotated with @Provider) are being created and registered with BeanManager
- all instances of the discovered JAX-RS resources (annotated with @Path) are being created and registered with BeanManager
Lastly, the instance of the JAXRSServerFactoryBean is being created and configured with all service beans and providers discovered before. Additionally, the providers are enriched with the services for javax.ws.rs.ext.MessageBodyReader and javax.ws.rs.ext.MessageBodyWriter, loaded via ServiceLoader. From this moment, Apache CXF application is ready to serve the requests. The quick example is shown below.
The empty JAX-RS Application:
Code Block | ||||
---|---|---|---|---|
| ||||
@ApplicationPath("/api")
public class BookStoreApplication extends Application {
} |
And one JAX-RS resource:
Code Block | ||||
---|---|---|---|---|
| ||||
@Path("/bookstore/")
public class BookStore {
@Inject private BookStoreService service;
@GET
@Path("/books/{bookId}")
@Produces(MediaType.APPLICATION_JSON)
public Book getBook(@PathParam("bookId") String id) {
return service.get(id);
}
} |