|
From: Bill B. <bb...@re...> - 2014-06-07 20:09:01
|
Unfortunately, the JAX-RS TCK expects that the MBW is not matched until
after the WriterInterceptor is invoked. We used to match prior to
invoking the interceptor chain...
So, you have 2 options:
1. In your WriterInterceptor buffer the json marshalling, change the
content header, flush the buffer.
2. Write a special MBW that delegates to the JSON writer and sets the
content header before doing this.
Make sense?
On 6/7/2014 1:00 PM, Heiko W.Rupp wrote:
> Hey,
>
> I have a use case where the user is requesting jsonp encoding e.g. via custom media type or a .jsonw ending.
>
> Anyway. I can intercept the call and surround with "jsonp();" successfully, but the returned
> content-type needs to be changed to "application/javascript".
>
> I could accept that as incoming type, but then RE is complaining about no matching MessageBodyWriter.
>
> So I am thinking of using ContainerWriteFilter to re-write this, but the calls seem to be
>
> MessageHandler method (@GET foo() {} ) (1)
> ContainerWriteFilter (2)
> <message body writer> (3)
> WriterInterceptor. (4)
> (5)
>
> So when I rewrite the content header in (2) a the mbw in (3) complains about wrong type and
> in (4) I can not check if the desired content type is my custom one to request the wrapping or not.
>
> So I would need to run a ContainerWriteFilter at (5) to rewrite the header *after* the interceptor has run.
>
> In RHQ I solved that with a normal servlet filter, but it looks like this does not work here because
> of Async processing (and rewriting the filter with an AsyncListener has its own issues )
>
> Thanks
> Heiko
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> Resteasy-users mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|