Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean that Apache Sling "more REST" than Spring-mvc?

Sometimes vaguely I hear that

Apache Sling more REST than Spring-mvc

from my colleagues.

I don't have possibilities to know about it from them. I have enough experience with Spring-mvc and I am novice in Apache Sling.

Can anyone explain the above quote?

P.S.

I want to see the list of non-REST features of these products.

for example: Spring-mvc allow to use session attributes and it is contradicts REST principe - to be stateless.

like image 280
gstackoverflow Avatar asked Mar 27 '14 17:03

gstackoverflow


People also ask

What is the difference between Spring MVC and REST?

Spring MVC Framework and REST While the traditional MVC controller relies on the View technology, the RESTful web service controller simply returns the object and the object data is written directly to the HTTP response as JSON/XML.

Why would you choose Spring Web MVC over Spring data REST?

In Spring MVC, a controller can handle the requests for all HTTP methods, which is a backbone of RESTful web services. For example, you can handle a GET method to perform read operations, POST methods to create resources, PUT methods to update resources, and DELETE methods to remove resources from the server.

Does Spring MVC use REST?

REST in SpringThe REST API support was introduced in Spring from version 3.0 onwards; since then, it has steadily evolved to the present day. We can create REST resources in the following ways: Using controllers which are used to handle HTTP requests such as GET, POST, PUT, and so forth.

What is Apache Sling used for?

Apache Sling™ is a framework for RESTful web-applications based on an extensible content tree. In a nutshell, Sling maps HTTP request URLs to content resources based on the request's path, extension and selectors.


3 Answers

I agree with others that it's hard to measure the RESTfulness of a framework ;-)

And my knowledge Spring MVC is very limited, so I cannot comment on that.

Apache Sling fosters a RESTful way of designing applications, due to its core design and concepts like resources being first-class citizens, default 1:1 mapping of URLs to the content repository, etc.

If you follow its design patterns and examples you're very likely to end up with an application that's RESTful, with clean URLs, no HTTP sessions, HTTP methods which do the right thing etc.

You can also do non-RESTful things with Sling but it's harder, you'd be fighting against Sling natural way of doing things.

So Sling naturally leads you to RESTful applications. Other frameworks might allow you to be RESTful or not, with equal weight. In Sling the emphasis is clearly on being RESTful, and all the core tools and techniques help you get there.

like image 171
Bertrand Delacretaz Avatar answered Oct 05 '22 21:10

Bertrand Delacretaz


There's no such thing as a framework being more or less RESTful than the others. This is like saying the materials used to build a house make it more or less fitting to a particular architectural style. What will say if your application is more or less RESTful is how you design it, and how your clients access it. You can have a RESTful application using no framework at all, as long as it fills the REST constraints. And you can make an application that isn't RESTful at all if you disregard those.

What will dictate if your application is more or less REST than others isn't the framework you're using, it's:

  • Being stateless.
  • Being cacheable.
  • Clients don't require out-of-band information (HATEOAS).
  • Respecting the standards of the underlying protocol.
  • Respecting the client-server architecture.

Be aware that REST isn't an adequate solution to most problems people have. What most people call REST is simply any HTTP API that isn't SOAP, and your colleagues are probably just trying to appeal to REST as an authority in order to give weight to their personal preferences.

like image 29
Pedro Werneck Avatar answered Oct 05 '22 19:10

Pedro Werneck


Apache Sling is specifically designed to facilitate applications that actually adhere to restful constraints - that is, that are designed to serve resources at URL locations without state change. Spring is more of a general purpose web application infrastructure.

like image 24
Warren Dew Avatar answered Oct 05 '22 21:10

Warren Dew