users@jsr311.java.net

Re: base-uri for MessageBodyReader

From: Reto Bachmann-Gmür <reto_at_gmuer.ch>
Date: Tue, 09 Sep 2008 10:55:57 +0200

Paul Sandoz wrote:
>
> On Sep 8, 2008, at 12:21 PM, Reto Bachmann-Gmür wrote:
>
>> Hi Paul,
>>
>> by default a provider is instantiated only once per application. Do
>> implementation have to change this behavior for Providers with
>> request-specific injections? Re-injecting the UriInfo on each request
>> doesn't seem an option because of concurrency issues.
>
>
> The injected instance can be a proxy that obtains the per-request
> instance from a thread-local variable. When the per-request stuff is
> instantiated it can be set on the relevant thread local variable.
missed that part of the spec, will implement it.

nice to see things working, thanks!

reto


>
> Paul.
>
>> Cheers,
>> reto
>>
>> Paul Sandoz wrote:
>>> Hi Reto,
>>> You can inject a UriInfo instance onto a field of a reader/writer,
>>> for example:
>>> @Context UriInfo ui;
>>> Paul.
>>> On Sep 8, 2008, at 8:31 AM, Reto Bachmann-Gmür wrote:
>>>> Hello
>>>>
>>>> I was writing a MessageBodyReader accepting RDF/XML and returning an
>>>> RDF-Graph instance when I noticed that my client uses relative URI
>>>> references:
>>>>
>>>>
>>>> PUT /editor/dynamic/page1 HTTP/1.1
>>>> Host: localhost:8282
>>>> Keep-Alive: 300
>>>> Connection: keep-alive
>>>> Content-Type: application/rdf+xml
>>>> Referer: http://localhost:8282/editor/static/disco.xhtml
>>>> Content-Length: 311
>>>>
>>>> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
>>>> <rdf:Description rdf:about="page1">
>>>> <infoBit xmlns="http://discobits.org/ontology#"
>>>> rdf:parseType="Literal">bla bla bla bla </infoBit>
>>>> <rdf:type
>>>> rdf:resource="http://discobits.org/ontology#XHTMLInfoDiscoBit"/>
>>>> </rdf:Description>
>>>> </rdf:RDF>
>>>>
>>>> In the MessageBodyReader I cannot reconstruct the full URI of the
>>>> subject of the two triples in the graph as I cannot access the fist
>>>> line of the http-request.
>>>>
>>>> I think the problem may occur with any formats supporting relative
>>>> URIs, for RDF things are particularly difficult as relative-uris are
>>>> permitted only in the serialization format, a valid RDF-Graph never
>>>> contains relative URI references.
>>>>
>>>> For MessageBodyWriter the situation is similar if the applications
>>>> wants to deliver relative URIs in the serilaized form. The issues
>>>> with writers is however less urgent, as it's usually acceptable to
>>>> deliver absolute URIs.
>>>>
>>>> Should MessageBodyReader have access to a context-URI? Or to the
>>>> full Request instead of just the entity headers?
>>>>
>>>> Reto
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
>>> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>