users@jersey.java.net

Re: [Jersey] FormParam problem in InjectableProvider and Spring

From: Cemo Koc <cem.koc.fwd_at_gmail.com>
Date: Fri, 13 Nov 2009 01:55:42 -0800 (PST)

Despite of being newbie in restful area, I believe that such an
implementation can be very beneficial for us. :) I am looking for your
implementation.

Thanks





Paul Sandoz wrote:
>
>
> Thinking out loud in the following....
>
> Having thought about this some more ideally what i would like to
> achieve is:
>
> @GET
> public XXX get(@Inject MyParamBean b) { ... } // I am referring to
> Jersey's @Inject annotation.
>
> which would replace:
>
> @GET
> public XXX get(@ResourceContext ResourceContext rc) { ...
> MyParamBean b = rc.get(MyParamBean.class);
> }
>
>
> Then for forms ideally we could do the same like:
>
> @POST
> @Consumes("application/x-www-form-urlencoded")
> public XXX post(@Inject MyParamBean b) { ... }
>
>
> The problem is there is a slight inconsistency in all this. Consider
> the following:
>
> public class Foo {
> public Foo(@Inject MyParamBean b) { ... }
>
> @GET
> public XXX get(@Inject MyParamBean b) { ... }
>
> @POST
> @Consumes("application/x-www-form-urlencoded")
> public XXX post(@Inject MyParamBean b);
> }
>
> Currently we only know that form parameters are present when the POST
> method is called, but the reference to b in the constructor parameter
> should be the same as the parameter of the get or post (default life-
> cycle is per-request).
>
> I am wondering if i should really relax things in this respect and go
> back on some of the things i said. The way we could do this is to
> buffer the request entity if it is of "application/x-www-form-
> urlencoded" and also parse the entity to an instance of Form from
> which @FormParam can operate. If there is no Form present we can throw
> an exception. Buffering would only occur if form parameters are
> accessed outside of the resource method, or cannot be detected from a
> resource method. However, i still do not like the fact form parameters
> could be processed from outside of the resource method.
>
> Marc, if you got this far :-), what do you think?
>
> Paul.
>
>
>

-- 
View this message in context: http://n2.nabble.com/FormParam-problem-in-InjectableProvider-and-Spring-tp3992897p3998312.html
Sent from the Jersey mailing list archive at Nabble.com.