Jerome Louvel wrote:
>>> ctx.redirectPermanent("/target/{orderId}";
>>> }
>>> }
>> How are the two approaches above simpler than having just one
>> solution to solve the problem, namely the returning of a Java object
>> (as Marc has previously shown):
>>
>> return new PermanentRedirect("/target/{orderId}");
>
> Because with one Context class you can solve many other problems like
> setting the status code, the reason phrase, local forward. It's simpler than
> having to rely on:
> - HttpContext
> - HttpRequestContext
> - HttpResponseContext
> - WebResource
> - Created
> - HttpResponse
> - TemporaryRedirect
>
> - NotModified
> 1 class instead of 8 different types, without loosing features is compelling
> enough for me.
>
I don't think i was very clear on how i was evaluating simplicity. I was
not evaluating it from a tally of classes/annotations. I was evaluating
simplicity by asking myself the following question: how does a developer
return a permanent redirect response?
Using your proposed approaches as i understand them from the emails i am
assuming one would do one of the following:
1) Implement a HTTP annotated method that returns void and is annotated
with RedirectionRef; or
2) Implement a POST method that returns void with a Context parameter,
or a via a Context field on the class, and call the method
redirectPermanent on the Context parameter/field when finished
processing the request; or
3) Annotate a method with RedirectionRef than returns the reference.
Ensure that this works with the appropriate HTTP request that
requires a redirect response.
Which should the developer use and why? What are the consequences for
choosing a particular option? What are the edge cases or traps that the
developer can get caught up in?
Using the TemporaryRedirect class there is one very basic way of doing it:
1) Implement a HTTP annotated method that returns an instance of
TemporaryRedirect.
The java documentation for TemporaryRedirect can be kept very simple and
precise:
"Return an instance of this class to respond to a request with a 307
(Temporary Redirect) response that contains a Location header field."
It is concise enough to fit in at the package-level summary documentation.
Paul.
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109