users@jersey.java.net

[Jersey] HttpRequestContext.getEntity(Class) using Jersey 2.x

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Sun, 23 Jun 2013 02:39:41 -0400

Hi,

     What is the equivalent of HttpRequestContext.getEntity(Class) for
Jersey 2.x? I see ContainerRequestContext.getEntityStream() but how do I
go from this InputStream to a POJO?

     My use-case is as follows: when a resource attempts to parse the
request entity, I'd like to log the entity's String representation so I
can reproduce the problem at a later time. In the past I used to:

1. Cache the entity before it was read by the resource.
2. Invoke HttpRequestContext.getEntity(String.class).

     I know it's relatively simply to construct a String from an
InputStream but tomorrow I might want to construct some other arbitrary
POJO from the InputStream, which brings us back to what is the
equivalent of HttpRequestContext.getEntity(Class) for Jersey 2.x?

Thanks,
Gili