Restlet MVC

7 messages Options Options
Embed this Post
Permalink
Gan123

Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink

      i am creating a web application using Restlet based on MVC. i have configured ServlerServlet to invoke my Application class, where i have all the URI mappings. i am planning to use the Application class as controller and Resource to implement business logic with other required patterns.

can any one suggest me whether this is the correct way to go ahead to implement MVC application in RESTlet? how and when the Application will be loaded? is it for every request or once per application ?

Thanks in advance.
Thierry Boileau

Re: Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hello,

there is only one instance of an Application (this principle also applies to instances of Restlet sub classes) whereas instances of the Resource class are generated at runtime. One instance of Resource is in charge to handle one pair of Request/Response.
Generally, the constructor of a Resource is the place where you retrieve the underlying business objects. This helps to know if your Resource is available or not, what is it's current state, etc. Then the acceptRepresentation, removeRepresentations, etc methods are the places to implement business logic.


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

      i am creating a web application using Restlet based on MVC. i have
configured ServlerServlet to invoke my Application class, where i have all
the URI mappings. i am planning to use the Application class as controller
and Resource to implement business logic with other required patterns. 

can any one suggest me whether this is the correct way to go ahead to
implement MVC application in RESTlet? how and when the Application will be
loaded? is it for every request or once per application ? 

Thanks in advance.
Rob Heittman

Re: Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Gan123
This is a purely theoretical observation and not really meant as an answer, but I did want to sort of get it on the record here.

The MVC paradigm is a specific separation of concerns architecture which has gained wide conceptual support because it has long been generally considered best practice for GUI applications.  Overlaying MVC onto the internals of a RESTful web application may encourage correct separation of concerns,  but also may not.  MVC alone does not capture separations of concern at multiple layers of an n-tier application.

REST works very well with a rich client (GWT, Flex RIA, SWT, Swing...) that has its own complex UI, ideally implemented using the MVC pattern.  As Thierry says, the internals of a Restlet application can be composed using an MVC way of thinking.  Here, though, the MVC pattern is not an automatic best practice and you may do better to just study the concerns in your server and leveraging the concepts in Restlet (which in turn are REST concepts) without reference to MVC.  Fielding mentions MVC in passing in his REST dissertation, when surveying preexisting peer-to-peer architectures, but REST itself is not based on an MVC way of thinking.

I would argue that there is not a "correct" way of implementing MVC in Restlet ... it's just that if you choose to think about server-side things this way, there are ways (as Thierry outlines) of accomplishing this.  Personally, I would set aside thinking about MVC on the server, in favor of thinking purely about REST.  I tend to find the MVC switch in my brain only activates when writing client side code, where it is ideally suited.

You may get widely divergent opinions on the list, but that is mine!  :-)

- Rob

On Fri, Nov 21, 2008 at 2:09 AM, Gan123 <narayanasgs1@...> wrote:


     i am creating a web application using Restlet based on MVC. i have
configured ServlerServlet to invoke my Application class, where i have all
the URI mappings. i am planning to use the Application class as controller
and Resource to implement business logic with other required patterns.

can any one suggest me whether this is the correct way to go ahead to
implement MVC application in RESTlet? how and when the Application will be
loaded? is it for every request or once per application ?

Thanks in advance.
--
View this message in context: http://n2.nabble.com/Restlet-MVC-tp1560691p1560691.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.


Avi Flax

Re: Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink
Bravo, Rob! I agree 100%!

FYI, the FAQ has an entry on MVC: http://www.restlet.org/documentation/1.1/faq#10

Not sure who wrote the answer, but if you do decide to follow MVC, I think the approach presented in the answer makes a lot of sense.

Avi

--
Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com
Tim Peierls

Re: Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink
Maybe the first line of that FAQ answer should be modified to avoid the word "implementation", e.g., "There is a rough correspondence between the MVC pattern [cite?] and the Restlet framework:"

--tim

On Fri, Nov 21, 2008 at 9:18 AM, Avi Flax <avif@...> wrote:
Bravo, Rob! I agree 100%!

FYI, the FAQ has an entry on MVC: http://www.restlet.org/documentation/1.1/faq#10

Not sure who wrote the answer, but if you do decide to follow MVC, I think the approach presented in the answer makes a lot of sense.

Avi

--
Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com

Avi Flax

Re: Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink
On Fri, Nov 21, 2008 at 09:44, Tim Peierls <tim@...> wrote:

> Maybe the first line of that FAQ answer should be modified to avoid the word "implementation", e.g., "There is a rough correspondence between the MVC pattern [cite?] and the Restlet framework:"

I think we can just change the word "implementing" to "following". But
I like the sentence you've proposed; I think we could just add that to
the answer, as the first sentence, like so:

"There is only a rough correspondence between the <a
href="http://en.wikipedia.org/wiki/Model-view-controller">MVC
pattern</a> and the Restlet framework; some <a
href="http://n2.nabble.com/Restlet-MVC-tp1560691p1561792.html">debate</a>
exists as to whether it should be employed at all. For those who wish
to follow the MVC pattern with Restlet, here is the basic
proposition:"

How's that?

Jerome, maybe it's time to move the FAQ to the Wiki so it can be more
readily edited!
jlouvel

RE: Restlet MVC

Reply Threaded MoreMore options
Print post
Permalink

Hi Avi,

Full agreement with Rob as well!

I have updated the FAQ as you suggested and reworded the rest of the entry for conciseness and to match the Restlet 1.1 API:
http://www.restlet.org/documentation/1.1/faq#10

Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Avi Flax [mailto:avif@...]
Envoyé : vendredi 21 novembre 2008 19:21
À : discuss@...
Objet : Re: Restlet MVC

On Fri, Nov 21, 2008 at 09:44, Tim Peierls <tim@...> wrote:

> Maybe the first line of that FAQ answer should be modified to avoid the word "implementation", e.g., "There is a rough correspondence between the MVC pattern [cite?] and the Restlet framework:"

I think we can just change the word "implementing" to "following". But
I like the sentence you've proposed; I think we could just add that to
the answer, as the first sentence, like so:

"There is only a rough correspondence between the <a
href="http://en.wikipedia.org/wiki/Model-view-controller">MVC
pattern</a> and the Restlet framework; some <a
href="http://n2.nabble.com/Restlet-MVC-tp1560691p1561792.html">debate</a>
exists as to whether it should be employed at all. For those who wish
to follow the MVC pattern with Restlet, here is the basic
proposition:"

How's that?

Jerome, maybe it's time to move the FAQ to the Wiki so it can be more
readily edited!