I see your point about it working without the interface but in my mind the Session interface helps me impose a contract. The Session interface implements four HTTP methods (along with a couple of non-HTTP methods) and annotates the HTTP methods at the interface level so that for one thing the correct HTTP method is used for the given operation (I.e. No one uses GET to create a session. That sort of thing happens all the time in so-called "RESTful" interfaces) and for another both the client side (the ClientResource that acts as a proxy to the session provisioner) and the server side share a common contract.
From: Tim Peierls <[email protected]<mailto:[email protected]>> Reply-To: discuss <[email protected]<mailto:[email protected]>> Date: Mon, 8 Aug 2011 19:45:01 -0500 To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: Re: Spring inject a Form constructed using the requestEntity What is the Session interface really doing for you? It doesn't look as though the abstract method is used in an essential way. Thought experiment: Comment out the abstract createSession method and put @Post in front of each concrete implementation of createSession. Still works, right? So there's no need for the method signatures to be the same. They don't even need to use the same name. You might as well use more specific signatures, especially in the case of Form, for which Restlet provides nice automatic conversion. --tim On Mon, Aug 8, 2011 at 7:06 PM, Paul Morris <[email protected]<mailto:[email protected]>> wrote: The interface is part of a very generic API for managing sessions and it's meant to support a wide variety of implementations, different session provisioners, etc. public interface Session { @Post abstract Representation createSession(Representation entity); // Other methods. } So my implementation supports webform params as in: username=pmorris&password=pmorrispmorris as well as HTTP Basic Authentication (details in the Auth header, null entity body) But some other developer implementing the interface may pass in some other Representation like JSON or XML, something that you wouldn't be consuming by casting to it a Form. Like: { "username" : "pmorris", "password" : "pmorrispmorris" } With Representation he can pass in whatever he wants and work out the details in his concrete implementation. This message and any included attachments are intended only for the addressee. The information contained in this message is confidential and may constitute proprietary or non-public information under international, federal, or state laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail. ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812677

