I did a minimal example based on the HelloWorld sample, and obviously things
work perfectly then. Obviously something else is wrong, I'll keep digging.
On Thu, Aug 14, 2008 at 9:58 PM, Daniel Larsson
<daniel.j.larsson_at_gmail.com>wrote:
> I haven't had time to try make a minimal example, but here's a short
> outtake of the declarations.
>
> I'm calling this with Accept: application/json
>
> Resource class:
>
> @Path("/test")
> @GET
> @Produces({"application/sparql-results+xml",
> "application/sparql-results+json",
> "application/rdf+xml", "text/rdf+n3", "application/json",
> "text/json"})
> public SPARQLQuery getTest() {
> ... }
>
> ...
>
> @Provider
>
> @Produces({"application/sparql-results+xml", "application/sparql-results+json",
> "application/rdf+xml", "text/rdf+n3", "application/json", "text/json"})
> @Consumes({"application/rdf+xml", "text/rdf+n3"})
> public class SPARQLQueryProvider implements MessageBodyWriter<SPARQLQuery>,
> MessageBodyReader<SPARQLQuery> {
> ...
> public void writeTo(
> SPARQLQuery query,
> Class<?> type,
> Type genericType,
> Annotation[] annotations,
> MediaType mediaType,
> MultivaluedMap<String, Object> headers,
> OutputStream out)
> throws IOException, WebApplicationException {
> // mediaType is "application/octet-stream" here
> }
>
> On Wed, Aug 13, 2008 at 11:41 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
>> Hi Daniel,
>>
>> The media type (content type) passed to the writer should always be the
>> most acceptable media type.
>>
>> The code recently change for the case when a resource method does not
>> declare what is produced i.e. the method or class is not has not annotated
>> with @Produces. In such a case the content type is determined from the set
>> of media types associated with the set message body reader that support for
>> the Java type and the the acceptable media types.
>>
>> Can you send me some example code of your resource class and your provider
>> as this will help me determine if there is a bug?
>>
>> Thanks,
>> Paul.
>>
>> Daniel Larsson wrote:
>>
>>> I recently updated my NetBeans installation, and got a newer jersey
>>> release (ProduceMime -> Produces, etc). What I've also noticed is a change
>>> in MessageBodyWriter<T>.writeTo. Previously, the mediaType parameter would
>>> reflect the request's Accept header value, but since the upgrade, I'm
>>> getting "application/octet-stream" sent to my provider.
>>>
>>> Have I relied on a misfeature until now? (My provider supports multiple
>>> media types, and used this parameter to pick the requested one)
>>>
>>
>> --
>> | ? + ? = To question
>> ----------------\
>> Paul Sandoz
>> x38109
>> +33-4-76188109
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>