dev@jsr311.java.net

Redirection and creation <was> Re: Container Independence

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 12 Apr 2007 13:23:59 +0200

Jerome Louvel wrote:
>> I know you want to avoid classes/interfaces but in this case I think
>> they really simplify things.
>
> Here is something that I have in mind:
>
> @WebResource("/orders/{orderId}")
> public Order {
>
> @WebMethod
> @RedirectionRef("/target/{orderId}")
> public void post(InputStream data) {
> ...
> }
> }
>

I think this is an improvement over your previous thoughts on having:

         @CreationRef
         public String getIdentifier() {...}

which IMHO introduces much more complexity than annotating the HTTP method.

The idea of using a URI template is a nice touch. Also I also find
rather appealing the renaming of UriTemplate and HttpMethod to
WebResource (i consider the issue with the WebResource interface as
separate thing) and WebMethod respectively.


> Of course, if finer control is preferred, we could have:
>
> @WebResource("/orders/{orderId}")
> public Order {
>
> @WebMethod
> public void post(InputStream data) {
> ...
>
> @Resource
> Context ctx;

'ctx' would need to be a field on the class or a parameter of the method
for standard injection to work. (we could do some byte code injection
:-) but that is tricky!)


> 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}");

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109