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.
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.
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.
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.
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.
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.
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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With