This example demonstrates how to develop RESTful web service with CDI managed beans and a Servlet 3.0 Web container.
This example currently works only with a standalone GlassFish 4 instance. The easiest way to get the application running is to build it and deploy as follows:
mvn clean package $AS_HOME/asadmin deploy target/cdi-webapp.war
After you successfully deploy the application, visit the following URLs:
Description URL Expected Results A managed bean with no use of injection whatsoever http://localhost:8080/cdi-webapp/helloworldHello WorldShows injection of context objects into the fields of a managed bean. http://localhost:8080/cdi-webapp/singletonOK GET http://localhost:8080/cdi-webapp/singletonShows injection of context objects into the fields of a managed bean. http://localhost:8080/cdi-webapp/singleton/counter42 (initial value, which gets incremented with each request)Shows injection of context objects and path parameters into the fields of a managed bean. http://localhost:8080/cdi-webapp/other/C/DOK GET http://localhost:8080/cdi-webapp/other, c=C, d=DShows injection of path and query parameters into the fields of a managed bean. http://localhost:8080/cdi-webapp/echofield/b?a=aECHO a bA managed bean that uses (but does not inject) a path parameter. http://localhost:8080/cdi-webapp/echo/aECHO a