Hi Jan,
You can inject UriInfo, and other JAX-RS artifacts (like HttpHeades,
Request etc):
@Context UriInfo ui;
My preference is for constructor injection:
public MyMessageBodyWriter .... {
private final UriUnfi ui;
public MyMessageBodyWriter(@Context UriInfo ui) {
this.ui = ui;
}
}
But you can use field or method injection. Note that a thread local
proxy is injected so if you try to access the "ui" instance outside
the scope of a request an IllegalStateException will be thrown (e.g.
if you try and do System.out.println(ui) in the constructor).
Paul.
On Oct 4, 2009, at 12:12 PM, Jan Algermissen wrote:
> Can anyone provide a hint, how I access the actual circumstances
> (e.g. parameters) of a request inside the applied
> MessageBodyWriter's writeTo method?
>
> In my scenario, the produced body depends on some request parameters.
>
> Thanks,
> Jan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>