Marc Hadley wrote:
> On Mar 7, 2008, at 3:51 PM, Bill Burke wrote:
>>
>> Also, can consider a simple Representation interface? I know it would
>> be easy to implement one with the @Provider model, but I think its a
>> good idea.
>>
> I think the combination of Response and ResponseBuilder already fulfill
> the role of representation.
>
@GET
public Representation get()
{
Connection conn = ...;
Blob blob = rs.getBlob(...);
return new Representation() {
public write(OutputStream stream) {
// stream the output
blob.close();
rs.close();
conn.close();
}
};
}
Instead of requiring the awkward creation and registration of
MessageBodyWriters, you allow the component to return a Representation
object, which is really a MessageBodyWriter-like object instantiated by
the resource.
Restlet works this way. And so does Apache HttpClient (except in the
opposite direction). I know Ryan's initial RESTEasy project had this
idea as well.
Bill
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com