For Java RESTful services, is JAX-RS better than an MVC platform like Swing, Grails or Play?

For example, the Play-framework supports RESTful services, such as: RESTful on Play! framework

How does this compare with something like a Jax-RS Jersey implementation? Is a platform like β€œThe Game” revolving around Jersey because all these are cool bells and whistles and this is also REST?

Developer productivity is important, but it is the right implementation. Perhaps using the MVC structure for REST services is "wrong"?

Please note that only RESTful services, no user interface components at all.

+8
rest jersey grails jax-rs playframework
source share
3 answers

Even though not using β€œMVC” for RESTful services is wrong, there are some pros and cons compared to using the JAX-RS implementation.

(Disclaimer: I used only Jersey and Play! For fun, not for production-class systems, so I compiled my comments most of all in MVC and JAX-RS. Keep in mind that these are broad generalizations.)

MVC frameworks - at least those that are considered compatible with developers and "spots" - usually save you from having to create a save level (part of the model). Most of them also simplify the "routing" of requests, using either forests, or conventions, or some configuration. The disadvantage is that you have to comply with some conventions for your controllers and usually have to write a view for each resource (or create layers of abstractions to avoid overwriting the same code).

JAX-RS stands out when defining routing (using Java annotations), and also removes any class of service restrictions. In my experience, this has significantly reduced the amount of template code and developer overhead. Jersey and Apache CXF also handle XML or JSON serialization using JAXB annotations, eliminating the need to define a view in an MVC context. The downside here is that you need to figure out your own level of ORM or persistence, which can be good or bad depending on whether you are building on top of existing data or creating a new system (or using something other than JPA / RDBMS for example , NoSQL Data Warehouse).

My personal comment: Play! it's a really cool frame, but I would choose CXF (or Jersey) as part of MVC any day to create a RESTful service. In my experience, this frees up the developer to focus on the logic needed for the service, and opens up options for different approaches to the database. The right tool for the right job.

+11
source share

Typically: for Scala, use Play. For Java, use a jersey.

You can use Jersey / Scala and Play / Java; I did both. It works. It's not bad. But if you have no particular reason for this, I would not mix ecosystems. Java and Scala are interoperable, but they have different ecosystems, I would avoid adding Java isms if you use Scala or Scala -isms and dependencies if you use direct Java.

Jersey and Game are usually close to REST services. None of them have any killer functions over the other.

Jersey defines URL mappings in annotations; Play defines them in a service route file. And they combine or have a different integration quality with different libraries for things like XML, JSON, database, testing, bullying, dependency injection libraries and application server deployment.

In the Java world there are JMS, Spring, JUnit, jdbi / hibernate / jpa, Jetty / Grizzly. In the Scala world there is Akka, specs2 / ScalaTest, Anorm / slick. Jersey is better for the first world, Scala for the second. You can definitely cross over with this, but it will be a little less elegant and may require more glue coding.

+6
source share

JAX-RS is the standard, and implementations can be created by different vendors. Jersey is one such implementation. Other structures may use JAX-RS, but are not standards. So this is not a one-to-one comparison.

I had never heard of Play before, but it looks interesting, more like Rails and Django than Jersey. What I like about Jersey is that it can be integrated into existing Java applications by simply adding a JAR and declaring some things in web.xml. What I find confusing regarding Jersey and JAX-RS is routing.

Playing seems to make routing easier, however, correct me if I'm wrong, it looks like this is a universal structure and cannot be used with other servlets in the same web application.

+1
source share

All Articles