The work in the Expert Group for JSR 371 progresses and here is a small update. A couple of decisions have been made and the most important one is that the JSR will be layered on top of JAX-RS. The decision was made by voting between this and the alternative of layering it on top of the Servlet API.
What this means for you as a developer is that the stuff you are familiar with from JAX-RS is directly transferable to MVC. As you can see in the simple example below, the only thing that differs from JAX-RS is the @Controller
and @View
annotations.
Note that this code is highly experimental and will most likely change as the work with the specification continues.
import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.mvc.Controller; import javax.mvc.View; @Path("count") public class CountController { @GET @Controller @Produces("text/html") @Path("{id}") @View("counter.jsp") public void view(@PathParam("id") String id) { } }
A more complete example with a little more details can be found at https://github.com/ivargrimstad/mvc-samples. I will continue evolving this example as we go.
The latest versions of the spec and reference implementation can be found here:
- Specification: https://java.net/projects/mvc-spec/pages/Home
- Reference Implementation: https://ozark.java.net/
It looks like it will be short spec 🙂
True, one of the goals is to use the existing functionality where possible and not invent anything that is already there…
… and IMO this is very good approach.