dev@jsr311.java.net

Re: Issue 1: Adding additional conneg metadata to _at_Produce/ConsumeXXX

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 09 Jul 2007 15:07:39 +0200

Dhanji R. Prasanna wrote:
>
>
> On 7/9/07, *Paul Sandoz* <Paul.Sandoz_at_sun.com
> <mailto:Paul.Sandoz_at_sun.com>> wrote:
>
>
>
> I presume that the 'canAccept' method would get called n times where n
> is the product of the number of items on each acceptable axis. And the
> runtime has to order the calls w.r.t. to the quality parameters.
> Although there could still be ambiguity, which takes precedence a
> "application/xml;q=0.8" with "en;q=0.6" or "application/json;q=0.6" with
> "fr;q=0.8"?
>
>
> Hmm good point I suppose this is where Jerome's List<Variant> holds its
> own in terms of simplicity.
>

Yes, although i am not sure if it handles the ambiguity edge case.


> However, i think that AcceptabilityEvaluator could be
> extended to a builder pattern (a nice parallel to Response.Builder) that
> could get around this issue:
>
> ae.accept(languages, type).
> accept(type, languages).build();
>
>
> Yea that's a good idea. I likes me builders =)
>

I thought you might :-)


> if the static method can get access to a runtime context from the
> current thread (although i am not sure if this is bad practice or not).
>
>
> It feels ugly but I think it is such an entrenched practice that it is
> probably ok (I mean servlet is built around ThreadLocal).
>

OK, i feel sort of the same, not sure we want to entrench the practice
further :-) ... field/parameter injection is incredibly powerful, but
for non-request-specific and constant ifaces i wonder how necessary it
is if things can be keyed off the current thread... (and for singleton
resources field injected stuff needs to be thread localized anyway).


> Where would one call the builder from?

 From the HTTP method. Although i do not see why for per-request
resources it could be called from the constructor and thrown as an
exception if the response is not 2xx, is constant for all HTTP methods,
and the request is associated for that resource.


> Im assuming it is a one-time
> action, per-resource.
>

I would assume so too.


> Just thinking aloud, we could also allow the AE to be injected to the
> http-method...
>

Yes, the interfaces annotated with HttpContext can be injected as a
field or as a method parameter [1].

Paul.

[1]
https://jsr311.dev.java.net/releases/0.1/javax/ws/rs/core/HttpContext.html


> I find that the introduction of a method calling order contract with the
> runtime can introduce complexities for the developer (which may be OK
> but we need to be aware of the consequences).
>
>
> Ok this is a very sensible point I concede it to you. It's important
> enough that an additional api-contract is mitigatory.
>
> Dhanji.
>

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